@v-tilt/browser 1.6.0 → 1.7.2

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.
Files changed (107) hide show
  1. package/dist/array.full.js +1 -1
  2. package/dist/array.full.js.map +1 -1
  3. package/dist/array.js +1 -1
  4. package/dist/array.js.map +1 -1
  5. package/dist/array.no-external.js +1 -1
  6. package/dist/array.no-external.js.map +1 -1
  7. package/dist/chat.js +1 -1
  8. package/dist/chat.js.map +1 -1
  9. package/dist/constants.d.ts +1 -1
  10. package/dist/entrypoints/server.es.d.ts +12 -0
  11. package/dist/external-scripts-loader.js +1 -1
  12. package/dist/main.js +1 -1
  13. package/dist/main.js.map +1 -1
  14. package/dist/module.d.ts +6 -3
  15. package/dist/module.js +1 -1
  16. package/dist/module.js.map +1 -1
  17. package/dist/module.no-external.d.ts +6 -3
  18. package/dist/module.no-external.js +1 -1
  19. package/dist/module.no-external.js.map +1 -1
  20. package/dist/server.d.ts +105 -0
  21. package/dist/server.js +2 -0
  22. package/dist/server.js.map +1 -0
  23. package/dist/types.d.ts +3 -1
  24. package/dist/vtilt.d.ts +3 -2
  25. package/package.json +1 -2
  26. package/lib/config.d.ts +0 -17
  27. package/lib/config.js +0 -76
  28. package/lib/constants.d.ts +0 -178
  29. package/lib/constants.js +0 -656
  30. package/lib/entrypoints/all-external-dependencies.d.ts +0 -8
  31. package/lib/entrypoints/all-external-dependencies.js +0 -10
  32. package/lib/entrypoints/array.d.ts +0 -2
  33. package/lib/entrypoints/array.full.d.ts +0 -17
  34. package/lib/entrypoints/array.full.js +0 -19
  35. package/lib/entrypoints/array.js +0 -4
  36. package/lib/entrypoints/array.no-external.d.ts +0 -1
  37. package/lib/entrypoints/array.no-external.js +0 -4
  38. package/lib/entrypoints/chat.d.ts +0 -22
  39. package/lib/entrypoints/chat.js +0 -32
  40. package/lib/entrypoints/external-scripts-loader.d.ts +0 -24
  41. package/lib/entrypoints/external-scripts-loader.js +0 -104
  42. package/lib/entrypoints/main.cjs.d.ts +0 -4
  43. package/lib/entrypoints/main.cjs.js +0 -29
  44. package/lib/entrypoints/module.es.d.ts +0 -4
  45. package/lib/entrypoints/module.es.js +0 -23
  46. package/lib/entrypoints/module.no-external.es.d.ts +0 -4
  47. package/lib/entrypoints/module.no-external.es.js +0 -23
  48. package/lib/entrypoints/recorder.d.ts +0 -23
  49. package/lib/entrypoints/recorder.js +0 -42
  50. package/lib/entrypoints/web-vitals.d.ts +0 -14
  51. package/lib/entrypoints/web-vitals.js +0 -29
  52. package/lib/extensions/chat/chat-wrapper.d.ts +0 -196
  53. package/lib/extensions/chat/chat-wrapper.js +0 -545
  54. package/lib/extensions/chat/chat.d.ts +0 -99
  55. package/lib/extensions/chat/chat.js +0 -1891
  56. package/lib/extensions/chat/index.d.ts +0 -10
  57. package/lib/extensions/chat/index.js +0 -27
  58. package/lib/extensions/chat/types.d.ts +0 -159
  59. package/lib/extensions/chat/types.js +0 -22
  60. package/lib/extensions/history-autocapture.d.ts +0 -17
  61. package/lib/extensions/history-autocapture.js +0 -105
  62. package/lib/extensions/replay/index.d.ts +0 -13
  63. package/lib/extensions/replay/index.js +0 -31
  64. package/lib/extensions/replay/session-recording-utils.d.ts +0 -92
  65. package/lib/extensions/replay/session-recording-utils.js +0 -212
  66. package/lib/extensions/replay/session-recording-wrapper.d.ts +0 -61
  67. package/lib/extensions/replay/session-recording-wrapper.js +0 -149
  68. package/lib/extensions/replay/session-recording.d.ts +0 -95
  69. package/lib/extensions/replay/session-recording.js +0 -700
  70. package/lib/extensions/replay/types.d.ts +0 -211
  71. package/lib/extensions/replay/types.js +0 -8
  72. package/lib/geolocation.d.ts +0 -5
  73. package/lib/geolocation.js +0 -31
  74. package/lib/rate-limiter.d.ts +0 -52
  75. package/lib/rate-limiter.js +0 -80
  76. package/lib/request-queue.d.ts +0 -78
  77. package/lib/request-queue.js +0 -156
  78. package/lib/request.d.ts +0 -54
  79. package/lib/request.js +0 -265
  80. package/lib/retry-queue.d.ts +0 -64
  81. package/lib/retry-queue.js +0 -182
  82. package/lib/session.d.ts +0 -66
  83. package/lib/session.js +0 -191
  84. package/lib/storage.d.ts +0 -117
  85. package/lib/storage.js +0 -438
  86. package/lib/types.d.ts +0 -350
  87. package/lib/types.js +0 -24
  88. package/lib/user-manager.d.ts +0 -154
  89. package/lib/user-manager.js +0 -589
  90. package/lib/utils/event-utils.d.ts +0 -52
  91. package/lib/utils/event-utils.js +0 -305
  92. package/lib/utils/globals.d.ts +0 -235
  93. package/lib/utils/globals.js +0 -30
  94. package/lib/utils/index.d.ts +0 -46
  95. package/lib/utils/index.js +0 -134
  96. package/lib/utils/patch.d.ts +0 -6
  97. package/lib/utils/patch.js +0 -39
  98. package/lib/utils/request-utils.d.ts +0 -17
  99. package/lib/utils/request-utils.js +0 -80
  100. package/lib/utils/type-utils.d.ts +0 -4
  101. package/lib/utils/type-utils.js +0 -9
  102. package/lib/utils/user-agent-utils.d.ts +0 -18
  103. package/lib/utils/user-agent-utils.js +0 -411
  104. package/lib/vtilt.d.ts +0 -359
  105. package/lib/vtilt.js +0 -1188
  106. package/lib/web-vitals.d.ts +0 -95
  107. package/lib/web-vitals.js +0 -380
