@babbel/miza-kinesis v4.0.5
Miza-Kinesis
Provides an interface to create tracking events which are sent to AWS Kinesis.
Requirements
- Nodejs >= 12 with NPM version >= 8
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 originkinesisStream.arn
- required Kinesis ARN where the events will be sendkinesisStream.httpOptions
- optional specified in AWS SDK https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Kinesis.htmlkinesisStream.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 eventendpoint
- localstack-only we recommend to run the service in development environment using Localstack. Kinesis (from Localstack) will respond at the locationhttp://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:
- Add details about changes in
CHANGELOG.md
- Version the new changes
- Manual version update:
- Update the version in
package.json
of your feature branch - Tag the last commit with the new version
git tag v1.x.x
git push origin v1.x.x
- Update the version in
- Automatic version update:
- Use
npm version
- Use
- Manual version update:
- Merge to master!
- New versions are automatically published to npm on every merge to
master
- New versions are automatically published to npm on every merge to
License
MIT Licensed. See LICENSE for full details.
10 months ago
10 months ago
10 months ago
12 months ago
1 year ago
1 year ago
1 year ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago