UNPKG

@deriv-com/analytics

Version:

Comprehensive analytics package for Deriv applications. Provides unified event tracking, A/B testing, and user analytics through RudderStack, PostHog and GrowthBook integrations with built-in caching and offline support.

76 lines (72 loc) 2.98 kB
import * as _growthbook_growthbook from '@growthbook/growthbook'; import { Context, GrowthBook, InitResponse } from '@growthbook/growthbook'; import { RudderAnalytics } from '@rudderstack/analytics-js'; type TGrowthbookAttributes = { id?: string; country?: string; user_language?: string; device_language?: string; device_type?: string; utm_source?: string; utm_medium?: 'ppc-native' | 'affiliate' | 'common' | string; utm_campaign?: string; is_authorised?: boolean; url?: string; domain?: string; utm_content?: string; residence_country?: string; loggedIn?: boolean; network_type?: string; network_downlink?: number; user_id?: string; anonymous_id?: string; account_mode?: string; }; type TGrowthbookOptions = Partial<Omit<Context, 'attributes'> & { attributes: TGrowthbookCoreAttributes; }>; type TGrowthbookCoreAttributes = { account_type?: string; user_id?: string; anonymous_id?: string; app_id?: string; user_identity?: string; residence_country?: string; geo_location?: string; email_hash?: string; network_type?: string; network_rtt?: number; network_downlink?: number; account_currency?: string; } & Partial<TGrowthbookAttributes>; type GrowthbookConfigs = { 'tracking-buttons-config': Record<string, boolean>; } & { [key: string]: Record<string, boolean> | string | boolean | []; }; declare class Growthbook { analytics: RudderAnalytics; GrowthBook: GrowthBook<GrowthbookConfigs>; private static _instance; isLoaded: boolean; status: void | InitResponse; private debug; private log; constructor(clientKey: string, decryptionKey: string, growthbookOptions?: TGrowthbookOptions, debug?: boolean); static getGrowthBookInstance: (clientKey: string, decryptionKey?: string, growthbookOptions?: TGrowthbookOptions, debug?: boolean) => Growthbook; reapplyExperiment(url?: string): void; private waitForIsLoaded; setAttributes: ({ id, country, user_language, device_language, device_type, utm_source, utm_medium, utm_campaign, is_authorised, url, domain, utm_content, residence_country, loggedIn, network_type, network_downlink, user_id, anonymous_id, account_mode, }: TGrowthbookAttributes) => void; getFeatureValue: <K extends keyof GrowthbookConfigs, V extends GrowthbookConfigs[K]>(key: K, defaultValue: V) => _growthbook_growthbook.WidenPrimitives<V>; getStatus: () => Promise<{ isLoaded: boolean; status: void | InitResponse; }>; getFeatureState: (id: string) => _growthbook_growthbook.FeatureResult<string | boolean | [] | Record<string, boolean> | null>; setUrl: (href: string) => void; isOn: (key: string) => boolean; init: () => Promise<void>; destroy: () => void; static resetInstance: () => void; } export { Growthbook, type GrowthbookConfigs, type TGrowthbookAttributes, type TGrowthbookCoreAttributes, type TGrowthbookOptions };