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

@aircall/tracker

Package Overview
Dependencies
Maintainers
5
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aircall/tracker - npm Package Compare versions

Comparing version 2.5.3 to 2.6.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [2.6.0](https://gitlab.com/aircall/shared/front-end-modules/compare/@aircall/tracker@2.5.3...@aircall/tracker@2.6.0) (2022-08-26)
### Features
* **tracker:** [PH-7496] add "cti_from_application" to common payload ([01b77fa](https://gitlab.com/aircall/shared/front-end-modules/commit/01b77fac1cce7d8e3f093d2ddd8958b47bec4a1d))
## [2.5.3](https://gitlab.com/aircall/shared/front-end-modules/compare/@aircall/tracker@2.5.2...@aircall/tracker@2.5.3) (2022-08-09)

@@ -8,0 +19,0 @@

@@ -37,2 +37,5 @@ export declare class AnalyticsJS extends Array {

}
export declare interface TrackerContext {
cti_from_application: string;
}
export declare type IUserOS = 'Windows' | 'MacOS' | 'Linux' | 'Unknown';

@@ -55,2 +58,3 @@ export declare type ICompanyBillingPeriod = 'annually' | 'monthly';

export default class Tracker {
context?: TrackerContext;
constructor();

@@ -65,4 +69,16 @@ private identified;

identify(identification: TrackerIdentification): void;
/**
* Store the context into the class
* @param context
*/
addContext(context: TrackerContext): void;
/**
* Track an event.
* Add the local context to the given property.
* Log it in the console when in development mode, send it to Segment otherwise.
* @param message
* @param properties
*/
track(message: string, properties?: object): void;
reset(): void;
}

20

dist/Tracker.js

@@ -85,9 +85,23 @@ "use strict";

}
// Track an event (log it in the console when in development mode, send it to Segment otherwise)
/**
* Store the context into the class
* @param context
*/
addContext(context) {
this.context = context;
}
/**
* Track an event.
* Add the local context to the given property.
* Log it in the console when in development mode, send it to Segment otherwise.
* @param message
* @param properties
*/
track(message, properties = {}) {
const propertiesWithContext = Object.assign(Object.assign({}, properties), this.context);
if (this.isDevelopment) {
console.log('TRACK', message, properties); // eslint-disable-line no-console
console.log('TRACK', message, propertiesWithContext); // eslint-disable-line no-console
}
else {
this.sdk.track(message, properties);
this.sdk.track(message, propertiesWithContext);
}

@@ -94,0 +108,0 @@ }

4

package.json
{
"name": "@aircall/tracker",
"version": "2.5.3",
"version": "2.6.0",
"main": "dist/index.js",

@@ -14,3 +14,3 @@ "types": "dist/index.d.ts",

},
"gitHead": "448b130786b09ea8a228295e159e5d07265c8520",
"gitHead": "662f36791e522dadaeb14a1263d39bf8819738c4",
"devDependencies": {

@@ -17,0 +17,0 @@ "@types/segment-analytics": "0.0.34"

@@ -102,2 +102,14 @@ import Tracker, {

});
it('should add context if any', (): void => {
const context = { cti_from_application: 'cti_name' };
tracker.addContext(context);
const spy: jest.SpyInstance = jest.spyOn(window.analytics, 'track');
tracker.init(initOptions);
tracker.identify(identifyOptions);
tracker.track(message, properties);
expect(spy).toHaveBeenCalledWith(message, { ...properties, ...context });
});
});

@@ -104,0 +116,0 @@

@@ -55,2 +55,6 @@ export class AnalyticsJS extends Array {

export declare interface TrackerContext {
cti_from_application: string;
}
export type IUserOS = 'Windows' | 'MacOS' | 'Linux' | 'Unknown';

@@ -88,2 +92,4 @@ export type ICompanyBillingPeriod = 'annually' | 'monthly';

export default class Tracker {
context?: TrackerContext;
/*

@@ -141,8 +147,24 @@ We temporarly define the analytics global variable with an instance of AnalyticsJS.

// Track an event (log it in the console when in development mode, send it to Segment otherwise)
/**
* Store the context into the class
* @param context
*/
public addContext(context: TrackerContext): void {
this.context = context;
}
/**
* Track an event.
* Add the local context to the given property.
* Log it in the console when in development mode, send it to Segment otherwise.
* @param message
* @param properties
*/
public track(message: string, properties: object = {}): void {
const propertiesWithContext = { ...properties, ...this.context };
if (this.isDevelopment) {
console.log('TRACK', message, properties); // eslint-disable-line no-console
console.log('TRACK', message, propertiesWithContext); // eslint-disable-line no-console
} else {
this.sdk.track(message, properties);
this.sdk.track(message, propertiesWithContext);
}

@@ -149,0 +171,0 @@ }

Sorry, the diff of this file is not supported yet

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