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

@aircall/tracker

v3.2.2

Published

## Introduction

Downloads

615

Readme

@aircall/tracker

Introduction

The tracker package, @aircall/tracker, serves as a common implementation for tracking events across Aircall frontend applications. This module is essentially a wrapper around the RudderStack JavaScript SDK, providing a simplified interface for tracking user activity in our applications.

Why use it?

The @aircall/tracker promotes the use of a unified tracking implementation across all Aircall frontend teams. This ensures consistency, reduces redundancy, and gives us the flexibility to switch to another tracking solution with minimal effort if the need arises.

Getting Started

To use the @aircall/tracker package in your project, follow the steps below:

  1. Install the package:

Using npm:

npm install @aircall/tracker

Using yarn:

yarn add @aircall/tracker
  1. Import the tracker instance into your application:
import tracker from '@aircall/tracker';
  1. Initialize the tracker with your specific RudderStack write key:
tracker.init({ key: 'YOUR_RUDDERSTACK_WRITE_KEY' });

Replace 'YOUR_RUDDERSTACK_WRITE_KEY' with the actual Rudderstack write key provided by the data team for your application.

Usage

After initializing the tracker module, you can use it for tracking events in your application. The tracker instance exposes four main methods: identify, track, addContext, and reset.

Identify

The identify method allows for user identification. It takes an identification object as an argument, which includes the user ID and any other relevant information you want to associate with the user.

tracker.identify({
  created_at: "2022-09-05T11:05:45.000Z"
  device: "web"
  email: '[email protected]',
  environment: "production",
  is_admin: false,
  language: "en_US"
  name: 'Test User',
  os_version: "OS X 10.15.7 64-bit"
  platform: 'phone',
  release: "v2.85.2"
  user_id: 123, // The user ID
});

The TrackerIdentification TypeScript interface outlines the necessary payload properties for tracking identification, as required by the data team. You can refer to the interface definition for more details, or import it from the package and use it as a type for your identification object.

import { TrackerIdentification } from '@aircall/tracker';

const identificationObject: TrackerIdentification = {
  user_id: 123,
  /* ... */
};

For additional information on the identify method, please refer to the Identify | RudderStack JavaScript SDK API docs.

Add Context

The addContext method is used to add context to the tracker instance, which will be sent along with all subsequent tracking events. It accepts a context object as an argument.

We use it on the phone app to add the cti_from_application property, which indicates the CTI application from which the event was sent.

tracker.addContext({ cti_from_application: 'salesforce' });

Track

The track method is used for tracking user events. It accepts the tracking event name and an optional event properties object as arguments. This method also includes any context properties that were previously set via the addContext method in the event payload.

tracker.track('event_name', {
  property1: 'value1',
  property2: 'value2',
  property3: 'value3',
});

For additional information on the track method, please refer to the Track | RudderStack JavaScript SDK API docs.

Page

The page method is used to record a page view event. It accepts an optional properties object as an argument. This method also includes any context properties that were previously set via the addContext method in the event payload.

tracker.page({
  property1: 'value1',
  property2: 'value2',
  property3: 'value3',
});

For additional information on the page method, please refer to the Page | RudderStack JavaScript SDK API docs.

Reset

The reset method is used to reset the information related to the previously identified user. It is used when a user logs out of the application.

tracker.reset();

For additional information on the reset method, please refer to the Track | RudderStack JavaScript SDK API docs.