@babbel/miza-kinesis

中文文档
6.0.0发布于 2025/02/06MITTypeScriptCommonJS近 30 天下载 4235

Library to emit Events to Kinesis Events Queue

原始使用文档
文档目录7 节
  1. Requirements
  2. Development
  3. Build
  4. Tests
  5. Usage
  6. Releasing new versions
  7. License

Miza-Kinesis

Provides an interface to create tracking events which are sent to AWS Kinesis.

Requirements

  • Nodejs >= 18 with NPM version >= 10

Development

Install dependencies:

npm install @babbel/miza-kinesis --save

Build

npm run build

Tests

npm test

Usage

Config to track single event:

const config = {
  appName: 'application-name',
  kinesisStream: {
    arn: 'Kinesis arn',
    connectTimeout: 1000,
    maxRetries: 10,
  },
  ipv4: '127.0.0.1', // optional
  endpoint: 'http://localhost:4568', // localstack only
};

Code Example:

const events = require('@babbel/miza-kinesis');

const emitEvent = events(config);

const event = {
  name: 'request:performed',
  meta: {
    // ...
  },
  // ... more
};

try {
  const data = await emitEvent(event);
  console.log(data)
}
catch(error) {
  console.error(error);
}

Config to track multiple events:

const config = {
  appName: 'application-name',
  kinesisStream: {
    arn: 'Kinesis arn',
    httpOptions: {
      connectTimeout: 1000,
      timeout: 1000,
    },
    maxRetries: 10,
  },
  ipv4: '127.0.0.1', // optional
  endpoint: 'http://localhost:4568', // localstack only
  type: 'BATCH',
};

Code Example:

const events = require('@babbel/miza-kinesis');

const emitEvent = events(config);

const events = [
  {
    name: 'request:performed',
    meta: {
      // ...
    },
  },
  {
    name: 'data:saved',
    meta: {
      // ...
    },
  },
];

try {
  const data = await emitEvent(event);
  console.log(data)
}
catch(error) {
  console.error(error);
}

Config has a following format:

  • appName - required added to the events meta data to give notice of it's origin
  • kinesisStream.arn - required Kinesis ARN where the events will be send
  • kinesisStream.httpOptions - optional specified in AWS SDK https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html
  • kinesisStream.maxRetries - optional the maximum amount of retries to attempt with a request. See AWS.Kinesis.maxRetries for more information.
  • config.maxRetries the maximum amount of retries to attempt for failed requests.
  • ipv4 - optional ip of the machine that is sending the event
  • endpoint - localstack-only we recommend to run the service in development environment using Localstack. Kinesis (from Localstack) will respond at the location http://localhost:4568. In order to work with Kinesis, you need to provide the location(endpoint) to the AWS-sdk configuration.
  • partitionKey - optional the key used to group data by shard within a stream.

emitEvent returns data in either of the following format: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html#putRecord-property or https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.html#putRecords-property

event specification you can check here: https://confluence.internal.babbel.com/wiki/display/PM/Event+Specifications

events array of events

Releasing new versions

In order to create a release:

  1. Add details about changes in CHANGELOG.md
  2. Version the new changes
    • Manual version update:
      1. Update the version in package.json of your feature branch
      2. Tag the last commit with the new version
        1. git tag v1.x.x
        2. git push origin v1.x.x
    • Automatic version update:
      1. Use npm version
  3. Merge to master!
    1. New versions are automatically published to npm on every merge to master

License

MIT Licensed. See LICENSE for full details.

版本与发布记录

@babbel/miza-kinesis 共发布 23 个版本,首次发布于 2020/06/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
6.0.0latest2025/02/061.7 年前
5.0.12024/06/262 年前
5.0.02024/06/262 年前
4.0.52023/08/013 年前
4.0.42023/07/273 年前
4.0.32023/07/213 年前

关于 @babbel/miza-kinesis 的常见问题

@babbel/miza-kinesis 是什么?

Library to emit Events to Kinesis Events Queue

如何安装 @babbel/miza-kinesis?

在项目目录运行 npm install @babbel/miza-kinesis,或使用 pnpm add / yarn add / bun add。

@babbel/miza-kinesis 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@babbel/miza-kinesis 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@babbel/miza-kinesis 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@babbel/miza-kinesis 可以商用吗?

@babbel/miza-kinesis 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@babbel/miza-kinesis 的下载量有多少?

根据 npm 官方下载统计,@babbel/miza-kinesis 在 2026/10/08 – 2026/11/06 这 30 天内被下载 4,235 次,日均约 141 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@babbel/miza-kinesis 还在维护吗?

最新版本 6.0.0 发布于 2025/02/06(1.7 年前);至今共发布 23 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/06/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。