@deriv-com/analytics 1.4.10 → 1.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
 - package/lib/analytics.d.ts +4 -4
 - package/lib/analytics.js +33 -13
 - package/lib/growthbook.d.ts +1 -1
 - package/lib/growthbook.js +2 -2
 - package/lib/types.d.ts +39 -12
 - package/package.json +1 -1
 
    
        package/README.md
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # `@deriv/analytics`
         
     | 
| 
      
 1 
     | 
    
         
            +
            # `@deriv-com/analytics`
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
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 
4 
     | 
    
         | 
| 
         @@ -18,7 +18,7 @@ Cross-project, connected user tracking events with A/B testing features 
     | 
|
| 
       18 
18 
     | 
    
         
             
            To install the package, run the following command:
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
            ```
         
     | 
| 
       21 
     | 
    
         
            -
            $ npm i @deriv/analytics
         
     | 
| 
      
 21 
     | 
    
         
            +
            $ npm i @deriv-com/analytics
         
     | 
| 
       22 
22 
     | 
    
         
             
            ```
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
            To proper initialisation of the package, pass proper keys in special function in special for init functions place:
         
     | 
| 
         @@ -49,7 +49,7 @@ And you finally can use the tracking events and A/B testing features 
     | 
|
| 
       49 
49 
     | 
    
         
             
            To start using it, let's observe on SDK usage examples:
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
            ```js
         
     | 
| 
       52 
     | 
    
         
            -
            import { Analytics } from '@deriv/analytics';
         
     | 
| 
      
 52 
     | 
    
         
            +
            import { Analytics } from '@deriv-com/analytics';
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
            // Tracking features:
         
     | 
| 
       55 
55 
     | 
    
         
             
            Analytics?.identifyEvent() // inentify the user
         
     | 
| 
         @@ -66,18 +66,18 @@ Analytics?.trackEvent('ce_virtual_signup_form', { 
     | 
|
| 
       66 
66 
     | 
    
         
             
            })
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
            // the same as example below, to not to add repetable properties again and again
         
     | 
| 
       69 
     | 
    
         
            -
            const  
     | 
| 
      
 69 
     | 
    
         
            +
            const analytics_data: Parameters<typeof Analytics.trackEvent>[1] = {
         
     | 
| 
       70 
70 
     | 
    
         
             
                form_name: 'default_diel_deriv',
         
     | 
| 
       71 
71 
     | 
    
         
             
            }
         
     | 
| 
       72 
72 
     | 
    
         
             
            Analytics?.trackEvent('ce_virtual_signup_form', {
         
     | 
| 
       73 
73 
     | 
    
         
             
                action: 'open',
         
     | 
| 
       74 
74 
     | 
    
         
             
                signup_provider: 'email',
         
     | 
| 
       75 
     | 
    
         
            -
                ... 
     | 
| 
      
 75 
     | 
    
         
            +
                ...analytics_data
         
     | 
| 
       76 
76 
     | 
    
         
             
            })
         
     | 
| 
       77 
77 
     | 
    
         
             
            Analytics?.trackEvent('ce_virtual_signup_form', {
         
     | 
| 
       78 
78 
     | 
    
         
             
                action: 'close',
         
     | 
| 
       79 
79 
     | 
    
         
             
                signup_provider: 'google',
         
     | 
| 
       80 
     | 
    
         
            -
                ... 
     | 
| 
      
 80 
     | 
    
         
            +
                ...analytics_data
         
     | 
| 
       81 
81 
     | 
    
         
             
            })
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
83 
     | 
    
         
             
            // A/B testing features
         
     | 
    
        package/lib/analytics.d.ts
    CHANGED
    
    | 
         @@ -8,7 +8,7 @@ type Options = { 
     | 
|
| 
       8 
8 
     | 
    
         
             
            };
         
     | 
| 
       9 
9 
     | 
    
         
             
            export declare function createAnalyticsInstance(options?: Options): {
         
     | 
| 
       10 
10 
     | 
    
         
             
                initialise: ({ growthbookKey, growthbookDecryptionKey, rudderstackKey }: Options) => void;
         
     | 
| 
       11 
     | 
    
         
            -
                setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, app_id, }: TCoreAttributes) => void;
         
     | 
| 
      
 11 
     | 
    
         
            +
                setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, app_id, utm_source, utm_medium, utm_campaign, is_authorised, }: TCoreAttributes) => void;
         
     | 
| 
       12 
12 
     | 
    
         
             
                identifyEvent: () => void;
         
     | 
| 
       13 
13 
     | 
    
         
             
                getFeatureState: (id: string) => string | undefined;
         
     | 
| 
       14 
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]) | (() => {
         
     | 
| 
         @@ -25,7 +25,7 @@ export declare function createAnalyticsInstance(options?: Options): { 
     | 
|
| 
       25 
25 
     | 
    
         
             
                isFeatureOn: (key: string) => boolean;
         
     | 
| 
       26 
26 
     | 
    
         
             
                setUrl: (href: string) => void;
         
     | 
| 
       27 
27 
     | 
    
         
             
                getId: () => string;
         
     | 
| 
       28 
     | 
    
         
            -
                trackEvent: <T_2 extends keyof TEvents>(event: T_2,  
     | 
| 
      
 28 
     | 
    
         
            +
                trackEvent: <T_2 extends keyof TEvents>(event: T_2, analytics_data: TEvents[T_2]) => void;
         
     | 
| 
       29 
29 
     | 
    
         
             
                getInstances: () => {
         
     | 
| 
       30 
30 
     | 
    
         
             
                    ab: Growthbook;
         
     | 
| 
       31 
31 
     | 
    
         
             
                    tracking: RudderStack;
         
     | 
| 
         @@ -35,7 +35,7 @@ export declare function createAnalyticsInstance(options?: Options): { 
     | 
|
| 
       35 
35 
     | 
    
         
             
            };
         
     | 
| 
       36 
36 
     | 
    
         
             
            export declare const Analytics: {
         
     | 
| 
       37 
37 
     | 
    
         
             
                initialise: ({ growthbookKey, growthbookDecryptionKey, rudderstackKey }: Options) => void;
         
     | 
| 
       38 
     | 
    
         
            -
                setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, app_id, }: TCoreAttributes) => void;
         
     | 
| 
      
 38 
     | 
    
         
            +
                setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, app_id, utm_source, utm_medium, utm_campaign, is_authorised, }: TCoreAttributes) => void;
         
     | 
| 
       39 
39 
     | 
    
         
             
                identifyEvent: () => void;
         
     | 
| 
       40 
40 
     | 
    
         
             
                getFeatureState: (id: string) => string | undefined;
         
     | 
| 
       41 
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]) | (() => {
         
     | 
| 
         @@ -52,7 +52,7 @@ export declare const Analytics: { 
     | 
|
| 
       52 
52 
     | 
    
         
             
                isFeatureOn: (key: string) => boolean;
         
     | 
| 
       53 
53 
     | 
    
         
             
                setUrl: (href: string) => void;
         
     | 
| 
       54 
54 
     | 
    
         
             
                getId: () => string;
         
     | 
| 
       55 
     | 
    
         
            -
                trackEvent: <T_2 extends keyof TEvents>(event: T_2,  
     | 
| 
      
 55 
     | 
    
         
            +
                trackEvent: <T_2 extends keyof TEvents>(event: T_2, analytics_data: TEvents[T_2]) => void;
         
     | 
| 
       56 
56 
     | 
    
         
             
                getInstances: () => {
         
     | 
| 
       57 
57 
     | 
    
         
             
                    ab: Growthbook;
         
     | 
| 
       58 
58 
     | 
    
         
             
                    tracking: RudderStack;
         
     | 
    
        package/lib/analytics.js
    CHANGED
    
    | 
         @@ -15,7 +15,13 @@ exports.Analytics = exports.createAnalyticsInstance = void 0; 
     | 
|
| 
       15 
15 
     | 
    
         
             
            var growthbook_1 = require("./growthbook");
         
     | 
| 
       16 
16 
     | 
    
         
             
            var rudderstack_1 = require("./rudderstack");
         
     | 
| 
       17 
17 
     | 
    
         
             
            function createAnalyticsInstance(options) {
         
     | 
| 
       18 
     | 
    
         
            -
                var _growthbook, _rudderstack;
         
     | 
| 
      
 18 
     | 
    
         
            +
                var _growthbook, _rudderstack, core_data = {}, cta_buttons = {}, offline_cache = {};
         
     | 
| 
      
 19 
     | 
    
         
            +
                var interval = setInterval(function () {
         
     | 
| 
      
 20 
     | 
    
         
            +
                    if (Object.keys(cta_buttons).length > 0)
         
     | 
| 
      
 21 
     | 
    
         
            +
                        clearInterval(interval);
         
     | 
| 
      
 22 
     | 
    
         
            +
                    else
         
     | 
| 
      
 23 
     | 
    
         
            +
                        cta_buttons = getFeatureValue('tracking-buttons-config', {});
         
     | 
| 
      
 24 
     | 
    
         
            +
                }, 1000);
         
     | 
| 
       19 
25 
     | 
    
         
             
                var initialise = function (_a) {
         
     | 
| 
       20 
26 
     | 
    
         
             
                    var growthbookKey = _a.growthbookKey, growthbookDecryptionKey = _a.growthbookDecryptionKey, rudderstackKey = _a.rudderstackKey;
         
     | 
| 
       21 
27 
     | 
    
         
             
                    _rudderstack = rudderstack_1.RudderStack.getRudderStackInstance(rudderstackKey);
         
     | 
| 
         @@ -23,12 +29,8 @@ function createAnalyticsInstance(options) { 
     | 
|
| 
       23 
29 
     | 
    
         
             
                        _growthbook = growthbook_1.Growthbook.getGrowthBookInstance(growthbookKey, growthbookDecryptionKey);
         
     | 
| 
       24 
30 
     | 
    
         
             
                    }
         
     | 
| 
       25 
31 
     | 
    
         
             
                };
         
     | 
| 
       26 
     | 
    
         
            -
                if (options) {
         
     | 
| 
       27 
     | 
    
         
            -
                    initialise(options);
         
     | 
| 
       28 
     | 
    
         
            -
                }
         
     | 
| 
       29 
     | 
    
         
            -
                var coreData = {};
         
     | 
| 
       30 
32 
     | 
    
         
             
                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;
         
     | 
| 
      
 33 
     | 
    
         
            +
                    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, utm_source = _a.utm_source, utm_medium = _a.utm_medium, utm_campaign = _a.utm_campaign, is_authorised = _a.is_authorised;
         
     | 
| 
       32 
34 
     | 
    
         
             
                    if (!_growthbook && !_rudderstack)
         
     | 
| 
       33 
35 
     | 
    
         
             
                        return;
         
     | 
| 
       34 
36 
     | 
    
         
             
                    var user_identity = user_id ? user_id : getId();
         
     | 
| 
         @@ -40,17 +42,19 @@ function createAnalyticsInstance(options) { 
     | 
|
| 
       40 
42 
     | 
    
         
             
                            user_language: user_language,
         
     | 
| 
       41 
43 
     | 
    
         
             
                            device_language: device_language,
         
     | 
| 
       42 
44 
     | 
    
         
             
                            device_type: device_type,
         
     | 
| 
      
 45 
     | 
    
         
            +
                            utm_source: utm_source,
         
     | 
| 
      
 46 
     | 
    
         
            +
                            utm_medium: utm_medium,
         
     | 
| 
      
 47 
     | 
    
         
            +
                            utm_campaign: utm_campaign,
         
     | 
| 
      
 48 
     | 
    
         
            +
                            is_authorised: is_authorised,
         
     | 
| 
       43 
49 
     | 
    
         
             
                        });
         
     | 
| 
       44 
50 
     | 
    
         
             
                    }
         
     | 
| 
       45 
     | 
    
         
            -
                     
     | 
| 
      
 51 
     | 
    
         
            +
                    core_data = __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 
52 
     | 
    
         
             
                };
         
     | 
| 
       47 
53 
     | 
    
         
             
                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 
54 
     | 
    
         
             
                var getFeatureValue = function (id, defaultValue) { return _growthbook === null || _growthbook === void 0 ? void 0 : _growthbook.getFeatureValue(id, defaultValue); };
         
     | 
| 
       49 
55 
     | 
    
         
             
                var isFeatureOn = function (key) { return _growthbook === null || _growthbook === void 0 ? void 0 : _growthbook.isOn(key); };
         
     | 
| 
       50 
56 
     | 
    
         
             
                var setUrl = function (href) { return _growthbook === null || _growthbook === void 0 ? void 0 : _growthbook.setUrl(href); };
         
     | 
| 
       51 
57 
     | 
    
         
             
                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 
58 
     | 
    
         
             
                /**
         
     | 
| 
       55 
59 
     | 
    
         
             
                 * Pushes page view event to Rudderstack
         
     | 
| 
       56 
60 
     | 
    
         
             
                 *
         
     | 
| 
         @@ -63,8 +67,8 @@ function createAnalyticsInstance(options) { 
     | 
|
| 
       63 
67 
     | 
    
         
             
                    _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.pageView(current_page, platform, getId());
         
     | 
| 
       64 
68 
     | 
    
         
             
                };
         
     | 
| 
       65 
69 
     | 
    
         
             
                var identifyEvent = function () {
         
     | 
| 
       66 
     | 
    
         
            -
                    if (( 
     | 
| 
       67 
     | 
    
         
            -
                        _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.identifyEvent( 
     | 
| 
      
 70 
     | 
    
         
            +
                    if ((core_data === null || core_data === void 0 ? void 0 : core_data.user_identity) && _rudderstack) {
         
     | 
| 
      
 71 
     | 
    
         
            +
                        _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.identifyEvent(core_data === null || core_data === void 0 ? void 0 : core_data.user_identity, { language: (core_data === null || core_data === void 0 ? void 0 : core_data.user_language) || 'en' });
         
     | 
| 
       68 
72 
     | 
    
         
             
                    }
         
     | 
| 
       69 
73 
     | 
    
         
             
                };
         
     | 
| 
       70 
74 
     | 
    
         
             
                var reset = function () {
         
     | 
| 
         @@ -72,10 +76,26 @@ function createAnalyticsInstance(options) { 
     | 
|
| 
       72 
76 
     | 
    
         
             
                        return;
         
     | 
| 
       73 
77 
     | 
    
         
             
                    _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.reset();
         
     | 
| 
       74 
78 
     | 
    
         
             
                };
         
     | 
| 
       75 
     | 
    
         
            -
                var trackEvent = function (event,  
     | 
| 
      
 79 
     | 
    
         
            +
                var trackEvent = function (event, analytics_data) {
         
     | 
| 
       76 
80 
     | 
    
         
             
                    if (!_rudderstack)
         
     | 
| 
       77 
81 
     | 
    
         
             
                        return;
         
     | 
| 
       78 
     | 
    
         
            -
                     
     | 
| 
      
 82 
     | 
    
         
            +
                    if (navigator.onLine) {
         
     | 
| 
      
 83 
     | 
    
         
            +
                        if (Object.keys(offline_cache).length > 0) {
         
     | 
| 
      
 84 
     | 
    
         
            +
                            Object.keys(offline_cache).map(function (cache) {
         
     | 
| 
      
 85 
     | 
    
         
            +
                                _rudderstack.track(offline_cache[cache].event, offline_cache[cache].payload);
         
     | 
| 
      
 86 
     | 
    
         
            +
                                delete offline_cache[cache];
         
     | 
| 
      
 87 
     | 
    
         
            +
                            });
         
     | 
| 
      
 88 
     | 
    
         
            +
                        }
         
     | 
| 
      
 89 
     | 
    
         
            +
                        if (event in cta_buttons) {
         
     | 
| 
      
 90 
     | 
    
         
            +
                            // @ts-ignore
         
     | 
| 
      
 91 
     | 
    
         
            +
                            cta_buttons[event] && (_rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.track(event, __assign(__assign({}, core_data), analytics_data)));
         
     | 
| 
      
 92 
     | 
    
         
            +
                        }
         
     | 
| 
      
 93 
     | 
    
         
            +
                        else
         
     | 
| 
      
 94 
     | 
    
         
            +
                            _rudderstack === null || _rudderstack === void 0 ? void 0 : _rudderstack.track(event, __assign(__assign({}, core_data), analytics_data));
         
     | 
| 
      
 95 
     | 
    
         
            +
                    }
         
     | 
| 
      
 96 
     | 
    
         
            +
                    else {
         
     | 
| 
      
 97 
     | 
    
         
            +
                        offline_cache[event + analytics_data.action] = { event: event, payload: __assign(__assign({}, core_data), analytics_data) };
         
     | 
| 
      
 98 
     | 
    
         
            +
                    }
         
     | 
| 
       79 
99 
     | 
    
         
             
                };
         
     | 
| 
       80 
100 
     | 
    
         
             
                var getInstances = function () { return ({ ab: _growthbook, tracking: _rudderstack }); };
         
     | 
| 
       81 
101 
     | 
    
         
             
                return {
         
     | 
    
        package/lib/growthbook.d.ts
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ export declare class Growthbook { 
     | 
|
| 
       5 
5 
     | 
    
         
             
                private static _instance;
         
     | 
| 
       6 
6 
     | 
    
         
             
                constructor(clientKey: string, decryptionKey: string);
         
     | 
| 
       7 
7 
     | 
    
         
             
                static getGrowthBookInstance(clientKey: string, decryptionKey: string): Growthbook;
         
     | 
| 
       8 
     | 
    
         
            -
                setAttributes({ id, country, user_language, device_language, device_type }: TGrowthbookAttributes): void;
         
     | 
| 
      
 8 
     | 
    
         
            +
                setAttributes({ id, country, user_language, device_language, device_type, utm_source, utm_medium, utm_campaign, is_authorised, }: TGrowthbookAttributes): void;
         
     | 
| 
       9 
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 
10 
     | 
    
         
             
                    apiHost: string;
         
     | 
| 
       11 
11 
     | 
    
         
             
                    streamingHost: string;
         
     | 
    
        package/lib/growthbook.js
    CHANGED
    
    | 
         @@ -73,8 +73,8 @@ var Growthbook = /** @class */ (function () { 
     | 
|
| 
       73 
73 
     | 
    
         
             
                    return Growthbook._instance;
         
     | 
| 
       74 
74 
     | 
    
         
             
                };
         
     | 
| 
       75 
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 })));
         
     | 
| 
      
 76 
     | 
    
         
            +
                    var id = _a.id, country = _a.country, user_language = _a.user_language, device_language = _a.device_language, device_type = _a.device_type, utm_source = _a.utm_source, utm_medium = _a.utm_medium, utm_campaign = _a.utm_campaign, is_authorised = _a.is_authorised;
         
     | 
| 
      
 77 
     | 
    
         
            +
                    return this.GrowthBook.setAttributes(__assign(__assign(__assign(__assign(__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 })), (utm_source !== undefined && { utm_source: utm_source })), (utm_medium !== undefined && { utm_medium: utm_medium })), (utm_campaign !== undefined && { utm_campaign: utm_campaign })), (is_authorised !== undefined && { is_authorised: is_authorised })));
         
     | 
| 
       78 
78 
     | 
    
         
             
                };
         
     | 
| 
       79 
79 
     | 
    
         
             
                Growthbook.prototype.getFeatureState = function (id) {
         
     | 
| 
       80 
80 
     | 
    
         
             
                    // @ts-ignore
         
     | 
    
        package/lib/types.d.ts
    CHANGED
    
    | 
         @@ -4,6 +4,10 @@ export type TGrowthbookAttributes = { 
     | 
|
| 
       4 
4 
     | 
    
         
             
                user_language?: string;
         
     | 
| 
       5 
5 
     | 
    
         
             
                device_language?: string;
         
     | 
| 
       6 
6 
     | 
    
         
             
                device_type?: string;
         
     | 
| 
      
 7 
     | 
    
         
            +
                utm_source?: string;
         
     | 
| 
      
 8 
     | 
    
         
            +
                utm_medium?: 'ppc-native' | 'affiliate' | 'common' | string;
         
     | 
| 
      
 9 
     | 
    
         
            +
                utm_campaign?: string;
         
     | 
| 
      
 10 
     | 
    
         
            +
                is_authorised?: boolean;
         
     | 
| 
       7 
11 
     | 
    
         
             
            };
         
     | 
| 
       8 
12 
     | 
    
         
             
            export type TCoreAttributes = {
         
     | 
| 
       9 
13 
     | 
    
         
             
                account_type?: string;
         
     | 
| 
         @@ -87,28 +91,35 @@ type TradeTypesForm = { 
     | 
|
| 
       87 
91 
     | 
    
         
             
                subform_name?: string;
         
     | 
| 
       88 
92 
     | 
    
         
             
            };
         
     | 
| 
       89 
93 
     | 
    
         
             
            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';
         
     | 
| 
      
 94 
     | 
    
         
            +
                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' | 'edit_your_bot' | 'choose_your_bot' | 'delete_your_bot';
         
     | 
| 
       91 
95 
     | 
    
         
             
                shortcut_name?: string;
         
     | 
| 
       92 
96 
     | 
    
         
             
                form_source?: string;
         
     | 
| 
      
 97 
     | 
    
         
            +
                form_name?: string;
         
     | 
| 
       93 
98 
     | 
    
         
             
                search_string?: string;
         
     | 
| 
       94 
99 
     | 
    
         
             
                delete_popup_respond?: string;
         
     | 
| 
       95 
100 
     | 
    
         
             
                bot_last_modified_time?: number;
         
     | 
| 
       96 
101 
     | 
    
         
             
                bot_name?: string;
         
     | 
| 
      
 102 
     | 
    
         
            +
                bot_status?: string;
         
     | 
| 
      
 103 
     | 
    
         
            +
                preview_mode?: string;
         
     | 
| 
       97 
104 
     | 
    
         
             
            };
         
     | 
| 
       98 
105 
     | 
    
         
             
            type BotQuickStrategyForm = {
         
     | 
| 
       99 
     | 
    
         
            -
                action?: 'open' | 'close' | ' 
     | 
| 
       100 
     | 
    
         
            -
                form_source?: ' 
     | 
| 
       101 
     | 
    
         
            -
                 
     | 
| 
       102 
     | 
    
         
            -
                 
     | 
| 
       103 
     | 
    
         
            -
                 
     | 
| 
       104 
     | 
    
         
            -
                 
     | 
| 
       105 
     | 
    
         
            -
                 
     | 
| 
      
 106 
     | 
    
         
            +
                action?: 'open' | 'close' | 'choose_strategy_type' | 'switch_strategy_mode' | 'choose_asset' | 'choose_trade_type' | 'choose_trade_type_mode' | 'choose_duration' | 'change_parameter_value' | 'info_popup_open' | 'run_strategy' | 'loss_threshold_warning_popup' | 'learn_more_expansion' | 'learn_more_collapse' | 'edit_strategy';
         
     | 
| 
      
 107 
     | 
    
         
            +
                form_source?: 'ce_bot_dashboard_form' | 'ce_bot_builder_form';
         
     | 
| 
      
 108 
     | 
    
         
            +
                form_name?: 'ce_bot_quick_strategy_form';
         
     | 
| 
      
 109 
     | 
    
         
            +
                strategy_type?: `d'alembert` | `martingale` | `oscar's-grind` | `reverse martingale` | `reverse d'alembert` | `1-3-2-6`;
         
     | 
