@v-tilt/browser 1.5.1 → 1.7.0
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/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/entrypoints/server.es.d.ts +12 -0
- package/dist/external-scripts-loader.js +1 -1
- package/dist/external-scripts-loader.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +51 -7
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +51 -7
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/server.d.ts +105 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +32 -6
- package/dist/vtilt.d.ts +19 -1
- package/package.json +1 -2
- package/lib/config.d.ts +0 -17
- package/lib/config.js +0 -76
- package/lib/constants.d.ts +0 -174
- package/lib/constants.js +0 -649
- package/lib/entrypoints/all-external-dependencies.d.ts +0 -8
- package/lib/entrypoints/all-external-dependencies.js +0 -10
- package/lib/entrypoints/array.d.ts +0 -2
- package/lib/entrypoints/array.full.d.ts +0 -17
- package/lib/entrypoints/array.full.js +0 -19
- package/lib/entrypoints/array.js +0 -4
- package/lib/entrypoints/array.no-external.d.ts +0 -1
- package/lib/entrypoints/array.no-external.js +0 -4
- package/lib/entrypoints/chat.d.ts +0 -22
- package/lib/entrypoints/chat.js +0 -32
- package/lib/entrypoints/external-scripts-loader.d.ts +0 -24
- package/lib/entrypoints/external-scripts-loader.js +0 -107
- package/lib/entrypoints/main.cjs.d.ts +0 -4
- package/lib/entrypoints/main.cjs.js +0 -29
- package/lib/entrypoints/module.es.d.ts +0 -4
- package/lib/entrypoints/module.es.js +0 -23
- package/lib/entrypoints/module.no-external.es.d.ts +0 -4
- package/lib/entrypoints/module.no-external.es.js +0 -23
- package/lib/entrypoints/recorder.d.ts +0 -23
- package/lib/entrypoints/recorder.js +0 -42
- package/lib/entrypoints/web-vitals.d.ts +0 -14
- package/lib/entrypoints/web-vitals.js +0 -29
- package/lib/extensions/chat/chat-wrapper.d.ts +0 -196
- package/lib/extensions/chat/chat-wrapper.js +0 -545
- package/lib/extensions/chat/chat.d.ts +0 -99
- package/lib/extensions/chat/chat.js +0 -1891
- package/lib/extensions/chat/index.d.ts +0 -10
- package/lib/extensions/chat/index.js +0 -27
- package/lib/extensions/chat/types.d.ts +0 -159
- package/lib/extensions/chat/types.js +0 -22
- package/lib/extensions/history-autocapture.d.ts +0 -17
- package/lib/extensions/history-autocapture.js +0 -105
- package/lib/extensions/replay/index.d.ts +0 -13
- package/lib/extensions/replay/index.js +0 -31
- package/lib/extensions/replay/session-recording-utils.d.ts +0 -92
- package/lib/extensions/replay/session-recording-utils.js +0 -212
- package/lib/extensions/replay/session-recording-wrapper.d.ts +0 -61
- package/lib/extensions/replay/session-recording-wrapper.js +0 -149
- package/lib/extensions/replay/session-recording.d.ts +0 -95
- package/lib/extensions/replay/session-recording.js +0 -700
- package/lib/extensions/replay/types.d.ts +0 -211
- package/lib/extensions/replay/types.js +0 -8
- package/lib/geolocation.d.ts +0 -5
- package/lib/geolocation.js +0 -31
- package/lib/rate-limiter.d.ts +0 -52
- package/lib/rate-limiter.js +0 -80
- package/lib/request-queue.d.ts +0 -78
- package/lib/request-queue.js +0 -156
- package/lib/request.d.ts +0 -54
- package/lib/request.js +0 -265
- package/lib/retry-queue.d.ts +0 -64
- package/lib/retry-queue.js +0 -182
- package/lib/session.d.ts +0 -66
- package/lib/session.js +0 -191
- package/lib/storage.d.ts +0 -117
- package/lib/storage.js +0 -438
- package/lib/types.d.ts +0 -326
- package/lib/types.js +0 -24
- package/lib/user-manager.d.ts +0 -154
- package/lib/user-manager.js +0 -589
- package/lib/utils/event-utils.d.ts +0 -52
- package/lib/utils/event-utils.js +0 -306
- package/lib/utils/globals.d.ts +0 -235
- package/lib/utils/globals.js +0 -30
- package/lib/utils/index.d.ts +0 -46
- package/lib/utils/index.js +0 -134
- package/lib/utils/patch.d.ts +0 -6
- package/lib/utils/patch.js +0 -39
- package/lib/utils/request-utils.d.ts +0 -17
- package/lib/utils/request-utils.js +0 -80
- package/lib/utils/type-utils.d.ts +0 -4
- package/lib/utils/type-utils.js +0 -9
- package/lib/utils/user-agent-utils.d.ts +0 -18
- package/lib/utils/user-agent-utils.js +0 -411
- package/lib/vtilt.d.ts +0 -342
- package/lib/vtilt.js +0 -1073
- package/lib/web-vitals.d.ts +0 -95
- package/lib/web-vitals.js +0 -380
package/lib/types.d.ts
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VTilt Types
|
|
3
|
-
*
|
|
4
|
-
* Type definitions for the VTilt tracking SDK.
|
|
5
|
-
* Following PostHog's patterns where applicable.
|
|
6
|
-
*/
|
|
7
|
-
import type { PersonProfilesMode } from "./constants";
|
|
8
|
-
export interface VTiltConfig {
|
|
9
|
-
/** Project identifier (required) */
|
|
10
|
-
token: string;
|
|
11
|
-
/** API host for tracking (default: https://api.vtilt.io) */
|
|
12
|
-
api_host?: string;
|
|
13
|
-
/** UI host for dashboard links */
|
|
14
|
-
ui_host?: string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Host for loading extension scripts (recorder.js, etc.)
|
|
17
|
-
* Defaults to unpkg CDN: https://unpkg.com/@v-tilt/browser@{version}/dist
|
|
18
|
-
* Can also use jsdelivr: https://cdn.jsdelivr.net/npm/@v-tilt/browser@{version}/dist
|
|
19
|
-
* Or self-hosted: https://your-domain.com/static
|
|
20
|
-
*/
|
|
21
|
-
script_host?: string;
|
|
22
|
-
/** Proxy domain for tracking requests */
|
|
23
|
-
proxy?: string;
|
|
24
|
-
/** Full proxy URL for tracking requests */
|
|
25
|
-
proxyUrl?: string;
|
|
26
|
-
/** Instance name (for multiple instances) */
|
|
27
|
-
name?: string;
|
|
28
|
-
/** Project ID (set via init() first argument) */
|
|
29
|
-
projectId?: string;
|
|
30
|
-
/** Domain to track (auto-detected if not provided) - used in event properties */
|
|
31
|
-
domain?: string;
|
|
32
|
-
/** Storage method for session data */
|
|
33
|
-
storage?: PersistenceMethod;
|
|
34
|
-
/** Persistence method for user data */
|
|
35
|
-
persistence?: PersistenceMethod;
|
|
36
|
-
/** Persistence name prefix */
|
|
37
|
-
persistence_name?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Enable cross-subdomain cookies.
|
|
40
|
-
* When true, cookies are shared across subdomains (e.g., app.example.com and www.example.com).
|
|
41
|
-
* Auto-detects false for platforms like herokuapp.com, vercel.app, netlify.app.
|
|
42
|
-
* @default true (except for excluded platforms)
|
|
43
|
-
*/
|
|
44
|
-
cross_subdomain_cookie?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Person profiles mode:
|
|
47
|
-
* - 'always': Always create person profiles (default)
|
|
48
|
-
* - 'identified_only': Only create when user is identified
|
|
49
|
-
* - 'never': Never create person profiles
|
|
50
|
-
*/
|
|
51
|
-
person_profiles?: PersonProfilesMode;
|
|
52
|
-
/** Enable autocapture */
|
|
53
|
-
autocapture?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Enable web vitals tracking.
|
|
56
|
-
* Can be a boolean or an object with detailed configuration.
|
|
57
|
-
*/
|
|
58
|
-
capture_performance?: boolean | CapturePerformanceConfig;
|
|
59
|
-
/** Enable page view tracking */
|
|
60
|
-
capture_pageview?: boolean | "auto";
|
|
61
|
-
/** Enable page leave tracking */
|
|
62
|
-
capture_pageleave?: boolean | "if_capture_pageview";
|
|
63
|
-
/** Disable compression */
|
|
64
|
-
disable_compression?: boolean;
|
|
65
|
-
/** Whether to stringify payload before sending */
|
|
66
|
-
stringifyPayload?: boolean;
|
|
67
|
-
/** Properties to exclude from events */
|
|
68
|
-
property_denylist?: string[];
|
|
69
|
-
/** Mask text in autocapture */
|
|
70
|
-
mask_all_text?: boolean;
|
|
71
|
-
/** Mask all element attributes */
|
|
72
|
-
mask_all_element_attributes?: boolean;
|
|
73
|
-
/** Respect Do Not Track browser setting */
|
|
74
|
-
respect_dnt?: boolean;
|
|
75
|
-
/** Opt users out by default */
|
|
76
|
-
opt_out_capturing_by_default?: boolean;
|
|
77
|
-
/** Session recording configuration */
|
|
78
|
-
session_recording?: SessionRecordingOptions;
|
|
79
|
-
/** Disable session recording (convenience flag) */
|
|
80
|
-
disable_session_recording?: boolean;
|
|
81
|
-
/** Chat widget configuration */
|
|
82
|
-
chat?: ChatWidgetConfig;
|
|
83
|
-
/** Disable chat (convenience flag) */
|
|
84
|
-
disable_chat?: boolean;
|
|
85
|
-
/** Global attributes added to all events */
|
|
86
|
-
globalAttributes?: Record<string, string>;
|
|
87
|
-
/** Bootstrap data for initialization */
|
|
88
|
-
bootstrap?: {
|
|
89
|
-
distinctID?: string;
|
|
90
|
-
isIdentifiedID?: boolean;
|
|
91
|
-
featureFlags?: Record<string, boolean | string>;
|
|
92
|
-
};
|
|
93
|
-
/** Before send hook for modifying events */
|
|
94
|
-
before_send?: (event: CaptureResult) => CaptureResult | null;
|
|
95
|
-
/** Loaded callback */
|
|
96
|
-
loaded?: (vtilt: any) => void;
|
|
97
|
-
}
|
|
98
|
-
export interface EventPayload {
|
|
99
|
-
[key: string]: any;
|
|
100
|
-
}
|
|
101
|
-
export interface CaptureResult {
|
|
102
|
-
uuid: string;
|
|
103
|
-
event: string;
|
|
104
|
-
properties: Properties;
|
|
105
|
-
$set?: Properties;
|
|
106
|
-
$set_once?: Properties;
|
|
107
|
-
timestamp?: string;
|
|
108
|
-
}
|
|
109
|
-
export interface CaptureOptions {
|
|
110
|
-
/** Override timestamp */
|
|
111
|
-
timestamp?: Date;
|
|
112
|
-
/** Properties to $set on person */
|
|
113
|
-
$set?: Properties;
|
|
114
|
-
/** Properties to $set_once on person */
|
|
115
|
-
$set_once?: Properties;
|
|
116
|
-
/** Send immediately (skip batching) */
|
|
117
|
-
send_instantly?: boolean;
|
|
118
|
-
}
|
|
119
|
-
export interface TrackingEvent {
|
|
120
|
-
timestamp: string;
|
|
121
|
-
event: string;
|
|
122
|
-
project_id: string;
|
|
123
|
-
distinct_id: string;
|
|
124
|
-
anonymous_id?: string;
|
|
125
|
-
payload: EventPayload;
|
|
126
|
-
}
|
|
127
|
-
export type Property = string | number | boolean | null | undefined | Date | any[] | Record<string, any>;
|
|
128
|
-
export interface Properties {
|
|
129
|
-
[key: string]: Property;
|
|
130
|
-
}
|
|
131
|
-
export interface PropertyOperations {
|
|
132
|
-
$set?: Properties;
|
|
133
|
-
$set_once?: Properties;
|
|
134
|
-
$unset?: string[];
|
|
135
|
-
}
|
|
136
|
-
export interface SessionData {
|
|
137
|
-
value: string;
|
|
138
|
-
expiry: number;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Persistence method for user/session data
|
|
142
|
-
* Following PostHog's approach:
|
|
143
|
-
* - 'localStorage+cookie': Stores limited data in cookies, rest in localStorage (default)
|
|
144
|
-
* - 'cookie': Stores all data in cookies
|
|
145
|
-
* - 'localStorage': Stores all data in localStorage
|
|
146
|
-
* - 'sessionStorage': Stores all data in sessionStorage
|
|
147
|
-
* - 'memory': Stores all data in memory only (no persistence)
|
|
148
|
-
*/
|
|
149
|
-
export type PersistenceMethod = "localStorage+cookie" | "cookie" | "localStorage" | "sessionStorage" | "memory";
|
|
150
|
-
/** User identity state */
|
|
151
|
-
export interface UserIdentity {
|
|
152
|
-
/** Current distinct ID (null if anonymous) */
|
|
153
|
-
distinct_id: string | null;
|
|
154
|
-
/** Anonymous ID (always present) */
|
|
155
|
-
anonymous_id: string;
|
|
156
|
-
/** Device ID (persists across sessions) */
|
|
157
|
-
device_id: string;
|
|
158
|
-
/** User properties */
|
|
159
|
-
properties: Properties;
|
|
160
|
-
/** Identity state */
|
|
161
|
-
user_state: "anonymous" | "identified";
|
|
162
|
-
}
|
|
163
|
-
export interface UserProperties {
|
|
164
|
-
[key: string]: any;
|
|
165
|
-
}
|
|
166
|
-
export interface AliasEvent {
|
|
167
|
-
distinct_id: string;
|
|
168
|
-
original: string;
|
|
169
|
-
}
|
|
170
|
-
/** Supported Web Vitals metrics */
|
|
171
|
-
export type SupportedWebVitalsMetric = "LCP" | "CLS" | "FCP" | "INP" | "TTFB";
|
|
172
|
-
/** All supported Web Vitals metrics */
|
|
173
|
-
export declare const ALL_WEB_VITALS_METRICS: SupportedWebVitalsMetric[];
|
|
174
|
-
/** Default Web Vitals metrics (matches PostHog defaults) */
|
|
175
|
-
export declare const DEFAULT_WEB_VITALS_METRICS: SupportedWebVitalsMetric[];
|
|
176
|
-
/**
|
|
177
|
-
* Web Vitals capture configuration
|
|
178
|
-
*/
|
|
179
|
-
export interface CapturePerformanceConfig {
|
|
180
|
-
/** Enable or disable web vitals capture */
|
|
181
|
-
web_vitals?: boolean;
|
|
182
|
-
/** Which metrics to capture (default: LCP, CLS, FCP, INP) */
|
|
183
|
-
web_vitals_allowed_metrics?: SupportedWebVitalsMetric[];
|
|
184
|
-
/** Delay before flushing metrics in ms (default: 5000) */
|
|
185
|
-
web_vitals_delayed_flush_ms?: number;
|
|
186
|
-
/**
|
|
187
|
-
* Maximum allowed metric value in ms (default: 900000 = 15 minutes)
|
|
188
|
-
* Values above this are considered anomalies and ignored.
|
|
189
|
-
* Set to 0 to disable this check.
|
|
190
|
-
*/
|
|
191
|
-
__web_vitals_max_value?: number;
|
|
192
|
-
}
|
|
193
|
-
export interface WebVitalMetric {
|
|
194
|
-
name: string;
|
|
195
|
-
value: number;
|
|
196
|
-
delta: number;
|
|
197
|
-
rating: "good" | "needs-improvement" | "poor";
|
|
198
|
-
id: string;
|
|
199
|
-
navigationType: string;
|
|
200
|
-
/** Timestamp when the metric was captured (added internally) */
|
|
201
|
-
timestamp?: number;
|
|
202
|
-
/** Attribution data from web-vitals library */
|
|
203
|
-
attribution?: Record<string, unknown>;
|
|
204
|
-
}
|
|
205
|
-
export interface GeolocationData {
|
|
206
|
-
country?: string;
|
|
207
|
-
locale?: string;
|
|
208
|
-
}
|
|
209
|
-
export interface GroupsConfig {
|
|
210
|
-
[groupType: string]: string;
|
|
211
|
-
}
|
|
212
|
-
export interface FeatureFlagsConfig {
|
|
213
|
-
[flagKey: string]: boolean | string;
|
|
214
|
-
}
|
|
215
|
-
export type SessionIdChangedCallback = (newSessionId: string, previousSessionId: string | null, changeInfo: {
|
|
216
|
-
reason: "timeout" | "new_session" | "reset";
|
|
217
|
-
}) => void;
|
|
218
|
-
export interface RequestOptions {
|
|
219
|
-
method?: "POST" | "GET";
|
|
220
|
-
headers?: Record<string, string>;
|
|
221
|
-
timeout?: number;
|
|
222
|
-
retry?: boolean;
|
|
223
|
-
}
|
|
224
|
-
/** Mask options for input elements in session recording */
|
|
225
|
-
export interface SessionRecordingMaskInputOptions {
|
|
226
|
-
color?: boolean;
|
|
227
|
-
date?: boolean;
|
|
228
|
-
"datetime-local"?: boolean;
|
|
229
|
-
email?: boolean;
|
|
230
|
-
month?: boolean;
|
|
231
|
-
number?: boolean;
|
|
232
|
-
range?: boolean;
|
|
233
|
-
search?: boolean;
|
|
234
|
-
tel?: boolean;
|
|
235
|
-
text?: boolean;
|
|
236
|
-
time?: boolean;
|
|
237
|
-
url?: boolean;
|
|
238
|
-
week?: boolean;
|
|
239
|
-
textarea?: boolean;
|
|
240
|
-
select?: boolean;
|
|
241
|
-
password?: boolean;
|
|
242
|
-
}
|
|
243
|
-
/** Session recording configuration */
|
|
244
|
-
export interface SessionRecordingOptions {
|
|
245
|
-
/** Enable session recording */
|
|
246
|
-
enabled?: boolean;
|
|
247
|
-
/** Sample rate (0-1, where 1 = 100%) */
|
|
248
|
-
sampleRate?: number;
|
|
249
|
-
/** Minimum session duration in ms before sending */
|
|
250
|
-
minimumDurationMs?: number;
|
|
251
|
-
/** Session idle threshold in ms (default: 5 minutes) */
|
|
252
|
-
sessionIdleThresholdMs?: number;
|
|
253
|
-
/** Full snapshot interval in ms (default: 5 minutes) */
|
|
254
|
-
fullSnapshotIntervalMs?: number;
|
|
255
|
-
/** Enable console log capture */
|
|
256
|
-
captureConsole?: boolean;
|
|
257
|
-
/** Enable network request capture */
|
|
258
|
-
captureNetwork?: boolean;
|
|
259
|
-
/** Canvas recording settings */
|
|
260
|
-
captureCanvas?: {
|
|
261
|
-
recordCanvas?: boolean;
|
|
262
|
-
canvasFps?: number;
|
|
263
|
-
canvasQuality?: number;
|
|
264
|
-
};
|
|
265
|
-
/** Block class for elements to hide (default: 'vt-no-capture') */
|
|
266
|
-
blockClass?: string;
|
|
267
|
-
/** Block selector for elements to hide */
|
|
268
|
-
blockSelector?: string;
|
|
269
|
-
/** Ignore class for input masking (default: 'vt-ignore-input') */
|
|
270
|
-
ignoreClass?: string;
|
|
271
|
-
/** Mask text class (default: 'vt-mask') */
|
|
272
|
-
maskTextClass?: string;
|
|
273
|
-
/** Mask text selector */
|
|
274
|
-
maskTextSelector?: string;
|
|
275
|
-
/** Mask all inputs (default: true) */
|
|
276
|
-
maskAllInputs?: boolean;
|
|
277
|
-
/** Mask input options */
|
|
278
|
-
maskInputOptions?: SessionRecordingMaskInputOptions;
|
|
279
|
-
/** Masking configuration */
|
|
280
|
-
masking?: {
|
|
281
|
-
maskAllInputs?: boolean;
|
|
282
|
-
maskTextSelector?: string;
|
|
283
|
-
blockSelector?: string;
|
|
284
|
-
};
|
|
285
|
-
/** Record headers in network requests */
|
|
286
|
-
recordHeaders?: boolean;
|
|
287
|
-
/** Record body in network requests */
|
|
288
|
-
recordBody?: boolean;
|
|
289
|
-
/** Compress events before sending (default: true) */
|
|
290
|
-
compressEvents?: boolean;
|
|
291
|
-
/** Internal: Mutation throttler refill rate */
|
|
292
|
-
__mutationThrottlerRefillRate?: number;
|
|
293
|
-
/** Internal: Mutation throttler bucket size */
|
|
294
|
-
__mutationThrottlerBucketSize?: number;
|
|
295
|
-
}
|
|
296
|
-
/** Chat widget configuration */
|
|
297
|
-
export interface ChatWidgetConfig {
|
|
298
|
-
/** Enable/disable chat widget (default: auto from dashboard) */
|
|
299
|
-
enabled?: boolean;
|
|
300
|
-
/** Auto-fetch settings from dashboard (default: true) */
|
|
301
|
-
autoConfig?: boolean;
|
|
302
|
-
/** Widget position (default: 'bottom-right') */
|
|
303
|
-
position?: "bottom-right" | "bottom-left";
|
|
304
|
-
/** Widget header/greeting message */
|
|
305
|
-
greeting?: string;
|
|
306
|
-
/** Widget primary color */
|
|
307
|
-
color?: string;
|
|
308
|
-
/** Start in AI mode (default: true) */
|
|
309
|
-
aiMode?: boolean;
|
|
310
|
-
/** AI greeting message (first message from AI) */
|
|
311
|
-
aiGreeting?: string;
|
|
312
|
-
/** Preload widget script on idle vs on-demand */
|
|
313
|
-
preload?: boolean;
|
|
314
|
-
/** Offline message shown when business is unavailable */
|
|
315
|
-
offlineMessage?: string;
|
|
316
|
-
/** Collect email when offline */
|
|
317
|
-
collectEmailOffline?: boolean;
|
|
318
|
-
}
|
|
319
|
-
export interface RemoteConfig {
|
|
320
|
-
/** Default to identified_only mode */
|
|
321
|
-
defaultIdentifiedOnly?: boolean;
|
|
322
|
-
/** Feature flags */
|
|
323
|
-
featureFlags?: FeatureFlagsConfig;
|
|
324
|
-
/** Session recording config */
|
|
325
|
-
sessionRecording?: SessionRecordingOptions;
|
|
326
|
-
}
|
package/lib/types.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* VTilt Types
|
|
4
|
-
*
|
|
5
|
-
* Type definitions for the VTilt tracking SDK.
|
|
6
|
-
* Following PostHog's patterns where applicable.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.DEFAULT_WEB_VITALS_METRICS = exports.ALL_WEB_VITALS_METRICS = void 0;
|
|
10
|
-
/** All supported Web Vitals metrics */
|
|
11
|
-
exports.ALL_WEB_VITALS_METRICS = [
|
|
12
|
-
"LCP",
|
|
13
|
-
"CLS",
|
|
14
|
-
"FCP",
|
|
15
|
-
"INP",
|
|
16
|
-
"TTFB",
|
|
17
|
-
];
|
|
18
|
-
/** Default Web Vitals metrics (matches PostHog defaults) */
|
|
19
|
-
exports.DEFAULT_WEB_VITALS_METRICS = [
|
|
20
|
-
"LCP",
|
|
21
|
-
"CLS",
|
|
22
|
-
"FCP",
|
|
23
|
-
"INP",
|
|
24
|
-
];
|
package/lib/user-manager.d.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User Manager - Handles user identity and properties
|
|
3
|
-
*
|
|
4
|
-
* Uses shared StorageManager for consistent storage operations.
|
|
5
|
-
*
|
|
6
|
-
* Manages:
|
|
7
|
-
* - anonymous_id: Generated ID for anonymous users
|
|
8
|
-
* - distinct_id: User-provided ID after identification
|
|
9
|
-
* - device_id: Persistent device identifier
|
|
10
|
-
* - user_properties: Custom properties set via identify/setUserProperties
|
|
11
|
-
* - user_state: "anonymous" or "identified"
|
|
12
|
-
*/
|
|
13
|
-
import { UserIdentity, AliasEvent, PersistenceMethod } from "./types";
|
|
14
|
-
export declare class UserManager {
|
|
15
|
-
private storage;
|
|
16
|
-
private userIdentity;
|
|
17
|
-
private _cachedPersonProperties;
|
|
18
|
-
constructor(storageMethod?: PersistenceMethod, cross_subdomain?: boolean);
|
|
19
|
-
/**
|
|
20
|
-
* Get current user identity
|
|
21
|
-
*/
|
|
22
|
-
getUserIdentity(): UserIdentity;
|
|
23
|
-
/**
|
|
24
|
-
* Get current distinct ID (identified user ID)
|
|
25
|
-
*/
|
|
26
|
-
getDistinctId(): string | null;
|
|
27
|
-
/**
|
|
28
|
-
* Get current anonymous ID
|
|
29
|
-
*/
|
|
30
|
-
getAnonymousId(): string;
|
|
31
|
-
/**
|
|
32
|
-
* Get current user properties
|
|
33
|
-
*/
|
|
34
|
-
getUserProperties(): Record<string, any>;
|
|
35
|
-
/**
|
|
36
|
-
* Get the effective ID for event tracking
|
|
37
|
-
*/
|
|
38
|
-
getEffectiveId(): string;
|
|
39
|
-
/**
|
|
40
|
-
* Get current device ID
|
|
41
|
-
*/
|
|
42
|
-
getDeviceId(): string;
|
|
43
|
-
/**
|
|
44
|
-
* Get current user state
|
|
45
|
-
*/
|
|
46
|
-
getUserState(): "anonymous" | "identified";
|
|
47
|
-
/**
|
|
48
|
-
* Identify a user with distinct ID and properties
|
|
49
|
-
*/
|
|
50
|
-
identify(newDistinctId?: string, userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
|
|
51
|
-
/**
|
|
52
|
-
* Set user properties without changing distinct ID
|
|
53
|
-
*/
|
|
54
|
-
setUserProperties(userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Reset user identity (logout)
|
|
57
|
-
* Generates new anonymous ID, clears user data, optionally resets device ID
|
|
58
|
-
*/
|
|
59
|
-
reset(reset_device_id?: boolean): void;
|
|
60
|
-
/**
|
|
61
|
-
* Update distinct ID (internal use - for VTilt)
|
|
62
|
-
*/
|
|
63
|
-
setDistinctId(distinctId: string): void;
|
|
64
|
-
/**
|
|
65
|
-
* Update user state (internal use - for VTilt)
|
|
66
|
-
*/
|
|
67
|
-
setUserState(state: "anonymous" | "identified"): void;
|
|
68
|
-
/**
|
|
69
|
-
* Update user properties (internal use - for VTilt)
|
|
70
|
-
*/
|
|
71
|
-
updateUserProperties(userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
|
|
72
|
-
/**
|
|
73
|
-
* Set device ID if not already set (internal use - for VTilt)
|
|
74
|
-
*/
|
|
75
|
-
ensureDeviceId(deviceId: string): void;
|
|
76
|
-
/**
|
|
77
|
-
* Create an alias to link two distinct IDs
|
|
78
|
-
*/
|
|
79
|
-
createAlias(alias: string, original?: string): AliasEvent | null;
|
|
80
|
-
/**
|
|
81
|
-
* Check if distinct ID is string-like (hardcoded string) - public for validation
|
|
82
|
-
*/
|
|
83
|
-
isDistinctIdStringLikePublic(distinctId: string): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Set initial person info
|
|
86
|
-
*/
|
|
87
|
-
set_initial_person_info(maskPersonalDataProperties?: boolean, customPersonalDataProperties?: string[]): void;
|
|
88
|
-
/**
|
|
89
|
-
* Get initial props
|
|
90
|
-
*/
|
|
91
|
-
get_initial_props(): Record<string, any>;
|
|
92
|
-
/**
|
|
93
|
-
* Update referrer info
|
|
94
|
-
*/
|
|
95
|
-
update_referrer_info(): void;
|
|
96
|
-
/**
|
|
97
|
-
* Load user identity from storage.
|
|
98
|
-
*
|
|
99
|
-
* For traditional SSR websites where each page navigation reloads JavaScript,
|
|
100
|
-
* identity MUST be persisted immediately when generated to ensure the same
|
|
101
|
-
* anonymous_id is used across all page loads.
|
|
102
|
-
*
|
|
103
|
-
* Flow:
|
|
104
|
-
* 1. Load from storage (reads cookies first for critical properties in SSR mode)
|
|
105
|
-
* 2. Generate new IDs if not found
|
|
106
|
-
* 3. Immediately persist to storage (saved to both localStorage and cookies)
|
|
107
|
-
*
|
|
108
|
-
* With `localStorage+cookie` persistence (default):
|
|
109
|
-
* - Critical properties are stored in cookies for SSR compatibility
|
|
110
|
-
* - Full data is stored in localStorage for fast SPA-style access
|
|
111
|
-
* - Cookies ensure identity persists across full page reloads
|
|
112
|
-
*/
|
|
113
|
-
private loadUserIdentity;
|
|
114
|
-
/**
|
|
115
|
-
* Save user identity to storage
|
|
116
|
-
*/
|
|
117
|
-
private saveUserIdentity;
|
|
118
|
-
/**
|
|
119
|
-
* Get user properties from storage
|
|
120
|
-
*/
|
|
121
|
-
private getStoredUserProperties;
|
|
122
|
-
/**
|
|
123
|
-
* Set user properties in storage
|
|
124
|
-
*/
|
|
125
|
-
private setStoredUserProperties;
|
|
126
|
-
/**
|
|
127
|
-
* Register a value once (only if not already set)
|
|
128
|
-
*/
|
|
129
|
-
private register_once;
|
|
130
|
-
/**
|
|
131
|
-
* Generate a new anonymous ID
|
|
132
|
-
*/
|
|
133
|
-
private generateAnonymousId;
|
|
134
|
-
/**
|
|
135
|
-
* Generate a new device ID
|
|
136
|
-
*/
|
|
137
|
-
private generateDeviceId;
|
|
138
|
-
/**
|
|
139
|
-
* Get hash for person properties (for deduplication)
|
|
140
|
-
*/
|
|
141
|
-
private getPersonPropertiesHash;
|
|
142
|
-
/**
|
|
143
|
-
* Validate distinct ID
|
|
144
|
-
*/
|
|
145
|
-
private isValidDistinctId;
|
|
146
|
-
/**
|
|
147
|
-
* Check if distinct ID is string-like (hardcoded string)
|
|
148
|
-
*/
|
|
149
|
-
private isDistinctIdStringLike;
|
|
150
|
-
/**
|
|
151
|
-
* Update storage method at runtime
|
|
152
|
-
*/
|
|
153
|
-
updateStorageMethod(method: PersistenceMethod, cross_subdomain?: boolean): void;
|
|
154
|
-
}
|