@v-tilt/browser 1.2.0 → 1.4.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/all-external-dependencies.js +2 -0
- package/dist/all-external-dependencies.js.map +1 -0
- package/dist/array.full.js +2 -0
- package/dist/array.full.js.map +1 -0
- 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 +2 -0
- package/dist/chat.js.map +1 -0
- package/dist/entrypoints/all-external-dependencies.d.ts +8 -0
- package/dist/entrypoints/array.full.d.ts +17 -0
- package/dist/entrypoints/chat.d.ts +22 -0
- package/dist/entrypoints/web-vitals.d.ts +14 -0
- package/dist/extensions/chat/chat-wrapper.d.ts +172 -0
- package/dist/extensions/chat/chat.d.ts +87 -0
- package/dist/extensions/chat/index.d.ts +10 -0
- package/dist/extensions/chat/types.d.ts +156 -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 +312 -5
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +312 -5
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/types.d.ts +59 -2
- package/dist/utils/globals.d.ts +138 -1
- package/dist/vtilt.d.ts +11 -1
- package/dist/web-vitals.d.ts +89 -5
- package/dist/web-vitals.js +2 -0
- package/dist/web-vitals.js.map +1 -0
- package/lib/config.js +5 -3
- package/lib/entrypoints/all-external-dependencies.d.ts +8 -0
- package/lib/entrypoints/all-external-dependencies.js +10 -0
- package/lib/entrypoints/array.full.d.ts +17 -0
- package/lib/entrypoints/array.full.js +19 -0
- package/lib/entrypoints/chat.d.ts +22 -0
- package/lib/entrypoints/chat.js +32 -0
- package/lib/entrypoints/external-scripts-loader.js +1 -1
- package/lib/entrypoints/web-vitals.d.ts +14 -0
- package/lib/entrypoints/web-vitals.js +29 -0
- package/lib/extensions/chat/chat-wrapper.d.ts +172 -0
- package/lib/extensions/chat/chat-wrapper.js +497 -0
- package/lib/extensions/chat/chat.d.ts +87 -0
- package/lib/extensions/chat/chat.js +998 -0
- package/lib/extensions/chat/index.d.ts +10 -0
- package/lib/extensions/chat/index.js +27 -0
- package/lib/extensions/chat/types.d.ts +156 -0
- package/lib/extensions/chat/types.js +22 -0
- package/lib/types.d.ts +59 -2
- package/lib/types.js +16 -0
- package/lib/utils/globals.d.ts +138 -1
- package/lib/vtilt.d.ts +11 -1
- package/lib/vtilt.js +42 -1
- package/lib/web-vitals.d.ts +89 -5
- package/lib/web-vitals.js +354 -46
- package/package.json +66 -65
package/dist/types.d.ts
CHANGED
|
@@ -51,8 +51,11 @@ export interface VTiltConfig {
|
|
|
51
51
|
person_profiles?: PersonProfilesMode;
|
|
52
52
|
/** Enable autocapture */
|
|
53
53
|
autocapture?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Enable web vitals tracking.
|
|
56
|
+
* Can be a boolean or an object with detailed configuration.
|
|
57
|
+
*/
|
|
58
|
+
capture_performance?: boolean | CapturePerformanceConfig;
|
|
56
59
|
/** Enable page view tracking */
|
|
57
60
|
capture_pageview?: boolean | "auto";
|
|
58
61
|
/** Enable page leave tracking */
|
|
@@ -75,6 +78,10 @@ export interface VTiltConfig {
|
|
|
75
78
|
session_recording?: SessionRecordingOptions;
|
|
76
79
|
/** Disable session recording (convenience flag) */
|
|
77
80
|
disable_session_recording?: boolean;
|
|
81
|
+
/** Chat widget configuration */
|
|
82
|
+
chat?: ChatWidgetConfig;
|
|
83
|
+
/** Disable chat (convenience flag) */
|
|
84
|
+
disable_chat?: boolean;
|
|
78
85
|
/** Global attributes added to all events */
|
|
79
86
|
globalAttributes?: Record<string, string>;
|
|
80
87
|
/** Bootstrap data for initialization */
|
|
@@ -160,6 +167,29 @@ export interface AliasEvent {
|
|
|
160
167
|
distinct_id: string;
|
|
161
168
|
original: string;
|
|
162
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
|
+
}
|
|
163
193
|
export interface WebVitalMetric {
|
|
164
194
|
name: string;
|
|
165
195
|
value: number;
|
|
@@ -167,6 +197,10 @@ export interface WebVitalMetric {
|
|
|
167
197
|
rating: "good" | "needs-improvement" | "poor";
|
|
168
198
|
id: string;
|
|
169
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>;
|
|
170
204
|
}
|
|
171
205
|
export interface GeolocationData {
|
|
172
206
|
country?: string;
|
|
@@ -259,6 +293,29 @@ export interface SessionRecordingOptions {
|
|
|
259
293
|
/** Internal: Mutation throttler bucket size */
|
|
260
294
|
__mutationThrottlerBucketSize?: number;
|
|
261
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
|
+
}
|
|
262
319
|
export interface RemoteConfig {
|
|
263
320
|
/** Default to identified_only mode */
|
|
264
321
|
defaultIdentifiedOnly?: boolean;
|
package/dist/utils/globals.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ declare const win: (Window & typeof globalThis) | undefined;
|
|
|
2
2
|
/**
|
|
3
3
|
* Extension kinds that can be lazy loaded
|
|
4
4
|
*/
|
|
5
|
-
export type VTiltExtensionKind = "recorder" | "web-vitals";
|
|
5
|
+
export type VTiltExtensionKind = "recorder" | "web-vitals" | "chat";
|
|
6
6
|
/**
|
|
7
7
|
* Interface for lazy-loaded session recording (set by recorder.ts)
|
|
8
8
|
* Matches LazyLoadedSessionRecordingInterface in session-recording-wrapper.ts
|
|
@@ -17,6 +17,139 @@ export interface LazyLoadedSessionRecordingInterface {
|
|
|
17
17
|
log: (message: string, level: "log" | "warn" | "error") => void;
|
|
18
18
|
updateConfig: (config: any) => void;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Web Vitals metric callback type
|
|
22
|
+
*/
|
|
23
|
+
export type WebVitalsMetricCallback = (metric: any) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Options for web vitals callbacks
|
|
26
|
+
*/
|
|
27
|
+
export interface WebVitalsCallbackOptions {
|
|
28
|
+
/** Report all changes (useful for CLS which updates over time) */
|
|
29
|
+
reportAllChanges?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Web Vitals callback function type (with optional options)
|
|
33
|
+
*/
|
|
34
|
+
export type WebVitalsCallbackFn = (callback: WebVitalsMetricCallback, options?: WebVitalsCallbackOptions) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Web Vitals callbacks interface (set by web-vitals.ts entrypoint)
|
|
37
|
+
*/
|
|
38
|
+
export interface WebVitalsCallbacks {
|
|
39
|
+
onLCP: WebVitalsCallbackFn;
|
|
40
|
+
onCLS: WebVitalsCallbackFn;
|
|
41
|
+
onFCP: WebVitalsCallbackFn;
|
|
42
|
+
onINP: WebVitalsCallbackFn;
|
|
43
|
+
onTTFB?: WebVitalsCallbackFn;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Chat message structure (matches PostgreSQL chat_messages table)
|
|
47
|
+
* Note: Read status is determined by cursor comparison, not per-message
|
|
48
|
+
*/
|
|
49
|
+
export interface ChatMessage {
|
|
50
|
+
id: string;
|
|
51
|
+
channel_id: string;
|
|
52
|
+
sender_type: "user" | "agent" | "ai" | "system";
|
|
53
|
+
sender_id: string | null;
|
|
54
|
+
sender_name: string | null;
|
|
55
|
+
sender_avatar_url: string | null;
|
|
56
|
+
content: string;
|
|
57
|
+
content_type: "text" | "html" | "attachment";
|
|
58
|
+
metadata: Record<string, unknown>;
|
|
59
|
+
created_at: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Chat channel structure (maps 1:1 to Ably channel)
|
|
63
|
+
*/
|
|
64
|
+
export interface ChatChannel {
|
|
65
|
+
id: string;
|
|
66
|
+
project_id: string;
|
|
67
|
+
person_id: string;
|
|
68
|
+
distinct_id: string;
|
|
69
|
+
status: "open" | "closed" | "snoozed";
|
|
70
|
+
ai_mode: boolean;
|
|
71
|
+
unread_count: number;
|
|
72
|
+
last_message_at: string | null;
|
|
73
|
+
last_message_preview: string | null;
|
|
74
|
+
last_message_sender: "user" | "agent" | "ai" | "system" | null;
|
|
75
|
+
user_last_read_at: string | null;
|
|
76
|
+
agent_last_read_at: string | null;
|
|
77
|
+
created_at: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Chat widget configuration
|
|
81
|
+
*
|
|
82
|
+
* Settings can come from two sources:
|
|
83
|
+
* 1. Dashboard (fetched from /api/chat/settings) - "snippet-only" mode
|
|
84
|
+
* 2. Code config (passed to vt.init) - overrides dashboard settings
|
|
85
|
+
*
|
|
86
|
+
* This enables Intercom-like flexibility: just add snippet OR customize with code.
|
|
87
|
+
*/
|
|
88
|
+
export interface ChatConfig {
|
|
89
|
+
/**
|
|
90
|
+
* Enable/disable chat widget.
|
|
91
|
+
* - undefined: Use dashboard setting (auto-fetch)
|
|
92
|
+
* - true: Enable (override dashboard)
|
|
93
|
+
* - false: Disable entirely
|
|
94
|
+
*/
|
|
95
|
+
enabled?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Auto-fetch settings from dashboard (default: true)
|
|
98
|
+
* When true, SDK fetches /api/chat/settings and uses those as base config.
|
|
99
|
+
* Code config always overrides fetched settings.
|
|
100
|
+
*/
|
|
101
|
+
autoConfig?: boolean;
|
|
102
|
+
/** Widget position (default: 'bottom-right') */
|
|
103
|
+
position?: "bottom-right" | "bottom-left";
|
|
104
|
+
/** Widget header/greeting message */
|
|
105
|
+
greeting?: string;
|
|
106
|
+
/** Widget primary color */
|
|
107
|
+
color?: string;
|
|
108
|
+
/** Start in AI mode (default: true) */
|
|
109
|
+
aiMode?: boolean;
|
|
110
|
+
/** AI greeting message (first message from AI) */
|
|
111
|
+
aiGreeting?: string;
|
|
112
|
+
/** Preload widget script on idle vs on-demand */
|
|
113
|
+
preload?: boolean;
|
|
114
|
+
/** Custom theme */
|
|
115
|
+
theme?: ChatTheme;
|
|
116
|
+
/** Offline message shown when business is unavailable */
|
|
117
|
+
offlineMessage?: string;
|
|
118
|
+
/** Collect email when offline */
|
|
119
|
+
collectEmailOffline?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Chat theme customization
|
|
123
|
+
*/
|
|
124
|
+
export interface ChatTheme {
|
|
125
|
+
primaryColor?: string;
|
|
126
|
+
fontFamily?: string;
|
|
127
|
+
borderRadius?: string;
|
|
128
|
+
headerBgColor?: string;
|
|
129
|
+
userBubbleColor?: string;
|
|
130
|
+
agentBubbleColor?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Interface for lazy-loaded chat widget (set by chat.ts entrypoint)
|
|
134
|
+
*/
|
|
135
|
+
export interface LazyLoadedChatInterface {
|
|
136
|
+
readonly isOpen: boolean;
|
|
137
|
+
readonly isConnected: boolean;
|
|
138
|
+
readonly isLoading: boolean;
|
|
139
|
+
readonly unreadCount: number;
|
|
140
|
+
readonly channel: ChatChannel | null;
|
|
141
|
+
open(): void;
|
|
142
|
+
close(): void;
|
|
143
|
+
toggle(): void;
|
|
144
|
+
show(): void;
|
|
145
|
+
hide(): void;
|
|
146
|
+
sendMessage(content: string): Promise<void>;
|
|
147
|
+
markAsRead(): void;
|
|
148
|
+
onMessage(callback: (message: ChatMessage) => void): () => void;
|
|
149
|
+
onTyping(callback: (isTyping: boolean, senderType: string) => void): () => void;
|
|
150
|
+
onConnectionChange(callback: (connected: boolean) => void): () => void;
|
|
151
|
+
destroy(): void;
|
|
152
|
+
}
|
|
20
153
|
/**
|
|
21
154
|
* VTilt Extensions interface for dynamically loaded modules
|
|
22
155
|
* This is the contract between lazily loaded extensions and the SDK
|
|
@@ -37,6 +170,10 @@ export interface VTiltExtensions {
|
|
|
37
170
|
};
|
|
38
171
|
/** Factory to create LazyLoadedSessionRecording (set by recorder.ts) */
|
|
39
172
|
initSessionRecording?: (instance: any, config?: any) => LazyLoadedSessionRecordingInterface;
|
|
173
|
+
/** Web Vitals callbacks (set by web-vitals.ts entrypoint) */
|
|
174
|
+
webVitalsCallbacks?: WebVitalsCallbacks;
|
|
175
|
+
/** Factory to create LazyLoadedChat (set by chat.ts entrypoint) */
|
|
176
|
+
initChat?: (instance: any, config?: ChatConfig) => LazyLoadedChatInterface;
|
|
40
177
|
}
|
|
41
178
|
export type AssignableWindow = Window & typeof globalThis & {
|
|
42
179
|
/** Main VTilt instance */
|
package/dist/vtilt.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VTiltConfig, EventPayload } from "./types";
|
|
2
2
|
import { HistoryAutocapture } from "./extensions/history-autocapture";
|
|
3
3
|
import { SessionRecordingWrapper } from "./extensions/replay";
|
|
4
|
+
import { ChatWrapper } from "./extensions/chat/chat-wrapper";
|
|
4
5
|
import { type QueuedRequest } from "./request-queue";
|
|
5
6
|
export declare class VTilt {
|
|
6
7
|
readonly version = "1.1.5";
|
|
@@ -13,6 +14,7 @@ export declare class VTilt {
|
|
|
13
14
|
private rateLimiter;
|
|
14
15
|
historyAutocapture?: HistoryAutocapture;
|
|
15
16
|
sessionRecording?: SessionRecordingWrapper;
|
|
17
|
+
chat?: ChatWrapper;
|
|
16
18
|
__loaded: boolean;
|
|
17
19
|
private _initial_pageview_captured;
|
|
18
20
|
private _visibility_state_listener;
|
|
@@ -271,11 +273,19 @@ export declare class VTilt {
|
|
|
271
273
|
/**
|
|
272
274
|
* Check if session recording is active
|
|
273
275
|
*/
|
|
274
|
-
|
|
276
|
+
isRecordingActive(): boolean;
|
|
275
277
|
/**
|
|
276
278
|
* Get session recording ID
|
|
277
279
|
*/
|
|
278
280
|
getSessionRecordingId(): string | null;
|
|
281
|
+
/**
|
|
282
|
+
* Initialize chat widget
|
|
283
|
+
*/
|
|
284
|
+
private _initChat;
|
|
285
|
+
/**
|
|
286
|
+
* Build chat config from VTiltConfig
|
|
287
|
+
*/
|
|
288
|
+
private _buildChatConfig;
|
|
279
289
|
/**
|
|
280
290
|
* _execute_array() deals with processing any vTilt function
|
|
281
291
|
* calls that were called before the vTilt library was loaded
|
package/dist/web-vitals.d.ts
CHANGED
|
@@ -1,11 +1,95 @@
|
|
|
1
|
-
import { VTiltConfig } from "./types";
|
|
1
|
+
import { VTiltConfig, SupportedWebVitalsMetric } from "./types";
|
|
2
2
|
import { VTilt } from "./vtilt";
|
|
3
|
+
/**
|
|
4
|
+
* Web Vitals Manager
|
|
5
|
+
*
|
|
6
|
+
* Captures Core Web Vitals (LCP, CLS, FCP, INP, TTFB) and sends them
|
|
7
|
+
* as batched $web_vitals events. Follows PostHog's approach with:
|
|
8
|
+
*
|
|
9
|
+
* 1. Extension pattern - checks for callbacks registered on __VTiltExtensions__
|
|
10
|
+
* 2. Lazy loading - loads web-vitals.js on demand if not bundled
|
|
11
|
+
* 3. Configurable metrics - choose which metrics to capture
|
|
12
|
+
* 4. Smart buffering - collects metrics per page, flushes on navigation or timeout
|
|
13
|
+
* 5. Session context - includes session_id and window_id for correlation
|
|
14
|
+
*
|
|
15
|
+
* Event structure:
|
|
16
|
+
* - event: "$web_vitals"
|
|
17
|
+
* - properties:
|
|
18
|
+
* - $web_vitals_LCP_value: number
|
|
19
|
+
* - $web_vitals_LCP_event: { name, value, delta, rating, ... }
|
|
20
|
+
* - $pathname: string
|
|
21
|
+
* - $current_url: string
|
|
22
|
+
*/
|
|
3
23
|
export declare class WebVitalsManager {
|
|
4
24
|
private instance;
|
|
5
|
-
private
|
|
6
|
-
|
|
25
|
+
private buffer;
|
|
26
|
+
private flushTimer;
|
|
27
|
+
private initialized;
|
|
28
|
+
private config;
|
|
29
|
+
constructor(vtiltConfig: VTiltConfig, instance: VTilt);
|
|
7
30
|
/**
|
|
8
|
-
*
|
|
31
|
+
* Parse capture_performance config (boolean or object)
|
|
9
32
|
*/
|
|
10
|
-
private
|
|
33
|
+
private parseConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Check if web vitals capture is enabled
|
|
36
|
+
*/
|
|
37
|
+
get isEnabled(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get the list of metrics to capture
|
|
40
|
+
*/
|
|
41
|
+
get allowedMetrics(): SupportedWebVitalsMetric[];
|
|
42
|
+
/**
|
|
43
|
+
* Get flush timeout in ms
|
|
44
|
+
*/
|
|
45
|
+
get flushTimeoutMs(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Get maximum allowed metric value
|
|
48
|
+
*/
|
|
49
|
+
get maxAllowedValue(): number;
|
|
50
|
+
private createEmptyBuffer;
|
|
51
|
+
/**
|
|
52
|
+
* Check if web vitals callbacks are available
|
|
53
|
+
*/
|
|
54
|
+
private getWebVitalsCallbacks;
|
|
55
|
+
/**
|
|
56
|
+
* Start capturing if enabled and callbacks are available
|
|
57
|
+
*/
|
|
58
|
+
startIfEnabled(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Lazy load web-vitals extension
|
|
61
|
+
*/
|
|
62
|
+
private loadWebVitals;
|
|
63
|
+
/**
|
|
64
|
+
* Start capturing web vitals using the provided callbacks
|
|
65
|
+
*/
|
|
66
|
+
private startCapturing;
|
|
67
|
+
/**
|
|
68
|
+
* Get current URL
|
|
69
|
+
*/
|
|
70
|
+
private getCurrentUrl;
|
|
71
|
+
/**
|
|
72
|
+
* Get current pathname
|
|
73
|
+
*/
|
|
74
|
+
private getCurrentPathname;
|
|
75
|
+
/**
|
|
76
|
+
* Add a metric to the buffer
|
|
77
|
+
*/
|
|
78
|
+
private addToBuffer;
|
|
79
|
+
/**
|
|
80
|
+
* Clean attribution data by removing large elements
|
|
81
|
+
*/
|
|
82
|
+
private cleanAttribution;
|
|
83
|
+
/**
|
|
84
|
+
* Get window ID from instance
|
|
85
|
+
*/
|
|
86
|
+
private getWindowId;
|
|
87
|
+
/**
|
|
88
|
+
* Schedule a delayed flush
|
|
89
|
+
*/
|
|
90
|
+
private scheduleFlush;
|
|
91
|
+
/**
|
|
92
|
+
* Flush buffered metrics as a single event
|
|
93
|
+
*/
|
|
94
|
+
private flush;
|
|
11
95
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(){"use strict";var n,e=-1,t=function(n){addEventListener("pageshow",function(t){t.persisted&&(e=t.timeStamp,n(t))},!0)},i=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},r=function(){var n=i();return n&&n.activationStart||0},o=function(n,t){var o=i(),u="navigate";return e>=0?u="back-forward-cache":o&&(document.prerendering||r()>0?u="prerender":document.wasDiscarded?u="restore":o.type&&(u=o.type.replace(/_/g,"-"))),{name:n,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:u}},u=function(n,e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var i=new PerformanceObserver(function(n){Promise.resolve().then(function(){e(n.getEntries())})});return i.observe(Object.assign({type:n,buffered:!0},t||{})),i}}catch(n){}},c=function(n,e,t,i){var r,o;return function(u){e.value>=0&&(u||i)&&((o=e.value-(r||0))||void 0===r)&&(r=e.value,e.delta=o,e.rating=function(n,e){return n>e[1]?"poor":n>e[0]?"needs-improvement":"good"}(e.value,t),n(e))}},f=function(n){requestAnimationFrame(function(){return requestAnimationFrame(function(){return n()})})},a=function(n){var e=function(e){"pagehide"!==e.type&&"hidden"!==document.visibilityState||n(e)};addEventListener("visibilitychange",e,!0),addEventListener("pagehide",e,!0)},d=function(n){var e=!1;return function(t){e||(n(t),e=!0)}},v=-1,s=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},l=function(n){"hidden"===document.visibilityState&&v>-1&&(v="visibilitychange"===n.type?n.timeStamp:0,h())},m=function(){addEventListener("visibilitychange",l,!0),addEventListener("prerenderingchange",l,!0)},h=function(){removeEventListener("visibilitychange",l,!0),removeEventListener("prerenderingchange",l,!0)},p=function(){return v<0&&(v=s(),m(),t(function(){setTimeout(function(){v=s(),m()},0)})),{get firstHiddenTime(){return v}}},g=function(n){document.prerendering?addEventListener("prerenderingchange",function(){return n()},!0):n()},T=[1800,3e3],L=function(n,e){e=e||{},g(function(){var i,a=p(),d=o("FCP"),v=u("paint",function(n){n.forEach(function(n){"first-contentful-paint"===n.name&&(v.disconnect(),n.startTime<a.firstHiddenTime&&(d.value=Math.max(n.startTime-r(),0),d.entries.push(n),i(!0)))})});v&&(i=c(n,d,T,e.reportAllChanges),t(function(t){d=o("FCP"),i=c(n,d,T,e.reportAllChanges),f(function(){d.value=performance.now()-t.timeStamp,i(!0)})}))})},w=[.1,.25],y=0,P=1/0,b=0,E=function(n){n.forEach(function(n){n.interactionId&&(P=Math.min(P,n.interactionId),b=Math.max(b,n.interactionId),y=b?(b-P)/7+1:0)})},C=function(){return n?y:performance.interactionCount||0},M=function(){"interactionCount"in performance||n||(n=u("event",E,{type:"event",buffered:!0,durationThreshold:0}))},F=[200,500],I=0,k=function(){return C()-I},B=[],N={},O=function(n){var e=B[B.length-1],t=N[n.interactionId];if(t||B.length<10||n.duration>e.latency){if(t)t.entries.push(n),t.latency=Math.max(t.latency,n.duration);else{var i={id:n.interactionId,latency:n.duration,entries:[n]};N[i.id]=i,B.push(i)}B.sort(function(n,e){return e.latency-n.latency}),B.splice(10).forEach(function(n){delete N[n.id]})}},S=[2500,4e3],q={},A=[800,1800],j=function n(e){document.prerendering?g(function(){return n(e)}):"complete"!==document.readyState?addEventListener("load",function(){return n(e)},!0):setTimeout(e,0)},D="undefined"!=typeof window?window:void 0,H="undefined"!=typeof globalThis?globalThis:D,_=null==H?void 0:H.navigator;null==H||H.document,null==H||H.location,null==H||H.fetch,(null==H?void 0:H.XMLHttpRequest)&&"withCredentials"in new H.XMLHttpRequest&&H.XMLHttpRequest,null==H||H.AbortController,null==_||_.userAgent;var x=null!=D?D:{},z={onLCP:function(n,e){e=e||{},g(function(){var i,v=p(),s=o("LCP"),l=function(n){var e=n[n.length-1];e&&e.startTime<v.firstHiddenTime&&(s.value=Math.max(e.startTime-r(),0),s.entries=[e],i())},m=u("largest-contentful-paint",l);if(m){i=c(n,s,S,e.reportAllChanges);var h=d(function(){q[s.id]||(l(m.takeRecords()),m.disconnect(),q[s.id]=!0,i(!0))});["keydown","click"].forEach(function(n){addEventListener(n,function(){return setTimeout(h,0)},!0)}),a(h),t(function(t){s=o("LCP"),i=c(n,s,S,e.reportAllChanges),f(function(){s.value=performance.now()-t.timeStamp,q[s.id]=!0,i(!0)})})}})},onCLS:function(n,e){e=e||{},L(d(function(){var i,r=o("CLS",0),d=0,v=[],s=function(n){n.forEach(function(n){if(!n.hadRecentInput){var e=v[0],t=v[v.length-1];d&&n.startTime-t.startTime<1e3&&n.startTime-e.startTime<5e3?(d+=n.value,v.push(n)):(d=n.value,v=[n])}}),d>r.value&&(r.value=d,r.entries=v,i())},l=u("layout-shift",s);l&&(i=c(n,r,w,e.reportAllChanges),a(function(){s(l.takeRecords()),i(!0)}),t(function(){d=0,r=o("CLS",0),i=c(n,r,w,e.reportAllChanges),f(function(){return i()})}),setTimeout(i,0))}))},onFCP:L,onINP:function(n,e){e=e||{},g(function(){var i;M();var r,f=o("INP"),d=function(n){n.forEach(function(n){n.interactionId&&O(n),"first-input"===n.entryType&&!B.some(function(e){return e.entries.some(function(e){return n.duration===e.duration&&n.startTime===e.startTime})})&&O(n)});var e,t=(e=Math.min(B.length-1,Math.floor(k()/50)),B[e]);t&&t.latency!==f.value&&(f.value=t.latency,f.entries=t.entries,r())},v=u("event",d,{durationThreshold:null!==(i=e.durationThreshold)&&void 0!==i?i:40});r=c(n,f,F,e.reportAllChanges),v&&("PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&v.observe({type:"first-input",buffered:!0}),a(function(){d(v.takeRecords()),f.value<0&&k()>0&&(f.value=0,f.entries=[]),r(!0)}),t(function(){B=[],I=C(),f=o("INP"),r=c(n,f,F,e.reportAllChanges)}))})},onTTFB:function(n,e){e=e||{};var u=o("TTFB"),f=c(n,u,A,e.reportAllChanges);j(function(){var a=i();if(a){var d=a.responseStart;if(d<=0||d>performance.now())return;u.value=Math.max(d-r(),0),u.entries=[a],f(!0),t(function(){u=o("TTFB",0),(f=c(n,u,A,e.reportAllChanges))(!0)})}})}};x.__VTiltExtensions__=x.__VTiltExtensions__||{},x.__VTiltExtensions__.webVitalsCallbacks=z}();
|
|
2
|
+
//# sourceMappingURL=web-vitals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-vitals.js","sources":["../../../../node_modules/.pnpm/web-vitals@3.5.2/node_modules/web-vitals/dist/web-vitals.js","../src/utils/globals.ts","../src/entrypoints/web-vitals.ts"],"sourcesContent":["var e,n,t,i,r,a=-1,o=function(e){addEventListener(\"pageshow\",(function(n){n.persisted&&(a=n.timeStamp,e(n))}),!0)},c=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType(\"navigation\")[0]},u=function(){var e=c();return e&&e.activationStart||0},f=function(e,n){var t=c(),i=\"navigate\";a>=0?i=\"back-forward-cache\":t&&(document.prerendering||u()>0?i=\"prerender\":document.wasDiscarded?i=\"restore\":t.type&&(i=t.type.replace(/_/g,\"-\")));return{name:e,value:void 0===n?-1:n,rating:\"good\",delta:0,entries:[],id:\"v3-\".concat(Date.now(),\"-\").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:i}},s=function(e,n,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var i=new PerformanceObserver((function(e){Promise.resolve().then((function(){n(e.getEntries())}))}));return i.observe(Object.assign({type:e,buffered:!0},t||{})),i}}catch(e){}},d=function(e,n,t,i){var r,a;return function(o){n.value>=0&&(o||i)&&((a=n.value-(r||0))||void 0===r)&&(r=n.value,n.delta=a,n.rating=function(e,n){return e>n[1]?\"poor\":e>n[0]?\"needs-improvement\":\"good\"}(n.value,t),e(n))}},l=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},p=function(e){var n=function(n){\"pagehide\"!==n.type&&\"hidden\"!==document.visibilityState||e(n)};addEventListener(\"visibilitychange\",n,!0),addEventListener(\"pagehide\",n,!0)},v=function(e){var n=!1;return function(t){n||(e(t),n=!0)}},m=-1,h=function(){return\"hidden\"!==document.visibilityState||document.prerendering?1/0:0},g=function(e){\"hidden\"===document.visibilityState&&m>-1&&(m=\"visibilitychange\"===e.type?e.timeStamp:0,T())},y=function(){addEventListener(\"visibilitychange\",g,!0),addEventListener(\"prerenderingchange\",g,!0)},T=function(){removeEventListener(\"visibilitychange\",g,!0),removeEventListener(\"prerenderingchange\",g,!0)},E=function(){return m<0&&(m=h(),y(),o((function(){setTimeout((function(){m=h(),y()}),0)}))),{get firstHiddenTime(){return m}}},C=function(e){document.prerendering?addEventListener(\"prerenderingchange\",(function(){return e()}),!0):e()},L=[1800,3e3],w=function(e,n){n=n||{},C((function(){var t,i=E(),r=f(\"FCP\"),a=s(\"paint\",(function(e){e.forEach((function(e){\"first-contentful-paint\"===e.name&&(a.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=Math.max(e.startTime-u(),0),r.entries.push(e),t(!0)))}))}));a&&(t=d(e,r,L,n.reportAllChanges),o((function(i){r=f(\"FCP\"),t=d(e,r,L,n.reportAllChanges),l((function(){r.value=performance.now()-i.timeStamp,t(!0)}))})))}))},b=[.1,.25],S=function(e,n){n=n||{},w(v((function(){var t,i=f(\"CLS\",0),r=0,a=[],c=function(e){e.forEach((function(e){if(!e.hadRecentInput){var n=a[0],t=a[a.length-1];r&&e.startTime-t.startTime<1e3&&e.startTime-n.startTime<5e3?(r+=e.value,a.push(e)):(r=e.value,a=[e])}})),r>i.value&&(i.value=r,i.entries=a,t())},u=s(\"layout-shift\",c);u&&(t=d(e,i,b,n.reportAllChanges),p((function(){c(u.takeRecords()),t(!0)})),o((function(){r=0,i=f(\"CLS\",0),t=d(e,i,b,n.reportAllChanges),l((function(){return t()}))})),setTimeout(t,0))})))},A={passive:!0,capture:!0},I=new Date,P=function(i,r){e||(e=r,n=i,t=new Date,k(removeEventListener),F())},F=function(){if(n>=0&&n<t-I){var r={entryType:\"first-input\",name:e.type,target:e.target,cancelable:e.cancelable,startTime:e.timeStamp,processingStart:e.timeStamp+n};i.forEach((function(e){e(r)})),i=[]}},M=function(e){if(e.cancelable){var n=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;\"pointerdown\"==e.type?function(e,n){var t=function(){P(e,n),r()},i=function(){r()},r=function(){removeEventListener(\"pointerup\",t,A),removeEventListener(\"pointercancel\",i,A)};addEventListener(\"pointerup\",t,A),addEventListener(\"pointercancel\",i,A)}(n,e):P(n,e)}},k=function(e){[\"mousedown\",\"keydown\",\"touchstart\",\"pointerdown\"].forEach((function(n){return e(n,M,A)}))},D=[100,300],x=function(t,r){r=r||{},C((function(){var a,c=E(),u=f(\"FID\"),l=function(e){e.startTime<c.firstHiddenTime&&(u.value=e.processingStart-e.startTime,u.entries.push(e),a(!0))},m=function(e){e.forEach(l)},h=s(\"first-input\",m);a=d(t,u,D,r.reportAllChanges),h&&p(v((function(){m(h.takeRecords()),h.disconnect()}))),h&&o((function(){var o;u=f(\"FID\"),a=d(t,u,D,r.reportAllChanges),i=[],n=-1,e=null,k(addEventListener),o=l,i.push(o),F()}))}))},B=0,R=1/0,H=0,N=function(e){e.forEach((function(e){e.interactionId&&(R=Math.min(R,e.interactionId),H=Math.max(H,e.interactionId),B=H?(H-R)/7+1:0)}))},O=function(){return r?B:performance.interactionCount||0},q=function(){\"interactionCount\"in performance||r||(r=s(\"event\",N,{type:\"event\",buffered:!0,durationThreshold:0}))},j=[200,500],_=0,z=function(){return O()-_},G=[],J={},K=function(e){var n=G[G.length-1],t=J[e.interactionId];if(t||G.length<10||e.duration>n.latency){if(t)t.entries.push(e),t.latency=Math.max(t.latency,e.duration);else{var i={id:e.interactionId,latency:e.duration,entries:[e]};J[i.id]=i,G.push(i)}G.sort((function(e,n){return n.latency-e.latency})),G.splice(10).forEach((function(e){delete J[e.id]}))}},Q=function(e,n){n=n||{},C((function(){var t;q();var i,r=f(\"INP\"),a=function(e){e.forEach((function(e){(e.interactionId&&K(e),\"first-input\"===e.entryType)&&(!G.some((function(n){return n.entries.some((function(n){return e.duration===n.duration&&e.startTime===n.startTime}))}))&&K(e))}));var n,t=(n=Math.min(G.length-1,Math.floor(z()/50)),G[n]);t&&t.latency!==r.value&&(r.value=t.latency,r.entries=t.entries,i())},c=s(\"event\",a,{durationThreshold:null!==(t=n.durationThreshold)&&void 0!==t?t:40});i=d(e,r,j,n.reportAllChanges),c&&(\"PerformanceEventTiming\"in window&&\"interactionId\"in PerformanceEventTiming.prototype&&c.observe({type:\"first-input\",buffered:!0}),p((function(){a(c.takeRecords()),r.value<0&&z()>0&&(r.value=0,r.entries=[]),i(!0)})),o((function(){G=[],_=O(),r=f(\"INP\"),i=d(e,r,j,n.reportAllChanges)})))}))},U=[2500,4e3],V={},W=function(e,n){n=n||{},C((function(){var t,i=E(),r=f(\"LCP\"),a=function(e){var n=e[e.length-1];n&&n.startTime<i.firstHiddenTime&&(r.value=Math.max(n.startTime-u(),0),r.entries=[n],t())},c=s(\"largest-contentful-paint\",a);if(c){t=d(e,r,U,n.reportAllChanges);var m=v((function(){V[r.id]||(a(c.takeRecords()),c.disconnect(),V[r.id]=!0,t(!0))}));[\"keydown\",\"click\"].forEach((function(e){addEventListener(e,(function(){return setTimeout(m,0)}),!0)})),p(m),o((function(i){r=f(\"LCP\"),t=d(e,r,U,n.reportAllChanges),l((function(){r.value=performance.now()-i.timeStamp,V[r.id]=!0,t(!0)}))}))}}))},X=[800,1800],Y=function e(n){document.prerendering?C((function(){return e(n)})):\"complete\"!==document.readyState?addEventListener(\"load\",(function(){return e(n)}),!0):setTimeout(n,0)},Z=function(e,n){n=n||{};var t=f(\"TTFB\"),i=d(e,t,X,n.reportAllChanges);Y((function(){var r=c();if(r){var a=r.responseStart;if(a<=0||a>performance.now())return;t.value=Math.max(a-u(),0),t.entries=[r],i(!0),o((function(){t=f(\"TTFB\",0),(i=d(e,t,X,n.reportAllChanges))(!0)}))}}))};export{b as CLSThresholds,L as FCPThresholds,D as FIDThresholds,j as INPThresholds,U as LCPThresholds,X as TTFBThresholds,S as getCLS,w as getFCP,x as getFID,Q as getINP,W as getLCP,Z as getTTFB,S as onCLS,w as onFCP,x as onFID,Q as onINP,W as onLCP,Z as onTTFB};\n",null,null],"names":["r","a","o","e","addEventListener","n","persisted","timeStamp","c","window","performance","getEntriesByType","u","activationStart","f","t","i","document","prerendering","wasDiscarded","type","replace","name","value","rating","delta","entries","id","concat","Date","now","Math","floor","random","navigationType","s","PerformanceObserver","supportedEntryTypes","includes","Promise","resolve","then","getEntries","observe","Object","assign","buffered","d","l","requestAnimationFrame","p","visibilityState","v","m","h","g","T","y","removeEventListener","E","setTimeout","firstHiddenTime","C","L","w","forEach","disconnect","startTime","max","push","reportAllChanges","b","B","R","H","N","interactionId","min","O","interactionCount","q","durationThreshold","j","_","z","G","J","K","length","duration","latency","sort","splice","U","V","X","Y","readyState","win","undefined","global","globalThis","navigator","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","vtiltWebVitalsCallbacks","takeRecords","hadRecentInput","onFCP","entryType","some","PerformanceEventTiming","prototype","onTTFB","responseStart","__VTiltExtensions__","webVitalsCallbacks"],"mappings":"yBAAA,IAAYA,EAAEC,GAAE,EAAGC,EAAE,SAASC,GAAGC,iBAAiB,WAAY,SAASC,GAAGA,EAAEC,YAAYL,EAAEI,EAAEE,UAAUJ,EAAEE,GAAG,GAAG,EAAG,EAAEG,EAAE,WAAW,OAAOC,OAAOC,aAAaA,YAAYC,kBAAkBD,YAAYC,iBAAiB,cAAc,EAAE,EAAEC,EAAE,WAAW,IAAIT,EAA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AAQ,kBAAkB0G,uBAAuBC,WAAW5G,EAAEmC,QAAQ,CAACvB,KAAK,cAAc0B,UAAS,IAAKI,EAAG,WAAWjD,EAAEO,EAAEsG,eAAe9G,EAAEuB,MAAM,GAAG6D,IAAI,IAAIpF,EAAEuB,MAAM,EAAEvB,EAAE0B,QAAQ,IAAIV,GAAE,EAAG,GAAId,EAAG,WAAWmF,EAAE,GAAGF,EAAEL,IAAI9E,EAAEc,EAAE,OAAOE,EAAE+B,EAAE5C,EAAEH,EAAEkF,EAAE7E,EAAEiE,iBAAiB,GAAI,EAAG,EEoBhrL+C,OFpBw8M,SAASlH,EAAEE,GAAGA,EAAEA,GAAG,CAAA,EAAG,IAAIU,EAAED,EAAE,QAAQE,EAAE+B,EAAE5C,EAAEY,EAAEgF,EAAE1F,EAAEiE,kBAAkB0B,EAAG,WAAW,IAAIhG,EAAEQ,IAAI,GAAGR,EAAE,CAAC,IAAIC,EAAED,EAAEsH,cAAc,GAAGrH,GAAG,GAAGA,EAAES,YAAYoB,MAAM,OAAOf,EAAEQ,MAAMQ,KAAKqC,IAAInE,EAAEW,IAAI,GAAGG,EAAEW,QAAQ,CAAC1B,GAAGgB,GAAE,GAAId,EAAG,WAAWa,EAAED,EAAE,OAAO,IAAIE,EAAE+B,EAAE5C,EAAEY,EAAEgF,EAAE1F,EAAEiE,oBAAmB,EAAG,EAAG,CAAC,EAAG,GEwB1tNsC,EAAiBW,oBACfX,EAAiBW,qBAAuB,CAAA,EAG1CX,EAAiBW,oBAAoBC,mBACnCX","x_google_ignoreList":[0]}
|
package/lib/config.js
CHANGED
|
@@ -39,9 +39,11 @@ class ConfigManager {
|
|
|
39
39
|
script.getAttribute("data-storage") || initialConfig.storage;
|
|
40
40
|
config.stringifyPayload =
|
|
41
41
|
script.getAttribute("data-stringify-payload") !== "false";
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// Handle capture_performance: data attribute is boolean, initialConfig can be boolean or object
|
|
43
|
+
const dataAttrPerformance = script.getAttribute("data-capture-performance") === "true";
|
|
44
|
+
config.capture_performance = dataAttrPerformance
|
|
45
|
+
? true
|
|
46
|
+
: initialConfig.capture_performance;
|
|
45
47
|
// Check for conflicting proxy configurations
|
|
46
48
|
if (config.proxy && config.proxyUrl) {
|
|
47
49
|
console.error("Error: Both data-proxy and data-proxy-url are specified. Please use only one of them.");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* All External Dependencies
|
|
4
|
+
*
|
|
5
|
+
* This file imports all external dependency entrypoints.
|
|
6
|
+
* Used by array.full.ts for the full bundle that includes everything.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
require("./recorder");
|
|
10
|
+
require("./web-vitals");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full Bundle Entrypoint
|
|
3
|
+
*
|
|
4
|
+
* Same as array.ts but includes all external dependencies bundled in.
|
|
5
|
+
* This is useful for users who want a single script tag without lazy loading.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* <script src="https://cdn.example.com/dist/array.full.js"></script>
|
|
9
|
+
*
|
|
10
|
+
* This bundle includes:
|
|
11
|
+
* - Core SDK (array.no-external.ts)
|
|
12
|
+
* - External scripts loader
|
|
13
|
+
* - Session recording (rrweb)
|
|
14
|
+
* - Web Vitals tracking
|
|
15
|
+
*/
|
|
16
|
+
import "./all-external-dependencies";
|
|
17
|
+
import "./array";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Full Bundle Entrypoint
|
|
4
|
+
*
|
|
5
|
+
* Same as array.ts but includes all external dependencies bundled in.
|
|
6
|
+
* This is useful for users who want a single script tag without lazy loading.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* <script src="https://cdn.example.com/dist/array.full.js"></script>
|
|
10
|
+
*
|
|
11
|
+
* This bundle includes:
|
|
12
|
+
* - Core SDK (array.no-external.ts)
|
|
13
|
+
* - External scripts loader
|
|
14
|
+
* - Session recording (rrweb)
|
|
15
|
+
* - Web Vitals tracking
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
require("./all-external-dependencies");
|
|
19
|
+
require("./array");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Entrypoint
|
|
3
|
+
*
|
|
4
|
+
* This file is built as a separate bundle (chat.js) that can be
|
|
5
|
+
* lazy-loaded when chat is enabled.
|
|
6
|
+
*
|
|
7
|
+
* Uses Ably for real-time messaging (imported directly in chat.ts).
|
|
8
|
+
*
|
|
9
|
+
* It exports:
|
|
10
|
+
* - initChat: Factory function to create LazyLoadedChat
|
|
11
|
+
*/
|
|
12
|
+
import { type ChatConfig, type LazyLoadedChatInterface } from "../utils/globals";
|
|
13
|
+
import { LazyLoadedChat } from "../extensions/chat/chat";
|
|
14
|
+
import type { VTilt } from "../vtilt";
|
|
15
|
+
/**
|
|
16
|
+
* Factory function to create a LazyLoadedChat instance
|
|
17
|
+
*
|
|
18
|
+
* Called by ChatWrapper after the chat script is loaded
|
|
19
|
+
*/
|
|
20
|
+
declare function initChat(instance: VTilt, config?: ChatConfig): LazyLoadedChatInterface;
|
|
21
|
+
export { initChat, LazyLoadedChat };
|
|
22
|
+
export default initChat;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Chat Entrypoint
|
|
4
|
+
*
|
|
5
|
+
* This file is built as a separate bundle (chat.js) that can be
|
|
6
|
+
* lazy-loaded when chat is enabled.
|
|
7
|
+
*
|
|
8
|
+
* Uses Ably for real-time messaging (imported directly in chat.ts).
|
|
9
|
+
*
|
|
10
|
+
* It exports:
|
|
11
|
+
* - initChat: Factory function to create LazyLoadedChat
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.LazyLoadedChat = void 0;
|
|
15
|
+
exports.initChat = initChat;
|
|
16
|
+
const globals_1 = require("../utils/globals");
|
|
17
|
+
const chat_1 = require("../extensions/chat/chat");
|
|
18
|
+
Object.defineProperty(exports, "LazyLoadedChat", { enumerable: true, get: function () { return chat_1.LazyLoadedChat; } });
|
|
19
|
+
// Initialize extensions object
|
|
20
|
+
globals_1.assignableWindow.__VTiltExtensions__ =
|
|
21
|
+
globals_1.assignableWindow.__VTiltExtensions__ || {};
|
|
22
|
+
/**
|
|
23
|
+
* Factory function to create a LazyLoadedChat instance
|
|
24
|
+
*
|
|
25
|
+
* Called by ChatWrapper after the chat script is loaded
|
|
26
|
+
*/
|
|
27
|
+
function initChat(instance, config) {
|
|
28
|
+
return new chat_1.LazyLoadedChat(instance, config);
|
|
29
|
+
}
|
|
30
|
+
// Register the factory function
|
|
31
|
+
globals_1.assignableWindow.__VTiltExtensions__.initChat = initChat;
|
|
32
|
+
exports.default = initChat;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Vitals Extension Entrypoint
|
|
3
|
+
*
|
|
4
|
+
* This file imports the web-vitals library and registers its callbacks
|
|
5
|
+
* on the global __VTiltExtensions__ object. The main SDK checks for these
|
|
6
|
+
* callbacks and uses them if available.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* - Include this entrypoint in the full bundle (array.full.ts)
|
|
10
|
+
* - Or load it dynamically via loadExternalDependency('web-vitals', callback)
|
|
11
|
+
*/
|
|
12
|
+
import { WebVitalsCallbacks } from "../utils/globals";
|
|
13
|
+
declare const vtiltWebVitalsCallbacks: WebVitalsCallbacks;
|
|
14
|
+
export default vtiltWebVitalsCallbacks;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Web Vitals Extension Entrypoint
|
|
4
|
+
*
|
|
5
|
+
* This file imports the web-vitals library and registers its callbacks
|
|
6
|
+
* on the global __VTiltExtensions__ object. The main SDK checks for these
|
|
7
|
+
* callbacks and uses them if available.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* - Include this entrypoint in the full bundle (array.full.ts)
|
|
11
|
+
* - Or load it dynamically via loadExternalDependency('web-vitals', callback)
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const web_vitals_1 = require("web-vitals");
|
|
15
|
+
const globals_1 = require("../utils/globals");
|
|
16
|
+
const vtiltWebVitalsCallbacks = {
|
|
17
|
+
onLCP: web_vitals_1.onLCP,
|
|
18
|
+
onCLS: web_vitals_1.onCLS,
|
|
19
|
+
onFCP: web_vitals_1.onFCP,
|
|
20
|
+
onINP: web_vitals_1.onINP,
|
|
21
|
+
onTTFB: web_vitals_1.onTTFB,
|
|
22
|
+
};
|
|
23
|
+
// Initialize extensions object if not exists
|
|
24
|
+
globals_1.assignableWindow.__VTiltExtensions__ =
|
|
25
|
+
globals_1.assignableWindow.__VTiltExtensions__ || {};
|
|
26
|
+
// Register web vitals callbacks
|
|
27
|
+
globals_1.assignableWindow.__VTiltExtensions__.webVitalsCallbacks =
|
|
28
|
+
vtiltWebVitalsCallbacks;
|
|
29
|
+
exports.default = vtiltWebVitalsCallbacks;
|