| 
      
 110 
     | 
    
         
            +
                strategy_switcher_mode?: 'learn more' | 'trade parameters';
         
     | 
| 
      
 111 
     | 
    
         
            +
                asset_type?: string;
         
     | 
| 
      
 112 
     | 
    
         
            +
                trade_type?: string;
         
     | 
| 
      
 113 
     | 
    
         
            +
                trade_type_mode?: string;
         
     | 
| 
       106 
114 
     | 
    
         
             
                duration_type?: 'ticks' | 'seconds' | 'minutes' | 'hours' | 'days';
         
     | 
| 
       107 
     | 
    
         
            -
                parameter_type?: 'initial-stake' | 'duration' | 'profit-threshold' | 'loss-threshold' | 'size-unit' | 'max-stake';
         
     | 
| 
       108 
     | 
    
         
            -
                 
     | 
| 
       109 
     | 
    
         
            -
                 
     | 
| 
       110 
     | 
    
         
            -
                 
     | 
| 
      
 115 
     | 
    
         
            +
                parameter_type?: 'initial-stake' | 'duration' | 'profit-threshold' | 'loss-threshold' | 'size-unit' | 'max-stake' | string;
         
     | 
| 
      
 116 
     | 
    
         
            +
                parameter_field_type?: 'input' | 'dropdown' | 'slider' | 'checkbox' | 'number';
         
     | 
