-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
162 lines (157 loc) · 4.23 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/**
* Base interface for extension options, allowing for disabling the extension.
*/
export interface IBaseExtensionOptions {
/**
* Flag to disable the extension (default: false).
*/
disable?: boolean;
}
/**
* Options specific to the Cookie Extension.
*/
export interface ICookieExtensionOptions extends IBaseExtensionOptions {
/**
* Number of days before the cookie expires (default: 30 days).
*/
cookieExpireDays?: number;
/**
* The name of the cookie (default: '_altcha_visited').
*/
cookieName?: string;
/**
* The path where the cookie is available (default: '/').
*/
cookiePath?: string;
}
/**
* Options specific to the Filter Extension.
*/
export interface IFilterExtensionOptions extends IBaseExtensionOptions {
/**
* Set to true to report events made by bots and crawlers.
*/
allowBots?: boolean;
/**
* A custom check function.
*
* @param event
* @returns Boolean or undefined.
*/
checkFn?: (event: IEvent) => boolean | undefined | void;
/**
* A list of hostnames to exclude from tracked data (default: 'localhost')
*/
hostnames?: string[];
}
/**
* Options specific to the Visibility Extension.
*/
export interface IVivibilityExtensionOptions extends IBaseExtensionOptions {
/**
* Timeout (in milliseconds) after which the hidden state is reported as an exit event (default: 4000ms).
*/
hiddenTimeout?: number;
}
/**
* Event data structure for custom event tracking.
*/
export interface IEvent {
/**
* The name of the custom event being tracked.
*/
customEvent?: string;
/**
* Duration of the event in milliseconds.
*/
duration?: number;
/**
* Flag indicating if this is an exit event (user exiting the app).
*/
exit?: boolean;
/**
* Custom properties as a key-value map to add additional context.
*/
props?: Record<string, string>;
/**
* Flag indicating if the user is a returning visitor.
*/
returning?: boolean;
/**
* The timestamp when the event is reported, in milliseconds. The origin time of the event is `timestamp - duration`.
*/
timestamp: number;
/**
* Name of the view or the URL of the current page.
*/
view?: string;
}
/**
* Configuration options for initializing the tracker.
*/
export interface ITrackerOptions {
/**
* List of URL query parameters that should be tracked. By default, all query parameters are removed.
*/
allowSearchParams?: string[];
/**
* Custom API URL to override the default analytics endpoint.
*/
apiUrl?: string;
/**
* The current version of the app (e.g., 'v1.0.0').
*/
appVersion?: string;
/**
* Click tracking extension configuration (or set to boolean to enable/disable).
*/
click?: IBaseExtensionOptions | boolean;
/**
* Cookie tracking extension configuration (or set to boolean to enable/disable).
*/
cookie?: ICookieExtensionOptions | boolean;
/**
* Enable or disable debug mode (default: false).
*/
debug?: boolean;
/**
* Filter extension configuration (or set to boolean to enable/disable).
*/
filter?: IBaseExtensionOptions | boolean;
/**
* Global variable name for the tracker instance in the browser (set to false or null to disable global name).
*/
globalName?: string | null | false;
/**
* Hash tracking extension configuration (or set to boolean to enable/disable).
*/
hash?: IBaseExtensionOptions | boolean;
/**
* Keyboard event tracking configuration (or set to boolean to enable/disable).
*/
keyboard?: IBaseExtensionOptions | boolean;
/**
* Mouse event tracking configuration (or set to boolean to enable/disable).
*/
mouse?: IBaseExtensionOptions | boolean;
/**
* Unique project identifier for the analytics tracker.
*/
projectId: string;
/**
* Pushstate event tracking configuration for SPAs (or set to boolean to enable/disable).
*/
pushstate?: IBaseExtensionOptions | boolean;
/**
* Respect the user's 'Do Not Track' browser setting (default: false).
*/
respectDnt?: boolean;
/**
* Custom unique identifier for the session or user.
*/
uniqueId?: string;
/**
* Visibility tracking configuration (or set to boolean to enable/disable).
*/
visibility?: IVivibilityExtensionOptions | boolean;
}