npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@babbel/miza-kinesis

v5.0.1

Published

Library to emit Events to Kinesis Events Queue

Downloads

1,171

Readme

Miza-Kinesis

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

Requirements

  • Nodejs >= 16 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 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.