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

@ht-sdks/events-sdk-node

v1.0.3

Published

HT Events Node SDK

Downloads

3,569

Readme

Events Node.js SDK

This SDK lets you track user event data from your Node applications.

Supported Versions of Node

See https://nodejs.dev/en/about/releases/ for currently supported and recommended versions of Node. Unsupported versions may work for this SDK, but Node versions older than 12 will require ES2019 polyfills.

Installing the SDK

Run the following command to install the Node.js SDK via npm:

$ npm install @ht-sdks/events-sdk-node

Using the SDK

Create a global client:

const Analytics = require('@ht-sdks/events-sdk-node');

const client = new Analytics(WRITE_KEY, {
  dataPlaneUrl: DATA_PLANE_URL,
});

SDK Initialization Options

Below parameters are optional and can be passed during SDK initialization:

| Name | Type | Default value | Description | | :--------------------- | :------- | :------------ | :------------------------------------------------------------------------------------------------ | | dataPlaneUrl | String | | The data plane URL. | | path | String | /v1/batch | Path to batch endpoint. | | flushAt | Number | 20 | The number of events to be flushed when reached this limit. | | flushInterval | Number | 10000 | The maximum timespan (in milliseconds) after which the events from the in-memory queue is flushed | | maxQueueSize | Number | 460800(500kb) | Maximum payload size of a batch request | | maxInternalQueueSize | Number | 20000 | The maximum length of the in-memory queue | | logLevel | String | 'info' | Log level. Ex: 'debug', 'error' | | axiosConfig | Object | N/A | Axios config | | axiosInstance | Object | N/A | Axios instance | | axiosRetryConfig | Object | N/A | Axios retry configuration | | retryCount | Number | 3 | Number of times requests will be retried by axios if failed | | errorHandler | Function | N/A | A function that will be called if request to server failed | | gzip | Boolean | true | Whether to compress request with gzip or not |

Example calls

Unlike the client-side SDKs that deal with a single user at a given time, the server-side SDKs deal with multiple users simultaneously. Therefore, you must specify either the userId or anonymousId every time while making any API calls supported by the Node SDK.

Identify

client.identify({
  userId: '1hKOmRA4GRlm',
  traits: {
    name: 'Alex Keener',
    email: '[email protected]',
    plan: 'Free',
    friends: 21,
  },
});

Track

client.track({
  userId: '1hKOmRA4GRlm',
  event: 'Item Viewed',
  properties: {
    revenue: 19.95,
    shippingMethod: 'Premium',
  },
});

Page

client.page({
  userId: '1hKOmRA4GRlm',
  category: 'Food',
  name: 'Pizza',
  properties: {
    url: 'https://example.com',
    title: 'Pizza',
    referrer: 'https://google.com',
  },
});

Screen

client.screen({
  userId: '12345',
  category: 'Food',
  name: 'Pizza',
  properties: {
    screenSize: 10,
    title: 'Pizza',
    referrer: 'https://google.com',
  },
});

Group

client.group({
  userId: '12345',
  groupId: '1',
  traits: {
    name: 'Company',
    description: 'Google',
  },
});

Alias

client.alias({
  previousId: 'old_id',
  userId: 'new_id',
});