Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aircall/tracker

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aircall/tracker

## Introduction

  • 3.1.3
  • npm
  • Socket score

Version published
Weekly downloads
121
increased by21%
Maintainers
3
Weekly downloads
 
Created
Source

@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: 'test@example.com',
  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.

FAQs

Package last updated on 05 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc