UNPKG

2.99 kBTypeScriptView Raw
1import { AnalyticsProvider, AnalyticsEvent, AutoTrackSessionOpts, AutoTrackPageViewOpts, AutoTrackEventOpts, PersonalizeAnalyticsEvent, KinesisAnalyticsEvent } from './types';
2import { PageViewTracker, EventTracker, SessionTracker } from './trackers';
3declare const trackers: {
4 pageView: typeof PageViewTracker;
5 event: typeof EventTracker;
6 session: typeof SessionTracker;
7};
8declare type TrackerTypes = keyof typeof trackers;
9/**
10 * Provide mobile analytics client functions
11 */
12export declare class AnalyticsClass {
13 private _config;
14 private _pluggables;
15 private _disabled;
16 private _trackers;
17 /**
18 * Initialize Analtyics
19 * @param config - Configuration of the Analytics
20 */
21 constructor();
22 getModuleName(): string;
23 /**
24 * configure Analytics
25 * @param {Object} config - Configuration of the Analytics
26 */
27 configure(config?: any): any;
28 /**
29 * add plugin into Analytics category
30 * @param pluggable - an instance of the plugin
31 */
32 addPluggable(pluggable: AnalyticsProvider): any;
33 /**
34 * Get the plugin object
35 * @param providerName - the name of the provider to be removed
36 */
37 getPluggable(providerName: string): AnalyticsProvider;
38 /**
39 * Remove the plugin object
40 * @param providerName - the name of the provider to be removed
41 */
42 removePluggable(providerName: string): void;
43 /**
44 * stop sending events
45 */
46 disable(): void;
47 /**
48 * start sending events
49 */
50 enable(): void;
51 /**
52 * Record Session start
53 * @param [provider] - name of the provider.
54 * @return - A promise which resolves if buffer doesn't overflow
55 */
56 startSession(provider?: string): Promise<unknown>;
57 /**
58 * Record Session stop
59 * @param [provider] - name of the provider.
60 * @return - A promise which resolves if buffer doesn't overflow
61 */
62 stopSession(provider?: string): Promise<unknown>;
63 /**
64 * Record one analytic event and send it to Pinpoint
65 * @param event - An object with the name of the event, attributes of the event and event metrics.
66 * @param [provider] - name of the provider.
67 */
68 record(event: AnalyticsEvent | PersonalizeAnalyticsEvent | KinesisAnalyticsEvent, provider?: string): Promise<unknown>;
69 updateEndpoint(attrs: {
70 [key: string]: any;
71 }, provider?: string): Promise<unknown>;
72 private _sendEvent;
73 /**
74 * Enable or disable auto tracking
75 * @param trackerType - The type of tracker to activate.
76 * @param [opts] - Auto tracking options.
77 */
78 autoTrack(trackerType: 'session', opts: AutoTrackSessionOpts): any;
79 autoTrack(trackerType: 'pageView', opts: AutoTrackPageViewOpts): any;
80 autoTrack(trackerType: 'event', opts: AutoTrackEventOpts): any;
81 autoTrack(trackerType: TrackerTypes, opts: {
82 provider: string;
83 [key: string]: any;
84 }): any;
85}
86export declare const Analytics: AnalyticsClass;
87export {};