@deriv-com/analytics
Version:
The analytics package contains all the utility functions used for tracking user events and sending them to the respective platform such as Rudderstack.
59 lines (58 loc) • 3.19 kB
TypeScript
import { Growthbook, GrowthbookConfigs } from './growthbook';
import { RudderStack } from './rudderstack';
import { TCoreAttributes, TEvents, TGrowthbookOptions } from './types';
declare global {
interface Window {
AnalyticsInstance: ReturnType<typeof createAnalyticsInstance>;
}
}
type Options = {
growthbookKey?: string;
growthbookDecryptionKey?: string;
rudderstackKey: string;
growthbookOptions?: TGrowthbookOptions;
disableRudderstackAMD?: boolean;
};
export declare function createAnalyticsInstance(options?: Options): {
initialise: ({ growthbookKey, growthbookDecryptionKey, rudderstackKey, growthbookOptions, disableRudderstackAMD, }: Options) => Promise<void>;
setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, anonymous_id, app_id, utm_source, utm_medium, utm_campaign, is_authorised, residence_country, url, domain, geo_location, loggedIn, network_downlink, network_rtt, network_type, account_currency, account_mode, }: TCoreAttributes) => void;
identifyEvent: (user_id?: string) => void;
getFeatureState: (id: string) => string | undefined;
getFeatureValue: <K extends string | number, V extends GrowthbookConfigs[K]>(id: K, defaultValue: V) => import("@growthbook/growthbook").WidenPrimitives<V>;
getGrowthbookStatus: () => Promise<{
isLoaded: boolean;
status: void | import("@growthbook/growthbook").InitResponse;
}>;
isFeatureOn: (key: string) => boolean;
setUrl: (href: string) => Promise<void>;
getId: () => string;
trackEvent: <T extends keyof TEvents>(event: T, analytics_data: TEvents[T]) => void;
getInstances: () => {
ab: Growthbook;
tracking: RudderStack;
};
pageView: (current_page: string, platform?: string, properties?: {}) => void;
reset: () => void;
};
export declare const Analytics: {
initialise: ({ growthbookKey, growthbookDecryptionKey, rudderstackKey, growthbookOptions, disableRudderstackAMD, }: Options) => Promise<void>;
setAttributes: ({ country, user_language, device_language, device_type, account_type, user_id, anonymous_id, app_id, utm_source, utm_medium, utm_campaign, is_authorised, residence_country, url, domain, geo_location, loggedIn, network_downlink, network_rtt, network_type, account_currency, account_mode, }: TCoreAttributes) => void;
identifyEvent: (user_id?: string) => void;
getFeatureState: (id: string) => string | undefined;
getFeatureValue: <K extends string | number, V extends GrowthbookConfigs[K]>(id: K, defaultValue: V) => import("@growthbook/growthbook").WidenPrimitives<V>;
getGrowthbookStatus: () => Promise<{
isLoaded: boolean;
status: void | import("@growthbook/growthbook").InitResponse;
}>;
isFeatureOn: (key: string) => boolean;
setUrl: (href: string) => Promise<void>;
getId: () => string;
trackEvent: <T extends keyof TEvents>(event: T, analytics_data: TEvents[T]) => void;
getInstances: () => {
ab: Growthbook;
tracking: RudderStack;
};
pageView: (current_page: string, platform?: string, properties?: {}) => void;
reset: () => void;
};
export {};