@aircall/tracker
Advanced tools
Comparing version 3.0.5 to 3.1.1
@@ -1,6 +0,102 @@ | ||
import Tracker from './Tracker'; | ||
declare const tracker: Tracker; | ||
export * from './actions'; | ||
export * from './Tracker'; | ||
export default tracker; | ||
//# sourceMappingURL=index.d.ts.map | ||
declare enum TRACKER_ENVIRONMENT { | ||
DEVELOPMENT = "development", | ||
TEST = "test", | ||
STAGING = "staging", | ||
BETA = "beta", | ||
PRODUCTION = "production" | ||
} | ||
declare interface TrackerIdentification { | ||
user_id: number; | ||
release: string; | ||
company_id?: number; | ||
company_name?: string; | ||
company_plan?: string; | ||
company?: CompanyTrackerIdentification; | ||
created_at: string; | ||
device: string; | ||
device_details?: string; | ||
email: string; | ||
environment: TRACKER_ENVIRONMENT; | ||
is_admin: boolean; | ||
language: string; | ||
name: string; | ||
platform: string; | ||
os_version?: string; | ||
screen_size?: string; | ||
window_size?: string; | ||
} | ||
declare interface TrackerContext { | ||
cti_from_application: string; | ||
} | ||
type IUserOS = 'Windows' | 'MacOS' | 'Linux' | 'Unknown'; | ||
type ICompanyBillingPeriod = 'annually' | 'monthly'; | ||
type ICompanyTierLevel = string; | ||
type ICompanyPlan = string; | ||
declare interface CompanyTrackerIdentification { | ||
billing_period: ICompanyBillingPeriod; | ||
country: string; | ||
created_at: string; | ||
last_plan_change?: string; | ||
is_trial: boolean; | ||
tier: ICompanyTierLevel; | ||
} | ||
declare interface TrackerOptions { | ||
key: string; | ||
} | ||
declare const defaultIdentification: TrackerIdentification; | ||
declare class Tracker { | ||
private readonly options; | ||
context?: TrackerContext; | ||
private analytics; | ||
private identified; | ||
private identification; | ||
constructor(options: TrackerOptions); | ||
private get isDevelopment(); | ||
get isIdentified(): boolean; | ||
private get sdk(); | ||
init(): void; | ||
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 RudderStack otherwise. | ||
* @param message | ||
* @param properties | ||
*/ | ||
track(message: string, properties?: object): void; | ||
/** | ||
* Record a page view event | ||
* Add the local context to the given property. | ||
* Log it in the console when in development mode, send it to RudderStack otherwise. | ||
* @param options | ||
*/ | ||
page(properties?: object): void; | ||
reset(): void; | ||
} | ||
declare enum TRACKER { | ||
INIT = "TRACKER_INIT", | ||
TRACK = "TRACKER_TRACK", | ||
PAGE = "TRACKER_PAGE" | ||
} | ||
interface TrackerAction { | ||
type: TRACKER.TRACK; | ||
message: string; | ||
properties: object; | ||
} | ||
interface PageAction { | ||
type: TRACKER.PAGE; | ||
properties: object; | ||
} | ||
declare const initTracker: () => { | ||
type: TRACKER.INIT; | ||
}; | ||
declare const track: (message: string, properties?: object) => TrackerAction; | ||
declare const page: (properties?: object) => PageAction; | ||
export { CompanyTrackerIdentification, ICompanyBillingPeriod, ICompanyPlan, ICompanyTierLevel, IUserOS, PageAction, TRACKER, TRACKER_ENVIRONMENT, Tracker, TrackerAction, TrackerContext, TrackerIdentification, TrackerOptions, defaultIdentification, initTracker, page, track }; |
@@ -0,8 +1,146 @@ | ||
'use strict'; | ||
'use strict' | ||
var rudderanalytics = require('rudder-sdk-js'); | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./tracker.cjs.production.min.js') | ||
} else { | ||
module.exports = require('./tracker.cjs.development.js') | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
var rudderanalytics__namespace = /*#__PURE__*/_interopNamespace(rudderanalytics); | ||
// src/Tracker.ts | ||
var RUDDERSTACK_DATA_PLANE_URL = "https://aircall-dataplane.rudderstack.com"; | ||
var TRACKER_ENVIRONMENT = /* @__PURE__ */ ((TRACKER_ENVIRONMENT2) => { | ||
TRACKER_ENVIRONMENT2["DEVELOPMENT"] = "development"; | ||
TRACKER_ENVIRONMENT2["TEST"] = "test"; | ||
TRACKER_ENVIRONMENT2["STAGING"] = "staging"; | ||
TRACKER_ENVIRONMENT2["BETA"] = "beta"; | ||
TRACKER_ENVIRONMENT2["PRODUCTION"] = "production"; | ||
return TRACKER_ENVIRONMENT2; | ||
})(TRACKER_ENVIRONMENT || {}); | ||
var defaultIdentification = { | ||
user_id: 0, | ||
created_at: "", | ||
release: "default", | ||
device: "", | ||
email: "", | ||
is_admin: false, | ||
name: "", | ||
platform: "default", | ||
environment: "development" /* DEVELOPMENT */, | ||
language: "" | ||
}; | ||
var Tracker = class { | ||
constructor(options) { | ||
this.options = options; | ||
this.analytics = rudderanalytics__namespace; | ||
} | ||
context; | ||
analytics; | ||
identified = false; | ||
identification = defaultIdentification; | ||
// Getter to check if we are in development environment | ||
get isDevelopment() { | ||
return this.identification.environment === "development" /* DEVELOPMENT */; | ||
} | ||
// Getter to check if the module is identified with user's information | ||
get isIdentified() { | ||
return this.identified; | ||
} | ||
// Getter to access the RudderStack SDK | ||
get sdk() { | ||
return this.analytics; | ||
} | ||
// Init the module by dynamically injecting the RudderStack SDK | ||
init() { | ||
this.analytics.load(this.options.key, RUDDERSTACK_DATA_PLANE_URL); | ||
} | ||
// Identify user with TrackerIdentification | ||
identify(identification) { | ||
this.sdk?.identify(identification.user_id.toString(), identification); | ||
this.identification = identification; | ||
this.identified = true; | ||
} | ||
/** | ||
* 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 RudderStack otherwise. | ||
* @param message | ||
* @param properties | ||
*/ | ||
track(message, properties = {}) { | ||
const propertiesWithContext = { ...properties, ...this.context }; | ||
if (this.isDevelopment) { | ||
console.log("TRACK", message, propertiesWithContext); | ||
} else { | ||
this.sdk?.track(message, propertiesWithContext); | ||
} | ||
} | ||
/** | ||
* Record a page view event | ||
* Add the local context to the given property. | ||
* Log it in the console when in development mode, send it to RudderStack otherwise. | ||
* @param options | ||
*/ | ||
page(properties = {}) { | ||
const propertiesWithContext = { ...properties, ...this.context }; | ||
if (this.isDevelopment) { | ||
console.log("PAGE", propertiesWithContext); | ||
} else { | ||
this.sdk?.page(propertiesWithContext); | ||
} | ||
} | ||
// Resets the id, including anonymousId, and clears traits for the currently identified user | ||
reset() { | ||
this.sdk?.reset(); | ||
} | ||
}; | ||
// src/actions.ts | ||
var TRACKER = /* @__PURE__ */ ((TRACKER2) => { | ||
TRACKER2["INIT"] = "TRACKER_INIT"; | ||
TRACKER2["TRACK"] = "TRACKER_TRACK"; | ||
TRACKER2["PAGE"] = "TRACKER_PAGE"; | ||
return TRACKER2; | ||
})(TRACKER || {}); | ||
var initTracker = () => ({ | ||
type: "TRACKER_INIT" /* INIT */ | ||
}); | ||
var track = (message, properties = {}) => ({ | ||
type: "TRACKER_TRACK" /* TRACK */, | ||
message, | ||
properties | ||
}); | ||
var page = (properties = {}) => ({ | ||
type: "TRACKER_PAGE" /* PAGE */, | ||
properties | ||
}); | ||
exports.TRACKER = TRACKER; | ||
exports.TRACKER_ENVIRONMENT = TRACKER_ENVIRONMENT; | ||
exports.Tracker = Tracker; | ||
exports.defaultIdentification = defaultIdentification; | ||
exports.initTracker = initTracker; | ||
exports.page = page; | ||
exports.track = track; |
{ | ||
"name": "@aircall/tracker", | ||
"version": "3.0.5", | ||
"version": "3.1.1", | ||
"main": "dist/index.js", | ||
"module": "dist/tracker.esm.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
@@ -19,7 +19,7 @@ "sideEffects": false, | ||
{ | ||
"path": "dist/tracker.cjs.production.min.js", | ||
"path": "dist/index.js", | ||
"limit": "24 KB" | ||
}, | ||
{ | ||
"path": "dist/tracker.esm.js", | ||
"path": "dist/index.mjs", | ||
"limit": "15 KB" | ||
@@ -32,10 +32,11 @@ } | ||
"devDependencies": { | ||
"@types/jest": "29", | ||
"@types/jest": "29.5.2", | ||
"jest": "29.5.0", | ||
"ts-jest": "29.1.0", | ||
"@size-limit/preset-small-lib": "8.1.0", | ||
"eslint": "8.30.0", | ||
"@aircall/eslint-config": "1.2.4", | ||
"husky": "8.0.1", | ||
"@aircall/eslint-config": "1.2.5", | ||
"size-limit": "8.1.0", | ||
"@aircall/tsconfig": "1.2.2", | ||
"tsdx": "0.14.1", | ||
"@aircall/tsconfig": "1.3.1", | ||
"tsup": "6.7.0", | ||
"tslib": "2.4.0", | ||
@@ -45,5 +46,5 @@ "jest-environment-jsdom": "29.5.0" | ||
"scripts": { | ||
"dev": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "tsdx test --passWithNoTests", | ||
"dev": "pnpm build --watch", | ||
"build": "tsup --config ../../tsup.config.ts", | ||
"test": "jest --passWithNoTests", | ||
"posttest": "pnpm run size", | ||
@@ -50,0 +51,0 @@ "lint": "eslint --ext ts src", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
1
13104
11
4
240