package/lib/vtilt.d.ts DELETED
@@ -1,359 +0,0 @@
1
- import { VTiltConfig, EventPayload } from "./types";
2
- import { HistoryAutocapture } from "./extensions/history-autocapture";
3
- import { SessionRecordingWrapper } from "./extensions/replay";
4
- import { ChatWrapper } from "./extensions/chat/chat-wrapper";
5
- import { type QueuedRequest } from "./request-queue";
6
- export declare class VTilt {
7
- readonly version = "1.6.0";
8
- private configManager;
9
- private sessionManager;
10
- private userManager;
11
- private webVitalsManager;
12
- private requestQueue;
13
- private retryQueue;
14
- private rateLimiter;
15
- historyAutocapture?: HistoryAutocapture;
16
- sessionRecording?: SessionRecordingWrapper;
17
- chat?: ChatWrapper;
18
- __loaded: boolean;
19
- private _initial_pageview_captured;
20
- private _visibility_state_listener;
21
- __request_queue: QueuedRequest[];
22
- private _has_warned_about_config;
23
- private _set_once_properties_sent;
24
- private _remoteConfig;
25
- constructor(config?: Partial<VTiltConfig>);
26
- /**
27
- * Initializes a new instance of the VTilt tracking object.
28
- *
29
- * @remarks
30
- * All new instances are added to the main vt object as sub properties (such as
31
- * `vt.library_name`) and also returned by this function.
32
- *
33
- * @example
34
- * ```js
35
- * // basic initialization
36
- * vt.init('<project_id>', {
37
- * api_host: '<client_api_host>'
38
- * })
39
- * ```
40
- *
41
- * @example
42
- * ```js
43
- * // multiple instances
44
- * vt.init('<project_id>', {}, 'project1')
45
- * vt.init('<project_id>', {}, 'project2')
46
- * ```
47
- *
48
- * @public
49
- *
50
- * @param projectId - Your VTilt project ID
51
- * @param config - A dictionary of config options to override
52
- * @param name - The name for the new VTilt instance that you want created
53
- *
54
- * @returns The newly initialized VTilt instance
55
- */
56
- init(projectId: string, config?: Partial<VTiltConfig>, name?: string): VTilt;
57
- /**
58
- * Handles the actual initialization logic for a VTilt instance.
59
- * This internal method should only be called by `init()`.
60
- */
61
- private _init;
62
- /**
63
- * Start the request queue if user hasn't opted out
64
- * Following PostHog's pattern - called from both _init() and _dom_loaded()
65
- * Safe to call multiple times as enable() is idempotent
66
- */
67
- private _start_queue_if_opted_in;
68
- /**
69
- * Set up handler to flush event queue on page unload
70
- * Uses both beforeunload and pagehide for maximum compatibility
71
- */
72
- private _setup_unload_handler;
73
- /**
74
- * Load remote config from cache and fetch fresh in background.
75
- * Uses sessionStorage for per-session caching.
76
- * Local config always overrides remote config.
77
- */
78
- private _loadRemoteConfig;
79
- /**
80
- * Fetch remote config from /decide endpoint.
81
- * Caches response in sessionStorage.
82
- */
83
- private _fetchRemoteConfig;
84
- /**
85
- * Apply remote config to current config.
86
- * Local config takes precedence over remote.
87
- */
88
- private _applyRemoteConfig;
89
- /**
90
- * Returns a string representation of the instance name
91
- * Used for debugging and logging
92
- *
93
- * @internal
94
- */
95
- toString(): string;
96
- /**
97
- * Get current domain from location
98
- * Returns full URL format for consistency with dashboard
99
- */
100
- private getCurrentDomain;
101
- /**
102
- * Check if tracking is properly configured
103
- * Returns true if projectId and token are present, false otherwise
104
- * Logs a warning only once per instance if not configured
105
- */
106
- private _is_configured;
107
- /**
108
- * Build the tracking URL with token in query parameters
109
- */
110
- private buildUrl;
111
- /**
112
- * Send HTTP request
113
- * This is the central entry point for all tracking requests
114
- * Events are batched and sent every 3 seconds for better performance
115
- */
116
- private sendRequest;
117
- /**
118
- * Send a batched request with multiple events
119
- * Called by RequestQueue when flushing
120
- * Uses RetryQueue for automatic retry on failure
121
- */
122
- private _send_batched_request;
123
- /**
124
- * Send HTTP request and return status code
125
- * Uses GZip compression for payloads > 1KB
126
- * Used by RetryQueue for retryable requests
127
- */
128
- private _send_http_request;
129
- /**
130
- * Send request using sendBeacon for reliable delivery on page unload
131
- * Uses GZip compression for payloads > 1KB
132
- */
133
- private _send_beacon_request;
134
- /**
135
- * Send a queued request (called after DOM is loaded)
136
- */
137
- _send_retriable_request(item: QueuedRequest): void;
138
- /**
139
- * Capture an event
140
- * Automatically adds common properties to all events
141
- * ($current_url, $host, $pathname, $referrer, $referring_domain, $browser, $os, $device, $timezone, etc.)
142
- * Only properties in EVENT_TO_PERSON_PROPERTIES are copied to person properties
143
- * Also adds title property for $pageview events only
144
- *
145
- * @param name - Event name
146
- * @param payload - Event payload
147
- * @param options - Optional capture options
148
- */
149
- capture(name: string, payload: EventPayload, options?: {
150
- skip_client_rate_limiting?: boolean;
151
- }): void;
152
- /**
153
- * Internal capture method that bypasses rate limiting
154
- * Used for system events like rate limit warnings
155
- */
156
- private _capture_internal;
157
- /**
158
- * Track a custom event (alias for capture)
159
- */
160
- trackEvent(name: string, payload?: EventPayload): void;
161
- /**
162
- * Identify a user with property operations
163
- * Sends $identify event when transitioning from anonymous to identified
164
- * Event's distinct_id is the previous/anonymous ID, new distinct_id is in payload
165
- *
166
- * @example
167
- * ```js
168
- * // Basic identify with properties
169
- * vTilt.identify('user_123',
170
- * { name: 'John Doe', email: 'john@example.com' }, // $set properties
171
- * { first_login: new Date().toISOString() } // $set_once properties
172
- * )
173
- * ```
174
- *
175
- * @example
176
- * ```js
177
- * // If no $set is provided, all properties are treated as $set
178
- * vTilt.identify('user_123', { name: 'John Doe', email: 'john@example.com' })
179
- * ```
180
- */
181
- identify(newDistinctId?: string, userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
182
- /**
183
- * Set user properties
184
- * Sets properties on the person profile associated with the current distinct_id
185
- *
186
- * @example
187
- * ```js
188
- * // Set properties that can be updated
189
- * vTilt.setUserProperties({ name: 'John Doe', email: 'john@example.com' })
190
- * ```
191
- *
192
- * @example
193
- * ```js
194
- * // Set properties with $set and $set_once operations
195
- * vTilt.setUserProperties(
196
- * { name: 'John Doe', last_login: new Date().toISOString() }, // $set properties
197
- * { first_login: new Date().toISOString() } // $set_once properties
198
- * )
199
- * ```
200
- *
201
- * @param userPropertiesToSet Optional: Properties to set (can be updated)
202
- * @param userPropertiesToSetOnce Optional: Properties to set once (preserves first value)
203
- */
204
- setUserProperties(userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
205
- /**
206
- * Reset user identity (logout)
207
- * Clears all user data, generates new anonymous ID, resets session
208
- *
209
- * @param reset_device_id - If true, also resets device_id. Default: false
210
- *
211
- * @example
212
- * // Reset on user logout
213
- * vtilt.resetUser()
214
- *
215
- * @example
216
- * // Reset and generate new device ID
217
- * vtilt.resetUser(true)
218
- */
219
- resetUser(reset_device_id?: boolean): void;
220
- /**
221
- * Get current user identity
222
- */
223
- getUserIdentity(): import("./types").UserIdentity;
224
- /**
225
- * Get current device ID
226
- */
227
- getDeviceId(): string;
228
- /**
229
- * Get current user state
230
- */
231
- getUserState(): "anonymous" | "identified";
232
- /**
233
- * Create an alias to link two distinct IDs
234
- * Links anonymous session to account on signup
235
- *
236
- * @param alias - A unique identifier that you want to use for this user in the future
237
- * @param original - The current identifier being used for this user (optional, defaults to current distinct_id)
238
- *
239
- * @example
240
- * // Link anonymous user to account on signup
241
- * vtilt.createAlias('user_12345')
242
- *
243
- * @example
244
- * // Explicit alias with original ID
245
- * vtilt.createAlias('user_12345', 'anonymous_abc123')
246
- */
247
- createAlias(alias: string, original?: string): void;
248
- /**
249
- * Capture initial pageview with visibility check
250
- * Note: The capture_pageview config check happens at the call site (in _init)
251
- */
252
- private _capture_initial_pageview;
253
- /**
254
- * Get current configuration
255
- */
256
- getConfig(): VTiltConfig;
257
- /**
258
- * Get current session ID
259
- */
260
- getSessionId(): string | null;
261
- /**
262
- * Get current distinct ID
263
- */
264
- getDistinctId(): string;
265
- /**
266
- * Get anonymous ID
267
- */
268
- getAnonymousId(): string;
269
- /**
270
- * Update configuration
271
- */
272
- updateConfig(config: Partial<VTiltConfig>): void;
273
- /**
274
- * Initialize session recording
275
- */
276
- private _initSessionRecording;
277
- /**
278
- * Build session recording config from VTiltConfig
279
- */
280
- private _buildSessionRecordingConfig;
281
- /**
282
- * Start session recording
283
- * Call this to manually start recording if it wasn't enabled initially
284
- */
285
- startSessionRecording(): void;
286
- /**
287
- * Stop session recording
288
- */
289
- stopSessionRecording(): void;
290
- /**
291
- * Check if session recording is active
292
- */
293
- isRecordingActive(): boolean;
294
- /**
295
- * Get session recording ID
296
- */
297
- getSessionRecordingId(): string | null;
298
- /**
299
- * Initialize chat widget
300
- */
301
- private _initChat;
302
- /**
303
- * Build chat config from VTiltConfig
304
- */
305
- private _buildChatConfig;
306
- /**
307
- * _execute_array() deals with processing any vTilt function
308
- * calls that were called before the vTilt library was loaded
309
- * (and are thus stored in an array so they can be called later)
310
- *
311
- * Note: we fire off all the vTilt function calls BEFORE we fire off
312
- * tracking calls. This is so identify/setUserProperties/updateConfig calls
313
- * can properly modify early tracking calls.
314
- *
315
- * @param {Array} array Array of queued calls in format [methodName, ...args]
316
- */
317
- _execute_array(array: any[]): void;
318
- /**
319
- * Called when DOM is loaded - processes queued requests and enables batching
320
- * Following PostHog's pattern in _dom_loaded()
321
- */
322
- _dom_loaded(): void;
323
- }
324
- /**
325
- * Initialize vTilt as a module
326
- * Returns an uninitialized vTilt instance that the user must call init() on
327
- */
328
- export declare function init_as_module(): VTilt;
329
- /**
330
- * Initialize vTilt from snippet
331
- * Processes queued calls from the snippet stub and replaces it with real instance
332
- *
333
- * The snippet uses some clever tricks to allow deferred loading of array.js (this code)
334
- *
335
- * window.vt is an array which the queue of calls made before the lib is loaded
336
- * It has methods attached to it to simulate the vt object so for instance
337
- *
338
- * window.vt.init("projectId", {token: "token", host: "host"})
339
- * window.vt.trackEvent("my-event", {foo: "bar"})
340
- *
341
- * ... will mean that window.vt will look like this:
342
- * window.vt == [
343
- * ["trackEvent", "my-event", {foo: "bar"}]
344
- * ]
345
- *
346
- * window.vt._i == [
347
- * ["projectId", {token: "token", host: "host"}, "vt"]
348
- * ]
349
- *
350
- * If a name is given to the init function then the same as above is true but as a sub-property on the object:
351
- *
352
- * window.vt.init("projectId", {token: "token"}, "vt2")
353
- * window.vt.vt2.trackEvent("my-event", {foo: "bar"})
354
- *
355
- * window.vt.vt2 == [
356
- * ["trackEvent", "my-event", {foo: "bar"}]
357
- * ]
358
- */
359
- export declare function init_from_snippet(): void;