@deriv-com/analytics 1.4.10

Sign up to get free protection for your applications and to get access to all the features.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Deriv
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # `@deriv/analytics`
2
+
3
+ The analytics package contains all the utility functions used for tracking user events and sending them to the respective platform such as Rudderstack and GrowthBook.
4
+
5
+ **In this document**
6
+
7
+ - [Analytics](#analytics)
8
+ - [What is Analytics?](#what-is-analytics)
9
+ - [Installation and initialisation](#installation)
10
+ - [Usage](#usage)
11
+
12
+ ### What is Analytics?
13
+
14
+ Cross-project, connected user tracking events with A/B testing features
15
+
16
+ ### Installation
17
+
18
+ To install the package, run the following command:
19
+
20
+ ```
21
+ $ npm i @deriv/analytics
22
+ ```
23
+
24
+ To proper initialisation of the package, pass proper keys in special function in special for init functions place:
25
+
26
+ ```js
27
+ Analytics?.initialise({
28
+ growthbookKey: process.env.GROWTHBOOK_CLIENT_KEY, // optional key to enable A/B tests
29
+ growthbookDecryptionKey: process.env.GROWTHBOOK_DECRYPTION_KEY, // optional key to enable A/B tests
30
+ // mandatory key to enable userevent tracking
31
+ rudderstackKey: RUDDERSTACK_KEY,
32
+ })
33
+ ```
34
+
35
+ To make good strategy for A/B testing we need to create some condition depends on data:
36
+
37
+ ```js
38
+ Analytics?.setAttributes({
39
+ user_language: getLanguage(),
40
+ device_language: navigator?.language,
41
+ country: this.country,
42
+ })
43
+ ```
44
+
45
+ And you finally can use the tracking events and A/B testing features
46
+
47
+ ### Usage
48
+
49
+ To start using it, let's observe on SDK usage examples:
50
+
51
+ ```js
52
+ import { Analytics } from '@deriv/analytics';
53
+
54
+ // Tracking features:
55
+ Analytics?.identifyEvent() // inentify the user
56
+ Analytics?.pageView() // track that page is showed for user
57
+ const user_id = Analytics?.getId() // get an user anon or real id
58
+
59
+
60
+ // Track Event
61
+ Analytics?.trackEvent('ce_virtual_signup_form', {
62
+ action: 'open',
63
+ form_name: 'default_diel_deriv',
64
+ form_source: document?.referrer,
65
+ signup_provider: 'email',
66
+ })
67
+
68
+ // the same as example below, to not to add repetable properties again and again
69
+ const analyticsData: Parameters<typeof Analytics.trackEvent>[1] = {
70
+ form_name: 'default_diel_deriv',
71
+ }
72
+ Analytics?.trackEvent('ce_virtual_signup_form', {
73
+ action: 'open',
74
+ signup_provider: 'email',
75
+ ...analyticsData
76
+ })
77
+ Analytics?.trackEvent('ce_virtual_signup_form', {
78
+ action: 'close',
79
+ signup_provider: 'google',
80
+ ...analyticsData
81
+ })
82
+
83
+ // A/B testing features
84
+ const test_toggle_aa_test = Analytics?.getFeatureState('test-toggle-aa-test') // returns value of experiment
85
+ const common_test = Analytics?.getFeatureValue('common-test', 'fallback') // returns feature flag's boolen
86
+ ```
87
+
88
+ If you need to get entire instance directly:
89
+
90
+ ```js
91
+ const { ab, tracking } = Analytics?.getInstances()
92
+ ```
93
+
94
+ If you want to check your ID
95
+
96
+ ```js
97
+ window.getMyId()
98
+ ```
@@ -0,0 +1,63 @@
1
+ import { Growthbook } from './growthbook';
2
+ import { RudderStack } from './rudderstack';
3
+ import { TCoreAttributes, TEvents } from './types';
4
+ type Options = {
5
+ growthbookKey?: string;
6
+ growthbookDecryptionKey?: string;
7
+ rudderstackKey: string;
8
+ };
9
+ export declare function createAnalyticsInstance(options?: Options): {
10
+ initialise: ({ growthbookKey, growthbookDecryptionKey, rudderstackKey }: Options) => void;
11
+ setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, app_id, }: TCoreAttributes) => void;
12
+ identifyEvent: () => void;
13
+ getFeatureState: (id: string) => string | undefined;
14
+ getFeatureValue: <T>(id: string, defaultValue?: T | undefined) => boolean | ((attributes: import("@growthbook/growthbook").Attributes) => void) | ((options?: import("@growthbook/growthbook").LoadFeaturesOptions | undefined) => Promise<void>) | ((options?: import("@growthbook/growthbook").RefreshFeaturesOptions | undefined) => Promise<void>) | (() => [string, string]) | (() => {
15
+ apiHost: string;
16
+ streamingHost: string;
17
+ apiRequestHeaders?: Record<string, string> | undefined;
18
+ streamingHostRequestHeaders?: Record<string, string> | undefined;
19
+ }) | (() => string) | (() => boolean) | (() => string[] | undefined) | ((features: Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((experiments: import("@growthbook/growthbook").AutoExperiment[]) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((overrides: import("@growthbook/growthbook").Attributes) => void) | ((vars: Record<string, number>) => void) | ((map: Map<string, any>) => void) | ((url: string) => void) | (() => {
20
+ [x: string]: any;
21
+ }) | (() => Record<string, number>) | (() => Map<string, any>) | (() => string) | (() => Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) | (() => import("@growthbook/growthbook").AutoExperiment[]) | ((cb: import("@growthbook/growthbook").SubscriptionFunction) => () => void) | (() => Map<string, {
22
+ experiment: import("@growthbook/growthbook").Experiment<any>;
23
+ result: import("@growthbook/growthbook").Result<any>;
24
+ }>) | (() => void) | ((renderer: () => void) => void) | ((key: string, variation: number) => void) | (<T_1>(experiment: import("@growthbook/growthbook").Experiment<T_1>) => import("@growthbook/growthbook").Result<T_1>) | ((key: string) => import("@growthbook/growthbook").Result<import("@growthbook/growthbook").AutoExperimentVariation> | null) | (<K extends string = string>(key: K) => boolean) | (<K_1 extends string = string>(key: K_1) => boolean) | (<V extends any, K_2 extends string = string>(key: K_2, defaultValue: V) => import("@growthbook/growthbook").WidenPrimitives<V>) | (<V_1 extends any, K_3 extends string = string>(id: K_3) => import("@growthbook/growthbook").FeatureResult<V_1 | null>) | (<V_2 extends any, K_4 extends string = string>(id: K_4) => import("@growthbook/growthbook").FeatureResult<V_2 | null>) | ((msg: string, ctx: Record<string, unknown>) => void);
25
+ isFeatureOn: (key: string) => boolean;
26
+ setUrl: (href: string) => void;
27
+ getId: () => string;
28
+ trackEvent: <T_2 extends keyof TEvents>(event: T_2, analyticsData: TEvents[T_2]) => void;
29
+ getInstances: () => {
30
+ ab: Growthbook;
31
+ tracking: RudderStack;
32
+ };
33
+ pageView: (current_page: string, platform?: string) => void;
34
+ reset: () => void;
35
+ };
36
+ export declare const Analytics: {
37
+ initialise: ({ growthbookKey, growthbookDecryptionKey, rudderstackKey }: Options) => void;
38
+ setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, app_id, }: TCoreAttributes) => void;
39
+ identifyEvent: () => void;
40
+ getFeatureState: (id: string) => string | undefined;
41
+ getFeatureValue: <T>(id: string, defaultValue?: T | undefined) => boolean | ((attributes: import("@growthbook/growthbook").Attributes) => void) | ((options?: import("@growthbook/growthbook").LoadFeaturesOptions | undefined) => Promise<void>) | ((options?: import("@growthbook/growthbook").RefreshFeaturesOptions | undefined) => Promise<void>) | (() => [string, string]) | (() => {
42
+ apiHost: string;
43
+ streamingHost: string;
44
+ apiRequestHeaders?: Record<string, string> | undefined;
45
+ streamingHostRequestHeaders?: Record<string, string> | undefined;
46
+ }) | (() => string) | (() => boolean) | (() => string[] | undefined) | ((features: Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((experiments: import("@growthbook/growthbook").AutoExperiment[]) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((overrides: import("@growthbook/growthbook").Attributes) => void) | ((vars: Record<string, number>) => void) | ((map: Map<string, any>) => void) | ((url: string) => void) | (() => {
47
+ [x: string]: any;
48
+ }) | (() => Record<string, number>) | (() => Map<string, any>) | (() => string) | (() => Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) | (() => import("@growthbook/growthbook").AutoExperiment[]) | ((cb: import("@growthbook/growthbook").SubscriptionFunction) => () => void) | (() => Map<string, {
49
+ experiment: import("@growthbook/growthbook").Experiment<any>;
50
+ result: import("@growthbook/growthbook").Result<any>;
51
+ }>) | (() => void) | ((renderer: () => void) => void) | ((key: string, variation: number) => void) | (<T_1>(experiment: import("@growthbook/growthbook").Experiment<T_1>) => import("@growthbook/growthbook").Result<T_1>) | ((key: string) => import("@growthbook/growthbook").Result<import("@growthbook/growthbook").AutoExperimentVariation> | null) | (<K extends string = string>(key: K) => boolean) | (<K_1 extends string = string>(key: K_1) => boolean) | (<V extends any, K_2 extends string = string>(key: K_2, defaultValue: V) => import("@growthbook/growthbook").WidenPrimitives<V>) | (<V_1 extends any, K_3 extends string = string>(id: K_3) => import("@growthbook/growthbook").FeatureResult<V_1 | null>) | (<V_2 extends any, K_4 extends string = string>(id: K_4) => import("@growthbook/growthbook").FeatureResult<V_2 | null>) | ((msg: string, ctx: Record<string, unknown>) => void);
52
+ isFeatureOn: (key: string) => boolean;
53
+ setUrl: (href: string) => void;
54
+ getId: () => string;
55
+ trackEvent: <T_2 extends keyof TEvents>(event: T_2, analyticsData: TEvents[T_2]) => void;
56
+ getInstances: () => {
57
+ ab: Growthbook;
58
+ tracking: RudderStack;
59
+ };
60
+ pageView: (current_page: string, platform?: string) => void;
61
+ reset: () => void;
62
+ };
63
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.Analytics = exports.createAnalyticsInstance = void 0;
15
+ var growthbook_1 = require("./growthbook");
16
+ var rudderstack_1 = require("./rudderstack");
17
+ function createAnalyticsInstance(options) {
18
+ var _growthbook, _rudderstack;
19
+ var initialise = function (_a) {
20
+ var growthbookKey = _a.growthbookKey, growthbookDecryptionKey = _a.growthbookDecryptionKey, rudderstackKey = _a.rudderstackKey;
21
+ _rudderstack = rudderstack_1.RudderStack.getRudderStackInstance(rudderstackKey);
22
+ if (growthbookKey && growthbookDecryptionKey) {
23
+ _growthbook = growthbook_1.Growthbook.getGrowthBookInstance(growthbookKey, growthbookDecryptionKey);
24
+ }
25
+ };
26
+ if (options) {
27
+ initialise(options);
28
+ }
29
+ var coreData = {};
30
+ var setAttributes = function (_a) {
31
+ var country = _a.country, user_language = _a.user_language, device_language = _a.device_language, device_type = _a.device_type, account_type = _a.account_type, user_id = _a.user_id, app_id = _a.app_id;
32
+ if (!_growthbook && !_rudderstack)
33
+ return;
34
+ var user_identity = user_id ? user_id : getId();
35
+ // Check if we have Growthbook instance
36
+ if (_growthbook) {
37
+ _growthbook.setAttributes({
38
+ id: user_identity || getId(),
39
+ country: country,
40
+ user_language: user_language,
41
+ device_language: device_language,
42
+ device_type: device_type,
43
+ });
44
+ }
45
+ coreData = __assign(__assign(__assign(__assign(__assign({}, (user_language !== undefined && { user_language: user_language })), (account_type !== undefined && { account_type: account_type })), (app_id !== undefined && { app_id: app_id })), (device_type !== undefined && { device_type: device_type })), (user_identity !== undefined && { user_identity: user_identity }));
46
+ };
47
+ var getFeatureState = function (id) { var _a, _b; return (_b = (_a = _growthbook === null || _growthbook === void 0 ? void 0 : _growthbook.getFeatureState(id)) === null || _a === void 0 ? void 0 : _a.experimentResult) === null || _b === void 0 ? void 0 : _b.name; };
48
+ var getFeatureValue = function (id, defaultValue) { return _growthbook === null || _growthbook === void 0 ? void 0 : _growthbook.getFeatureValue(id, defaultValue); };
49
+ var isFeatureOn = function (key) { return _growthbook === null || _growthbook === void 0 ? void 0 : _growthbook.isOn(key); };
50
+ var setUrl = function (href) { return _growthbook === null || _growthbook === void 0 ? void 0 : _growthbook.setUrl(href); };
51
+ var getId = function () { return (_rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.getUserId()) || (_rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.getAnonymousId()); };
52
+ // for QA testing purposes
53
+ window.getMyId = getId;
54
+ /**
55
+ * Pushes page view event to Rudderstack
56
+ *
57
+ * @param curret_page The name or URL of the current page to track the page view event
58
+ */
59
+ var pageView = function (current_page, platform) {
60
+ if (platform === void 0) { platform = 'Deriv App'; }
61
+ if (!_rudderstack)
62
+ return;
63
+ _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.pageView(current_page, platform, getId());
64
+ };
65
+ var identifyEvent = function () {
66
+ if ((coreData === null || coreData === void 0 ? void 0 : coreData.user_identity) && _rudderstack) {
67
+ _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.identifyEvent(coreData === null || coreData === void 0 ? void 0 : coreData.user_identity, { language: (coreData === null || coreData === void 0 ? void 0 : coreData.user_language) || 'en' });
68
+ }
69
+ };
70
+ var reset = function () {
71
+ if (!_rudderstack)
72
+ return;
73
+ _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.reset();
74
+ };
75
+ var trackEvent = function (event, analyticsData) {
76
+ if (!_rudderstack)
77
+ return;
78
+ _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.track(event, __assign(__assign({}, coreData), analyticsData));
79
+ };
80
+ var getInstances = function () { return ({ ab: _growthbook, tracking: _rudderstack }); };
81
+ return {
82
+ initialise: initialise,
83
+ setAttributes: setAttributes,
84
+ identifyEvent: identifyEvent,
85
+ getFeatureState: getFeatureState,
86
+ getFeatureValue: getFeatureValue,
87
+ isFeatureOn: isFeatureOn,
88
+ setUrl: setUrl,
89
+ getId: getId,
90
+ trackEvent: trackEvent,
91
+ getInstances: getInstances,
92
+ pageView: pageView,
93
+ reset: reset,
94
+ };
95
+ }
96
+ exports.createAnalyticsInstance = createAnalyticsInstance;
97
+ exports.Analytics = createAnalyticsInstance();
@@ -0,0 +1,34 @@
1
+ import { GrowthBook } from '@growthbook/growthbook';
2
+ import { TGrowthbookAttributes } from './types';
3
+ export declare class Growthbook {
4
+ GrowthBook: GrowthBook<GrowthBook<Record<string, any>>>;
5
+ private static _instance;
6
+ constructor(clientKey: string, decryptionKey: string);
7
+ static getGrowthBookInstance(clientKey: string, decryptionKey: string): Growthbook;
8
+ setAttributes({ id, country, user_language, device_language, device_type }: TGrowthbookAttributes): void;
9
+ getFeatureState<K, V>(id: K): import("@growthbook/growthbook").FeatureResult<boolean | ((attributes: import("@growthbook/growthbook").Attributes) => void) | ((options?: import("@growthbook/growthbook").LoadFeaturesOptions | undefined) => Promise<void>) | ((options?: import("@growthbook/growthbook").RefreshFeaturesOptions | undefined) => Promise<void>) | (() => [string, string]) | (() => {
10
+ apiHost: string;
11
+ streamingHost: string;
12
+ apiRequestHeaders?: Record<string, string> | undefined;
13
+ streamingHostRequestHeaders?: Record<string, string> | undefined;
14
+ }) | (() => string) | (() => boolean) | (() => string[] | undefined) | ((features: Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((experiments: import("@growthbook/growthbook").AutoExperiment[]) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((overrides: import("@growthbook/growthbook").Attributes) => void) | ((vars: Record<string, number>) => void) | ((map: Map<string, any>) => void) | ((url: string) => void) | (() => {
15
+ [x: string]: any;
16
+ }) | (() => Record<string, number>) | (() => Map<string, any>) | (() => string) | (() => Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) | (() => import("@growthbook/growthbook").AutoExperiment[]) | ((cb: import("@growthbook/growthbook").SubscriptionFunction) => () => void) | (() => Map<string, {
17
+ experiment: import("@growthbook/growthbook").Experiment<any>;
18
+ result: import("@growthbook/growthbook").Result<any>;
19
+ }>) | (() => void) | ((renderer: () => void) => void) | ((key: string, variation: number) => void) | (<T>(experiment: import("@growthbook/growthbook").Experiment<T>) => import("@growthbook/growthbook").Result<T>) | ((key: string) => import("@growthbook/growthbook").Result<import("@growthbook/growthbook").AutoExperimentVariation> | null) | (<K_1 extends string = string>(key: K_1) => boolean) | (<K_2 extends string = string>(key: K_2) => boolean) | (<V_1 extends any, K_3 extends string = string>(key: K_3, defaultValue: V_1) => import("@growthbook/growthbook").WidenPrimitives<V_1>) | (<V_2 extends any, K_4 extends string = string>(id: K_4) => import("@growthbook/growthbook").FeatureResult<V_2 | null>) | (<V_3 extends any, K_5 extends string = string>(id: K_5) => import("@growthbook/growthbook").FeatureResult<V_3 | null>) | ((msg: string, ctx: Record<string, unknown>) => void) | null>;
20
+ getFeatureValue<K, V>(key: K, defaultValue?: V): boolean | ((attributes: import("@growthbook/growthbook").Attributes) => void) | ((options?: import("@growthbook/growthbook").LoadFeaturesOptions | undefined) => Promise<void>) | ((options?: import("@growthbook/growthbook").RefreshFeaturesOptions | undefined) => Promise<void>) | (() => [string, string]) | (() => {
21
+ apiHost: string;
22
+ streamingHost: string;
23
+ apiRequestHeaders?: Record<string, string> | undefined;
24
+ streamingHostRequestHeaders?: Record<string, string> | undefined;
25
+ }) | (() => string) | (() => boolean) | (() => string[] | undefined) | ((features: Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((experiments: import("@growthbook/growthbook").AutoExperiment[]) => void) | ((encryptedString: string, decryptionKey?: string | undefined, subtle?: SubtleCrypto | undefined) => Promise<void>) | ((overrides: import("@growthbook/growthbook").Attributes) => void) | ((vars: Record<string, number>) => void) | ((map: Map<string, any>) => void) | ((url: string) => void) | (() => {
26
+ [x: string]: any;
27
+ }) | (() => Record<string, number>) | (() => Map<string, any>) | (() => string) | (() => Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>) | (() => import("@growthbook/growthbook").AutoExperiment[]) | ((cb: import("@growthbook/growthbook").SubscriptionFunction) => () => void) | (() => Map<string, {
28
+ experiment: import("@growthbook/growthbook").Experiment<any>;
29
+ result: import("@growthbook/growthbook").Result<any>;
30
+ }>) | (() => void) | ((renderer: () => void) => void) | ((key: string, variation: number) => void) | (<T>(experiment: import("@growthbook/growthbook").Experiment<T>) => import("@growthbook/growthbook").Result<T>) | ((key: string) => import("@growthbook/growthbook").Result<import("@growthbook/growthbook").AutoExperimentVariation> | null) | (<K_1 extends string = string>(key: K_1) => boolean) | (<K_2 extends string = string>(key: K_2) => boolean) | (<V_1 extends any, K_3 extends string = string>(key: K_3, defaultValue: V_1) => import("@growthbook/growthbook").WidenPrimitives<V_1>) | (<V_2 extends any, K_4 extends string = string>(id: K_4) => import("@growthbook/growthbook").FeatureResult<V_2 | null>) | (<V_3 extends any, K_5 extends string = string>(id: K_5) => import("@growthbook/growthbook").FeatureResult<V_3 | null>) | ((msg: string, ctx: Record<string, unknown>) => void);
31
+ setUrl(href: string): void;
32
+ isOn(key: string): boolean;
33
+ init(): void;
34
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.Growthbook = void 0;
38
+ var growthbook_1 = require("@growthbook/growthbook");
39
+ var RudderAnalytics = __importStar(require("rudder-sdk-js"));
40
+ var Growthbook = /** @class */ (function () {
41
+ // we have to pass settings due the specific framework implementation
42
+ function Growthbook(clientKey, decryptionKey) {
43
+ this.GrowthBook = new growthbook_1.GrowthBook({
44
+ apiHost: 'https://cdn.growthbook.io',
45
+ clientKey: clientKey,
46
+ decryptionKey: decryptionKey,
47
+ subscribeToChanges: true,
48
+ enableDevMode: window === null || window === void 0 ? void 0 : window.location.hostname.includes('localhost'),
49
+ trackingCallback: function (experiment, result) {
50
+ if (window.dataLayer) {
51
+ window.dataLayer.push({
52
+ event: 'experiment_viewed',
53
+ event_category: 'experiment',
54
+ rudder_anonymous_id: RudderAnalytics.getAnonymousId(),
55
+ experiment_id: experiment.key,
56
+ variation_id: result.variationId,
57
+ });
58
+ }
59
+ RudderAnalytics.track('experiment_viewed', {
60
+ experimentId: experiment.key,
61
+ variationId: result.variationId,
62
+ });
63
+ },
64
+ });
65
+ this.init();
66
+ }
67
+ // for make instance by singleton
68
+ Growthbook.getGrowthBookInstance = function (clientKey, decryptionKey) {
69
+ if (!Growthbook._instance) {
70
+ Growthbook._instance = new Growthbook(clientKey, decryptionKey);
71
+ return Growthbook._instance;
72
+ }
73
+ return Growthbook._instance;
74
+ };
75
+ Growthbook.prototype.setAttributes = function (_a) {
76
+ var id = _a.id, country = _a.country, user_language = _a.user_language, device_language = _a.device_language, device_type = _a.device_type;
77
+ return this.GrowthBook.setAttributes(__assign(__assign(__assign(__assign({ id: id }, (country !== undefined && { country: country })), (user_language !== undefined && { user_language: user_language })), (device_language !== undefined && { device_language: device_language })), (device_type !== undefined && { device_type: device_type })));
78
+ };
79
+ Growthbook.prototype.getFeatureState = function (id) {
80
+ // @ts-ignore
81
+ return this.GrowthBook.evalFeature(id);
82
+ };
83
+ Growthbook.prototype.getFeatureValue = function (key, defaultValue) {
84
+ // @ts-ignore
85
+ return this.GrowthBook.getFeatureValue(key, defaultValue);
86
+ };
87
+ Growthbook.prototype.setUrl = function (href) {
88
+ return this.GrowthBook.setURL(href);
89
+ };
90
+ Growthbook.prototype.isOn = function (key) {
91
+ // @ts-ignore
92
+ return this.GrowthBook.isOn(key);
93
+ };
94
+ Growthbook.prototype.init = function () {
95
+ this.GrowthBook.loadFeatures().catch(function (err) { return console.error(err); });
96
+ };
97
+ return Growthbook;
98
+ }());
99
+ exports.Growthbook = Growthbook;
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Analytics } from './analytics';
2
+ export { TEvents } from './types';
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Analytics = void 0;
4
+ var analytics_1 = require("./analytics");
5
+ Object.defineProperty(exports, "Analytics", { enumerable: true, get: function () { return analytics_1.Analytics; } });
@@ -0,0 +1,49 @@
1
+ import { TEvents } from './types';
2
+ export declare class RudderStack {
3
+ has_identified: boolean;
4
+ has_initialized: boolean;
5
+ current_page: string;
6
+ private static _instance;
7
+ constructor(RUDDERSTACK_KEY: string);
8
+ static getRudderStackInstance(RUDDERSTACK_KEY: string): RudderStack;
9
+ /**
10
+ * @returns The anonymous ID assigned to the user before the identify event was called
11
+ */
12
+ getAnonymousId(): string;
13
+ /**
14
+ * @returns The user ID that was assigned to the user after calling identify event
15
+ */
16
+ getUserId(): string;
17
+ /**
18
+ * Initializes the Rudderstack SDK. Ensure that the appropriate environment variables are set before this is called.
19
+ * For local/staging environment, ensure that `RUDDERSTACK_STAGING_KEY` and `RUDDERSTACK_URL` is set.
20
+ * For production environment, ensure that `RUDDERSTACK_PRODUCTION_KEY` and `RUDDERSTACK_URL` is set.
21
+ */
22
+ init(RUDDERSTACK_KEY: string): void;
23
+ /**
24
+ *
25
+ * @param user_id The user ID of the user to identify and associate all events with that particular user ID
26
+ * @param payload Additional information passed to identify the user
27
+ */
28
+ identifyEvent: (user_id: string, payload: {
29
+ language: string;
30
+ }) => void;
31
+ /**
32
+ * Pushes page view event to Rudderstack
33
+ *
34
+ * @param curret_page The name or URL of the current page to track the page view event
35
+ */
36
+ pageView(current_page: string, platform: string | undefined, user_id: string): void;
37
+ /**
38
+ * Pushes reset event to rudderstack
39
+ */
40
+ reset(): void;
41
+ /**
42
+ * Pushes track events to Rudderstack. When this method is called before `identifyEvent` method is called, the events tracked will be associated with an anonymous ID.
43
+ * Otherwise, if the events needs to be associated with a user ID, call `identifyEvent` with the user ID passed first before calling this method.
44
+ *
45
+ * @param event The event name to track
46
+ * @param payload Additional information related to the event
47
+ */
48
+ track<T extends keyof TEvents>(event: T, payload: TEvents[T]): void;
49
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.RudderStack = void 0;
27
+ var RudderAnalytics = __importStar(require("rudder-sdk-js"));
28
+ var RudderStack = /** @class */ (function () {
29
+ function RudderStack(RUDDERSTACK_KEY) {
30
+ var _this = this;
31
+ this.has_identified = false;
32
+ this.has_initialized = false;
33
+ this.current_page = '';
34
+ /**
35
+ *
36
+ * @param user_id The user ID of the user to identify and associate all events with that particular user ID
37
+ * @param payload Additional information passed to identify the user
38
+ */
39
+ this.identifyEvent = function (user_id, payload) {
40
+ RudderAnalytics.identify(user_id, payload);
41
+ _this.has_identified = true;
42
+ };
43
+ this.init(RUDDERSTACK_KEY);
44
+ }
45
+ RudderStack.getRudderStackInstance = function (RUDDERSTACK_KEY) {
46
+ if (!RudderStack._instance) {
47
+ RudderStack._instance = new RudderStack(RUDDERSTACK_KEY);
48
+ return RudderStack._instance;
49
+ }
50
+ return RudderStack._instance;
51
+ };
52
+ /**
53
+ * @returns The anonymous ID assigned to the user before the identify event was called
54
+ */
55
+ RudderStack.prototype.getAnonymousId = function () {
56
+ return RudderAnalytics.getAnonymousId();
57
+ };
58
+ /**
59
+ * @returns The user ID that was assigned to the user after calling identify event
60
+ */
61
+ RudderStack.prototype.getUserId = function () {
62
+ return RudderAnalytics.getUserId();
63
+ };
64
+ /**
65
+ * Initializes the Rudderstack SDK. Ensure that the appropriate environment variables are set before this is called.
66
+ * For local/staging environment, ensure that `RUDDERSTACK_STAGING_KEY` and `RUDDERSTACK_URL` is set.
67
+ * For production environment, ensure that `RUDDERSTACK_PRODUCTION_KEY` and `RUDDERSTACK_URL` is set.
68
+ */
69
+ RudderStack.prototype.init = function (RUDDERSTACK_KEY) {
70
+ var _this = this;
71
+ if (RUDDERSTACK_KEY) {
72
+ RudderAnalytics.load(RUDDERSTACK_KEY, 'https://deriv-dataplane.rudderstack.com');
73
+ RudderAnalytics.ready(function () {
74
+ _this.has_initialized = true;
75
+ _this.has_identified = !!(_this.getUserId() || !!_this.getAnonymousId());
76
+ });
77
+ }
78
+ };
79
+ /**
80
+ * Pushes page view event to Rudderstack
81
+ *
82
+ * @param curret_page The name or URL of the current page to track the page view event
83
+ */
84
+ RudderStack.prototype.pageView = function (current_page, platform, user_id) {
85
+ if (platform === void 0) { platform = 'Deriv App'; }
86
+ if (this.has_initialized && this.has_identified && current_page !== this.current_page) {
87
+ RudderAnalytics.page(platform, current_page, { user_id: user_id });
88
+ this.current_page = current_page;
89
+ }
90
+ };
91
+ /**
92
+ * Pushes reset event to rudderstack
93
+ */
94
+ RudderStack.prototype.reset = function () {
95
+ if (this.has_initialized) {
96
+ RudderAnalytics.reset();
97
+ this.has_identified = false;
98
+ }
99
+ };
100
+ /**
101
+ * Pushes track events to Rudderstack. When this method is called before `identifyEvent` method is called, the events tracked will be associated with an anonymous ID.
102
+ * Otherwise, if the events needs to be associated with a user ID, call `identifyEvent` with the user ID passed first before calling this method.
103
+ *
104
+ * @param event The event name to track
105
+ * @param payload Additional information related to the event
106
+ */
107
+ RudderStack.prototype.track = function (event, payload) {
108
+ if (this.has_initialized && this.has_identified) {
109
+ try {
110
+ RudderAnalytics.track(event, payload);
111
+ }
112
+ catch (err) {
113
+ console.error(err);
114
+ }
115
+ }
116
+ };
117
+ return RudderStack;
118
+ }());
119
+ exports.RudderStack = RudderStack;
package/lib/types.d.ts ADDED
@@ -0,0 +1,219 @@
1
+ export type TGrowthbookAttributes = {
2
+ id: string;
3
+ country?: string;
4
+ user_language?: string;
5
+ device_language?: string;
6
+ device_type?: string;
7
+ };
8
+ export type TCoreAttributes = {
9
+ account_type?: string;
10
+ user_id?: string;
11
+ app_id?: string;
12
+ user_identity?: string;
13
+ } & Partial<TGrowthbookAttributes>;
14
+ type SignupProvider = 'email' | 'phone' | 'google' | 'facebook' | 'apple';
15
+ type VirtualSignupForm = {
16
+ action?: 'open' | 'started' | 'email_confirmation_sent' | 'email_confirmed' | 'signup_continued' | 'country_selection_screen_opened' | 'password_screen_opened' | 'signup_done' | 'signup_flow_error' | 'go_to_login';
17
+ signup_provider?: SignupProvider;
18
+ form_source?: string;
19
+ form_name?: string;
20
+ error_message?: string;
21
+ email?: string;
22
+ app_id?: string;
23
+ };
24
+ type EmailVerificationForm = {
25
+ action?: 'verify_popup_opened' | 'verify_popup_closed' | 'verify_popup_cta' | 'email_verification_sent' | 'email_verification_opened' | 'success_popup_opened' | 'success_popup_closed' | 'success_popup_cta';
26
+ form_source?: 'ce_tradershub_real_form' | 'ce_virtual_signup_form' | 'account_setting';
27
+ form_name?: string;
28
+ app_id?: string;
29
+ };
30
+ type RealAccountSignupForm = {
31
+ action?: 'open' | 'step_passed' | 'save' | 'restore' | 'close' | 'real_signup_error' | 'other_error' | 'real_signup_finished';
32
+ step_codename?: string;
33
+ step_num?: number;
34
+ user_choice?: string;
35
+ form_source?: string;
36
+ form_name?: string;
37
+ real_signup_error_message?: string;
38
+ landing_company?: string;
39
+ };
40
+ type RealAccountSignupIdentifyForm = {
41
+ action?: 'open' | 'step_passed' | 'step_back' | 'save' | 'close' | 'real_signup_error' | 'other_error' | 'real_signup_finished';
42
+ step_codename?: string;
43
+ step_num?: string;
44
+ user_choice?: string;
45
+ form_source?: string;
46
+ form_name?: string;
47
+ real_signup_error_message?: string;
48
+ landing_company?: string;
49
+ };
50
+ type LoginForm = {
51
+ action: 'open' | 'login_cta' | 'go_to_forgot' | 'email_reset_password_sent' | 'email_reset_password_opened' | 'reset_password_continued' | 'reset_password_done' | 'login_flow_error' | 'go_to_signup';
52
+ login_provider?: 'email' | 'phone' | 'google' | 'facebook' | 'apple';
53
+ form_source?: 'virtual_signup_form' | 'deriv.com (log in CTA)' | 'mobile_derivGo' | string;
54
+ error_message?: string;
55
+ email?: string;
56
+ };
57
+ type QuestionnaireForm = {
58
+ action: 'open' | 'choose_answer' | 'close';
59
+ question_code?: string;
60
+ question_content?: string;
61
+ answer_code?: string;
62
+ };
63
+ type PartnerAccountSignupForm = {
64
+ action: 'open' | 'open_wizard' | 'step_passed' | 'step_back' | 'push_learn_more' | 'close_wizard' | 'close' | 'partners_signup_error' | 'other_error' | 'try_submit' | 'failed_popup_cta' | 'success_popup_opened' | 'success_popup_cta';
65
+ step_codename?: string;
66
+ step_num?: number;
67
+ user_choice?: string;
68
+ form_source?: string;
69
+ form_name?: 'ce_partner_account_signup_form';
70
+ partner_signup_error_message?: string;
71
+ };
72
+ type VirtualSignupEmailConfirmation = {
73
+ action?: 'received' | 'expired' | 'confirmed' | 'error';
74
+ signup_provider?: SignupProvider;
75
+ form_source?: string;
76
+ email_md5?: string;
77
+ error_message?: string;
78
+ };
79
+ type TradeTypesForm = {
80
+ action?: 'open' | 'close' | 'choose_trade_type' | 'search' | 'info_open' | 'info_switcher' | 'info_close';
81
+ trade_type_name?: string;
82
+ tab_name?: string;
83
+ search_string?: string;
84
+ info_switcher_mode?: 'description' | 'glossary';
85
+ form_source?: string;
86
+ form_name?: string;
87
+ subform_name?: string;
88
+ };
89
+ type BotDashboardForm = {
90
+ action?: 'open' | 'close' | 'search' | 'delete' | 'yes' | 'no' | 'search_string' | 'choose_shortcut' | 'bot_last_modified_time' | 'delete_popup_respond' | 'push_open_button' | 'push_user_guide' | 'save_your_bot' | 'choose_your_bot' | 'delete_your_bot';
91
+ shortcut_name?: string;
92
+ form_source?: string;
93
+ search_string?: string;
94
+ delete_popup_respond?: string;
95
+ bot_last_modified_time?: number;
96
+ bot_name?: string;
97
+ };
98
+ type BotQuickStrategyForm = {
99
+ action?: 'open' | 'close' | 'choose_strategy' | 'switch_strategy_mode' | 'choose_asset' | 'choose_trade_type' | 'choose_trade_type_mode' | 'choose_duration' | 'change_parameter_value' | 'info_popup_open' | 'run_strategy';
100
+ form_source?: 'bot_dashboard' | 'bot_builder_form';
101
+ strategy_type?: "d'alembert" | 'martingale' | "oscar's-grind";
102
+ strategy_switcher_mode?: 'trade-parameters' | 'description';
103
+ asset_type?: 'gbp-basket' | 'eur-basket' | 'etc';
104
+ trade_type?: 'rise/fall' | 'rise-equals/fall-equals' | 'etc';
105
+ trade_type_mode?: 'rise' | 'fall' | 'rise-equals' | 'fall-equals' | 'etc';
106
+ duration_type?: 'ticks' | 'seconds' | 'minutes' | 'hours' | 'days';
107
+ parameter_type?: 'initial-stake' | 'duration' | 'profit-threshold' | 'loss-threshold' | 'size-unit' | 'max-stake';
108
+ parameter_value?: string;
109
+ plus_push_amount?: string;
110
+ minus_push_amount?: string;
111
+ manual_parameter_input?: 'yes' | 'no';
112
+ };
113
+ type BotBuilderForm = {
114
+ action?: 'open' | 'close' | 'search';
115
+ form_source?: 'bot_header_form' | 'bot_dashboard_form';
116
+ search_string?: string;
117
+ };
118
+ type BotTutorialForm = {
119
+ action?: 'open' | 'close' | 'search';
120
+ form_source?: 'bot_header_form' | 'bot_dashboard_form-shortcut' | 'bot_dashboard_form-edit' | 'bot_dashboard_form-open';
121
+ search_string?: string;
122
+ };
123
+ type IndicatorsTypesFormAction = {
124
+ action: 'open' | 'close' | 'add_active' | 'clean_all_active' | 'delete_active' | 'edit_active' | 'search' | 'info_open' | 'info_close';
125
+ form_name?: string;
126
+ indicator_type_name?: string;
127
+ indicators_category_name?: string;
128
+ search_string?: string;
129
+ subform_name?: string;
130
+ };
131
+ type MarketTypesFormAction = {
132
+ action: 'open' | 'close' | 'choose_market_type' | 'search' | 'info_redirect' | 'add_to_favorites' | 'delete_from_favorites';
133
+ form_name?: string;
134
+ market_type_name?: string;
135
+ search_string?: string;
136
+ tab_market_name?: string;
137
+ };
138
+ type ReportsFormAction = {
139
+ action: 'choose_report_type';
140
+ form_name: string;
141
+ subform_name: 'open_positions_form' | 'statement_form' | 'trade_table_form';
142
+ trade_type_filter?: string;
143
+ growth_type_filter?: string;
144
+ start_date_filter?: string;
145
+ end_date_filter?: string;
146
+ transaction_type_filter?: string;
147
+ } | {
148
+ action: 'filter_trade_type';
149
+ form_name: string;
150
+ subform_name: 'open_positions_form';
151
+ trade_type_filter: string;
152
+ } | {
153
+ action: 'filter_growth_rate';
154
+ form_name: string;
155
+ subform_name: 'open_positions_form';
156
+ growth_type_filter: string;
157
+ } | {
158
+ action: 'filter_dates';
159
+ form_name: string;
160
+ subform_name: 'trade_table_form' | 'statement_form';
161
+ start_date_filter?: string;
162
+ end_date_filter?: string;
163
+ } | {
164
+ action: 'filter_transaction_type';
165
+ form_name: string;
166
+ subform_name: 'statement_form';
167
+ transaction_type_filter: string;
168
+ } | {
169
+ action: 'open';
170
+ form_name: string;
171
+ subform_name: string;
172
+ form_source: string;
173
+ } | {
174
+ action: 'close';
175
+ form_name: string;
176
+ subform_name: string;
177
+ } | {
178
+ action: 'open_contract_details';
179
+ form_name: string;
180
+ form_source: string;
181
+ };
182
+ type ChartTypesFormAction = {
183
+ action?: 'open' | 'close' | 'choose_chart_type' | 'choose_time_interval';
184
+ form_name?: string;
185
+ chart_type_name?: string;
186
+ time_interval_name?: string;
187
+ };
188
+ type TradersHubOnboardingFormAction = {
189
+ action?: 'open' | 'close' | 'step_passed' | 'step_back' | 'choose_step_navigation';
190
+ form_source?: 'tradershub_dashboard_form' | 'tradershub_first_entrance' | 'repeat_tour';
191
+ step_num?: number;
192
+ step_codename?: string;
193
+ };
194
+ type UpgradeMT5BannerAction = {
195
+ action: 'open' | 'push_cta_upgrade';
196
+ };
197
+ export type TEvents = {
198
+ ce_virtual_signup_form: VirtualSignupForm;
199
+ ce_email_verification_form: EmailVerificationForm;
200
+ ce_real_account_signup_form: RealAccountSignupForm;
201
+ ce_real_account_signup_setup_form: RealAccountSignupForm;
202
+ ce_real_account_signup_identity_form: RealAccountSignupIdentifyForm;
203
+ ce_login_form: LoginForm;
204
+ ce_questionnaire_form: QuestionnaireForm;
205
+ ce_partner_account_signup_form: PartnerAccountSignupForm;
206
+ ce_virtual_signup_email_confirmation: VirtualSignupEmailConfirmation;
207
+ ce_bot_dashboard_form: BotDashboardForm;
208
+ ce_bot_quick_strategy_form: BotQuickStrategyForm;
209
+ ce_bot_builder_form: BotBuilderForm;
210
+ ce_bot_tutorial_form: BotTutorialForm;
211
+ ce_indicators_types_form: IndicatorsTypesFormAction;
212
+ ce_trade_types_form: TradeTypesForm;
213
+ ce_chart_types_form: ChartTypesFormAction;
214
+ ce_market_types_form: MarketTypesFormAction;
215
+ ce_reports_form: ReportsFormAction;
216
+ ce_tradershub_onboarding_form: TradersHubOnboardingFormAction;
217
+ ce_upgrade_mt5_banner: UpgradeMT5BannerAction;
218
+ };
219
+ export {};
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@deriv-com/analytics",
3
+ "version": "1.4.10",
4
+ "description": "The analytics package contains all the utility functions used for tracking user events and sending them to the respective platform such as Rudderstack.",
5
+ "keywords": [
6
+ "rudderstack",
7
+ "growthbook",
8
+ "react"
9
+ ],
10
+ "author": "Amir Ali, Addriene, Nikita",
11
+ "main": "lib/index.js",
12
+ "types": "lib/index.d.ts",
13
+ "scripts": {
14
+ "test": "./node_modules/.bin/jest",
15
+ "build": "tsc",
16
+ "prepare": "npm run build && husky install",
17
+ "prepublishOnly": "npm test"
18
+ },
19
+ "files": [
20
+ "lib/**/*"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/binary-com/deriv-analytics"
25
+ },
26
+ "homepage": "https://github.com/binary-com/deriv-analytics",
27
+ "devDependencies": {
28
+ "@types/jest": "^29.5.3",
29
+ "@types/node": "^20.4.1",
30
+ "husky": "^8.0.3",
31
+ "jest": "^29.6.1",
32
+ "jest-environment-jsdom": "^29.6.1",
33
+ "lint-staged": "^15.0.1",
34
+ "prettier": "^3.0.3",
35
+ "ts-jest": "^29.1.1",
36
+ "typescript": "^4.9.5"
37
+ },
38
+ "dependencies": {
39
+ "@growthbook/growthbook": "^0.29.0",
40
+ "rudder-sdk-js": "^2.35.0"
41
+ },
42
+ "engines": {
43
+ "node": "18.x",
44
+ "npm": "9.x"
45
+ },
46
+ "license": "MIT",
47
+ "lint-staged": {
48
+ "*.{js,md,ts}": "prettier --write"
49
+ }
50
+ }