| 
      
 117 
     | 
    
         
            +
                parameter_value?: string | number | boolean;
         
     | 
| 
      
 118 
     | 
    
         
            +
                plus_minus_push?: 'yes' | 'no';
         
     | 
| 
       111 
119 
     | 
    
         
             
                manual_parameter_input?: 'yes' | 'no';
         
     | 
| 
      
 120 
     | 
    
         
            +
                dont_show_checkbox?: 'yes' | 'no';
         
     | 
| 
      
 121 
     | 
    
         
            +
                cta_name?: 'edit_the_amount' | 'yes_continue';
         
     | 
| 
      
 122 
     | 
    
         
            +
                learn_more_title?: string;
         
     | 
| 
       112 
123 
     | 
    
         
             
            };
         
     | 
| 
       113 
124 
     | 
    
         
             
            type BotBuilderForm = {
         
     | 
| 
       114 
125 
     | 
    
         
             
                action?: 'open' | 'close' | 'search';
         
     | 
| 
         @@ -185,6 +196,21 @@ type ChartTypesFormAction = { 
     | 
|
| 
       185 
196 
     | 
    
         
             
                chart_type_name?: string;
         
     | 
| 
       186 
197 
     | 
    
         
             
                time_interval_name?: string;
         
     | 
| 
       187 
198 
     | 
    
         
             
            };
         
     | 
| 
      
 199 
     | 
    
         
            +
            type ContractsSetupForm = {
         
     | 
| 
      
 200 
     | 
    
         
            +
                form_name: string;
         
     | 
| 
      
 201 
     | 
    
         
            +
                trade_type_name: string;
         
     | 
| 
      
 202 
     | 
    
         
            +
            } & ({
         
     | 
| 
      
 203 
     | 
    
         
            +
                action: 'change_parameter_value';
         
     | 
| 
      
 204 
     | 
    
         
            +
                duration_type?: string;
         
     | 
| 
      
 205 
     | 
    
         
            +
                input_type?: string;
         
     | 
| 
      
 206 
     | 
    
         
            +
                parameter_field_type?: string;
         
     | 
| 
      
 207 
     | 
    
         
            +
                parameter_type?: string;
         
     | 
| 
      
 208 
     | 
    
         
            +
                parameter_value?: string;
         
     | 
| 
      
 209 
     | 
    
         
            +
            } | {
         
     | 
| 
      
 210 
     | 
    
         
            +
                action: 'run_contract';
         
     | 
| 
      
 211 
     | 
    
         
            +
                switcher_duration_mode_name?: string;
         
     | 
| 
      
 212 
     | 
    
         
            +
                switcher_stakepayout_mode_name?: string;
         
     | 
| 
      
 213 
     | 
    
         
            +
            });
         
     | 
| 
       188 
214 
     | 
    
         
             
            type TradersHubOnboardingFormAction = {
         
     | 
| 
       189 
215 
     | 
    
         
             
                action?: 'open' | 'close' | 'step_passed' | 'step_back' | 'choose_step_navigation';
         
     | 
| 
       190 
216 
     | 
    
         
             
                form_source?: 'tradershub_dashboard_form' | 'tradershub_first_entrance' | 'repeat_tour';
         
     | 
| 
         @@ -208,6 +234,7 @@ export type TEvents = { 
     | 
|
| 
       208 
234 
     | 
    
         
             
                ce_bot_quick_strategy_form: BotQuickStrategyForm;
         
     | 
| 
       209 
235 
     | 
    
         
             
                ce_bot_builder_form: BotBuilderForm;
         
     | 
| 
       210 
236 
     | 
    
         
             
                ce_bot_tutorial_form: BotTutorialForm;
         
     | 
| 
      
 237 
     | 
    
         
            +
                ce_contracts_set_up_form: ContractsSetupForm;
         
     | 
| 
       211 
238 
     | 
    
         
             
                ce_indicators_types_form: IndicatorsTypesFormAction;
         
     | 
| 
       212 
239 
     | 
    
         
             
                ce_trade_types_form: TradeTypesForm;
         
     | 
| 
       213 
240 
     | 
    
         
             
                ce_chart_types_form: ChartTypesFormAction;
         
     | 
    
        package/package.json
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            {
         
     | 
| 
       2 
2 
     | 
    
         
             
              "name": "@deriv-com/analytics",
         
     | 
| 
       3 
     | 
    
         
            -
              "version": "1.4. 
     | 
| 
      
 3 
     | 
    
         
            +
              "version": "1.4.12",
         
     | 
| 
       4 
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 
5 
     | 
    
         
             
              "keywords": [
         
     | 
| 
       6 
6 
     | 
    
         
             
                "rudderstack",
         
     |