3.2.2 • Published 8 months ago

@aircall/tracker v3.2.2

Weekly downloads
135
License
-
Repository
-
Last release
8 months ago

@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.

3.2.2

8 months ago

3.1.3

10 months ago

3.2.1

9 months ago

3.1.2

10 months ago

3.0.4

11 months ago

3.0.3

11 months ago

3.1.1

11 months ago

3.0.5

11 months ago

3.0.2

12 months ago

3.0.0

1 year ago

2.7.1

1 year ago

2.7.0

2 years ago

2.6.0

2 years ago

2.5.2

2 years ago

2.5.3

2 years ago

2.5.1

2 years ago

2.4.0

3 years ago

2.3.13

3 years ago

2.3.14

3 years ago

2.3.11

3 years ago

2.3.10

4 years ago

2.3.9

4 years ago

2.3.8

4 years ago

2.3.7

4 years ago

2.3.6

4 years ago

2.3.5

4 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago