@faststats/web 0.2.7 → 0.2.9
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/CHANGELOG.md +25 -0
- package/dist/chunks/analytics-BlPwufvF.js +1 -0
- package/dist/chunks/api-urls-BrkcoElX.js +1 -0
- package/dist/{error-asweBGYd.js → chunks/error-C-fHJ_1D.js} +2 -2
- package/dist/chunks/feature-flags-6rZlmhfu.d.ts +18 -0
- package/dist/chunks/feature-flags-CqVtrpX2.js +1 -0
- package/dist/chunks/replay-CKrEvguu.js +1 -0
- package/dist/chunks/replay-IhsP2Ab4.d.ts +77 -0
- package/dist/chunks/rolldown-runtime-MP-BAFHD.js +1 -0
- package/dist/chunks/types-C3vW7XGe.js +1 -0
- package/dist/chunks/web-vitals-BooBPWJC.js +1 -0
- package/dist/error.d.ts +44 -0
- package/dist/error.js +1 -0
- package/dist/feature-flags.d.ts +2 -0
- package/dist/feature-flags.js +1 -0
- package/dist/index.d.ts +140 -0
- package/dist/index.js +1 -0
- package/dist/replay.d.ts +2 -0
- package/dist/replay.js +1 -0
- package/dist/web-vitals.d.ts +27 -0
- package/dist/web-vitals.js +1 -0
- package/package.json +32 -11
- package/scripts/check-bundle-size.mjs +90 -9
- package/src/analytics.ts +60 -47
- package/src/entries/error.ts +6 -0
- package/src/entries/feature-flags.ts +5 -0
- package/src/entries/main.ts +21 -0
- package/src/entries/replay.ts +1 -0
- package/src/entries/web-vitals.ts +1 -0
- package/src/env.d.ts +2 -0
- package/src/error.ts +5 -0
- package/src/feature-flags.ts +2 -4
- package/src/replay.ts +104 -59
- package/src/sdk.ts +8 -0
- package/src/utils/types.ts +1 -1
- package/src/web-vitals.ts +32 -14
- package/tests/analytics.test.ts +33 -2
- package/tests/replay.test.ts +150 -21
- package/tsdown.config.ts +16 -1
- package/dist/analytics-Ct-lghlf.js +0 -1
- package/dist/module.d.ts +0 -531
- package/dist/module.js +0 -1
- package/dist/replay-DUA5c3Jf.js +0 -1
- package/dist/types-Df70G0eM.js +0 -1
- package/dist/web-vitals-gcUR-TX_.js +0 -1
- package/src/module.ts +0 -25
package/dist/module.d.ts
DELETED
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
import { recordOptions } from "rrweb/typings/types";
|
|
2
|
-
import { SlimDOMOptions } from "rrweb-snapshot";
|
|
3
|
-
|
|
4
|
-
//#region src/feature-flags.d.ts
|
|
5
|
-
type FeatureFlagEvaluation = {
|
|
6
|
-
value: string;
|
|
7
|
-
variantKey?: string;
|
|
8
|
-
variantValue?: string;
|
|
9
|
-
};
|
|
10
|
-
type FeatureFlagCheckContext = {
|
|
11
|
-
baseUrl?: string;
|
|
12
|
-
projectToken?: string;
|
|
13
|
-
projectId?: string;
|
|
14
|
-
identifier?: string;
|
|
15
|
-
externalId?: string;
|
|
16
|
-
attributes?: Record<string, unknown>;
|
|
17
|
-
signal?: AbortSignal;
|
|
18
|
-
};
|
|
19
|
-
declare function fetchFeatureFlagEvaluation(flagKey: string, context: FeatureFlagCheckContext): Promise<FeatureFlagEvaluation>;
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region ../../node_modules/.bun/@rrweb+types@2.0.0-alpha.20/node_modules/@rrweb/types/dist/index.d.ts
|
|
22
|
-
declare type addedNodeMutation = {
|
|
23
|
-
parentId: number;
|
|
24
|
-
previousId?: number | null;
|
|
25
|
-
nextId: number | null;
|
|
26
|
-
node: serializedNodeWithId;
|
|
27
|
-
};
|
|
28
|
-
declare type adoptedStyleSheetData = {
|
|
29
|
-
source: IncrementalSource.AdoptedStyleSheet;
|
|
30
|
-
} & adoptedStyleSheetParam;
|
|
31
|
-
declare type adoptedStyleSheetParam = {
|
|
32
|
-
id: number;
|
|
33
|
-
styles?: {
|
|
34
|
-
styleId: number;
|
|
35
|
-
rules: styleSheetAddRule[];
|
|
36
|
-
}[];
|
|
37
|
-
styleIds: number[];
|
|
38
|
-
};
|
|
39
|
-
declare type attributeMutation = {
|
|
40
|
-
id: number;
|
|
41
|
-
attributes: {
|
|
42
|
-
[key: string]: string | styleOMValue | null;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
declare type attributes = cssTextKeyAttr & {
|
|
46
|
-
[key: string]: string | number | true | null;
|
|
47
|
-
};
|
|
48
|
-
declare enum CanvasContext {
|
|
49
|
-
'2D' = 0,
|
|
50
|
-
WebGL = 1,
|
|
51
|
-
WebGL2 = 2
|
|
52
|
-
}
|
|
53
|
-
declare type canvasMutationCommand = {
|
|
54
|
-
property: string;
|
|
55
|
-
args: Array<unknown>;
|
|
56
|
-
setter?: true;
|
|
57
|
-
};
|
|
58
|
-
declare type canvasMutationData = {
|
|
59
|
-
source: IncrementalSource.CanvasMutation;
|
|
60
|
-
} & canvasMutationParam;
|
|
61
|
-
declare type canvasMutationParam = {
|
|
62
|
-
id: number;
|
|
63
|
-
type: CanvasContext;
|
|
64
|
-
commands: canvasMutationCommand[];
|
|
65
|
-
} | ({
|
|
66
|
-
id: number;
|
|
67
|
-
type: CanvasContext;
|
|
68
|
-
} & canvasMutationCommand);
|
|
69
|
-
declare type cdataNode = {
|
|
70
|
-
type: NodeType.CDATA;
|
|
71
|
-
textContent: '';
|
|
72
|
-
};
|
|
73
|
-
declare type commentNode = {
|
|
74
|
-
type: NodeType.Comment;
|
|
75
|
-
textContent: string;
|
|
76
|
-
};
|
|
77
|
-
declare type cssTextKeyAttr = {
|
|
78
|
-
_cssText?: string;
|
|
79
|
-
};
|
|
80
|
-
declare type customElementData = {
|
|
81
|
-
source: IncrementalSource.CustomElement;
|
|
82
|
-
} & customElementParam;
|
|
83
|
-
declare type customElementParam = {
|
|
84
|
-
define?: {
|
|
85
|
-
name: string;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
declare type customEvent<T = unknown> = {
|
|
89
|
-
type: EventType.Custom;
|
|
90
|
-
data: {
|
|
91
|
-
tag: string;
|
|
92
|
-
payload: T;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
declare type documentNode = {
|
|
96
|
-
type: NodeType.Document;
|
|
97
|
-
childNodes: serializedNodeWithId[];
|
|
98
|
-
compatMode?: string;
|
|
99
|
-
};
|
|
100
|
-
declare type documentTypeNode = {
|
|
101
|
-
type: NodeType.DocumentType;
|
|
102
|
-
name: string;
|
|
103
|
-
publicId: string;
|
|
104
|
-
systemId: string;
|
|
105
|
-
};
|
|
106
|
-
declare type domContentLoadedEvent = {
|
|
107
|
-
type: EventType.DomContentLoaded;
|
|
108
|
-
data: unknown;
|
|
109
|
-
};
|
|
110
|
-
declare type elementNode = {
|
|
111
|
-
type: NodeType.Element;
|
|
112
|
-
tagName: string;
|
|
113
|
-
attributes: attributes;
|
|
114
|
-
childNodes: serializedNodeWithId[];
|
|
115
|
-
isSVG?: true;
|
|
116
|
-
needBlock?: boolean;
|
|
117
|
-
isCustom?: true;
|
|
118
|
-
};
|
|
119
|
-
declare enum EventType {
|
|
120
|
-
DomContentLoaded = 0,
|
|
121
|
-
Load = 1,
|
|
122
|
-
FullSnapshot = 2,
|
|
123
|
-
IncrementalSnapshot = 3,
|
|
124
|
-
Meta = 4,
|
|
125
|
-
Custom = 5,
|
|
126
|
-
Plugin = 6
|
|
127
|
-
}
|
|
128
|
-
declare type eventWithoutTime = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent;
|
|
129
|
-
declare type eventWithTime = eventWithoutTime & {
|
|
130
|
-
timestamp: number;
|
|
131
|
-
delay?: number;
|
|
132
|
-
};
|
|
133
|
-
declare type fontData = {
|
|
134
|
-
source: IncrementalSource.Font;
|
|
135
|
-
} & fontParam;
|
|
136
|
-
declare type fontParam = {
|
|
137
|
-
family: string;
|
|
138
|
-
fontSource: string;
|
|
139
|
-
buffer: boolean;
|
|
140
|
-
descriptors?: FontFaceDescriptors;
|
|
141
|
-
};
|
|
142
|
-
declare type fullSnapshotEvent = {
|
|
143
|
-
type: EventType.FullSnapshot;
|
|
144
|
-
data: {
|
|
145
|
-
node: serializedNodeWithId;
|
|
146
|
-
initialOffset: {
|
|
147
|
-
top: number;
|
|
148
|
-
left: number;
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | selectionData | styleDeclarationData | adoptedStyleSheetData | customElementData;
|
|
153
|
-
declare type incrementalSnapshotEvent = {
|
|
154
|
-
type: EventType.IncrementalSnapshot;
|
|
155
|
-
data: incrementalData;
|
|
156
|
-
};
|
|
157
|
-
declare enum IncrementalSource {
|
|
158
|
-
Mutation = 0,
|
|
159
|
-
MouseMove = 1,
|
|
160
|
-
MouseInteraction = 2,
|
|
161
|
-
Scroll = 3,
|
|
162
|
-
ViewportResize = 4,
|
|
163
|
-
Input = 5,
|
|
164
|
-
TouchMove = 6,
|
|
165
|
-
MediaInteraction = 7,
|
|
166
|
-
StyleSheetRule = 8,
|
|
167
|
-
CanvasMutation = 9,
|
|
168
|
-
Font = 10,
|
|
169
|
-
Log = 11,
|
|
170
|
-
Drag = 12,
|
|
171
|
-
StyleDeclaration = 13,
|
|
172
|
-
Selection = 14,
|
|
173
|
-
AdoptedStyleSheet = 15,
|
|
174
|
-
CustomElement = 16
|
|
175
|
-
}
|
|
176
|
-
declare type inputData = {
|
|
177
|
-
source: IncrementalSource.Input;
|
|
178
|
-
id: number;
|
|
179
|
-
} & inputValue;
|
|
180
|
-
declare type inputValue = {
|
|
181
|
-
text: string;
|
|
182
|
-
isChecked: boolean;
|
|
183
|
-
userTriggered?: boolean;
|
|
184
|
-
};
|
|
185
|
-
declare type loadedEvent = {
|
|
186
|
-
type: EventType.Load;
|
|
187
|
-
data: unknown;
|
|
188
|
-
};
|
|
189
|
-
declare type mediaInteractionData = {
|
|
190
|
-
source: IncrementalSource.MediaInteraction;
|
|
191
|
-
} & mediaInteractionParam;
|
|
192
|
-
declare type mediaInteractionParam = {
|
|
193
|
-
type: MediaInteractions;
|
|
194
|
-
id: number;
|
|
195
|
-
currentTime?: number;
|
|
196
|
-
volume?: number;
|
|
197
|
-
muted?: boolean;
|
|
198
|
-
loop?: boolean;
|
|
199
|
-
playbackRate?: number;
|
|
200
|
-
};
|
|
201
|
-
declare enum MediaInteractions {
|
|
202
|
-
Play = 0,
|
|
203
|
-
Pause = 1,
|
|
204
|
-
Seeked = 2,
|
|
205
|
-
VolumeChange = 3,
|
|
206
|
-
RateChange = 4
|
|
207
|
-
}
|
|
208
|
-
declare type metaEvent = {
|
|
209
|
-
type: EventType.Meta;
|
|
210
|
-
data: {
|
|
211
|
-
href: string;
|
|
212
|
-
width: number;
|
|
213
|
-
height: number;
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
declare type mouseInteractionData = {
|
|
217
|
-
source: IncrementalSource.MouseInteraction;
|
|
218
|
-
} & mouseInteractionParam;
|
|
219
|
-
declare type mouseInteractionParam = {
|
|
220
|
-
type: MouseInteractions;
|
|
221
|
-
id: number;
|
|
222
|
-
x?: number;
|
|
223
|
-
y?: number;
|
|
224
|
-
pointerType?: PointerTypes;
|
|
225
|
-
};
|
|
226
|
-
declare enum MouseInteractions {
|
|
227
|
-
MouseUp = 0,
|
|
228
|
-
MouseDown = 1,
|
|
229
|
-
Click = 2,
|
|
230
|
-
ContextMenu = 3,
|
|
231
|
-
DblClick = 4,
|
|
232
|
-
Focus = 5,
|
|
233
|
-
Blur = 6,
|
|
234
|
-
TouchStart = 7,
|
|
235
|
-
TouchMove_Departed = 8,
|
|
236
|
-
TouchEnd = 9,
|
|
237
|
-
TouchCancel = 10
|
|
238
|
-
}
|
|
239
|
-
declare type mousemoveData = {
|
|
240
|
-
source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag;
|
|
241
|
-
positions: mousePosition[];
|
|
242
|
-
};
|
|
243
|
-
declare type mousePosition = {
|
|
244
|
-
x: number;
|
|
245
|
-
y: number;
|
|
246
|
-
id: number;
|
|
247
|
-
timeOffset: number;
|
|
248
|
-
};
|
|
249
|
-
declare type mutationCallbackParam = {
|
|
250
|
-
texts: textMutation[];
|
|
251
|
-
attributes: attributeMutation[];
|
|
252
|
-
removes: removedNodeMutation[];
|
|
253
|
-
adds: addedNodeMutation[];
|
|
254
|
-
isAttachIframe?: true;
|
|
255
|
-
};
|
|
256
|
-
declare type mutationData = {
|
|
257
|
-
source: IncrementalSource.Mutation;
|
|
258
|
-
} & mutationCallbackParam;
|
|
259
|
-
declare enum NodeType {
|
|
260
|
-
Document = 0,
|
|
261
|
-
DocumentType = 1,
|
|
262
|
-
Element = 2,
|
|
263
|
-
Text = 3,
|
|
264
|
-
CDATA = 4,
|
|
265
|
-
Comment = 5
|
|
266
|
-
}
|
|
267
|
-
declare type pluginEvent<T = unknown> = {
|
|
268
|
-
type: EventType.Plugin;
|
|
269
|
-
data: {
|
|
270
|
-
plugin: string;
|
|
271
|
-
payload: T;
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
declare enum PointerTypes {
|
|
275
|
-
Mouse = 0,
|
|
276
|
-
Pen = 1,
|
|
277
|
-
Touch = 2
|
|
278
|
-
}
|
|
279
|
-
declare type removedNodeMutation = {
|
|
280
|
-
parentId: number;
|
|
281
|
-
id: number;
|
|
282
|
-
isShadow?: boolean;
|
|
283
|
-
};
|
|
284
|
-
declare type scrollData = {
|
|
285
|
-
source: IncrementalSource.Scroll;
|
|
286
|
-
} & scrollPosition;
|
|
287
|
-
declare type scrollPosition = {
|
|
288
|
-
id: number;
|
|
289
|
-
x: number;
|
|
290
|
-
y: number;
|
|
291
|
-
};
|
|
292
|
-
declare type selectionData = {
|
|
293
|
-
source: IncrementalSource.Selection;
|
|
294
|
-
} & selectionParam;
|
|
295
|
-
declare type selectionParam = {
|
|
296
|
-
ranges: Array<SelectionRange>;
|
|
297
|
-
};
|
|
298
|
-
declare type SelectionRange = {
|
|
299
|
-
start: number;
|
|
300
|
-
startOffset: number;
|
|
301
|
-
end: number;
|
|
302
|
-
endOffset: number;
|
|
303
|
-
};
|
|
304
|
-
declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
|
|
305
|
-
rootId?: number;
|
|
306
|
-
isShadowHost?: boolean;
|
|
307
|
-
isShadow?: boolean;
|
|
308
|
-
};
|
|
309
|
-
declare type serializedNodeWithId = serializedNode & {
|
|
310
|
-
id: number;
|
|
311
|
-
};
|
|
312
|
-
declare type styleDeclarationData = {
|
|
313
|
-
source: IncrementalSource.StyleDeclaration;
|
|
314
|
-
} & styleDeclarationParam;
|
|
315
|
-
declare type styleDeclarationParam = {
|
|
316
|
-
id?: number;
|
|
317
|
-
styleId?: number;
|
|
318
|
-
index: number[];
|
|
319
|
-
set?: {
|
|
320
|
-
property: string;
|
|
321
|
-
value: string | null;
|
|
322
|
-
priority: string | undefined;
|
|
323
|
-
};
|
|
324
|
-
remove?: {
|
|
325
|
-
property: string;
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
declare type styleOMValue = {
|
|
329
|
-
[key: string]: styleValueWithPriority | string | false;
|
|
330
|
-
};
|
|
331
|
-
declare type styleSheetAddRule = {
|
|
332
|
-
rule: string;
|
|
333
|
-
index?: number | number[];
|
|
334
|
-
};
|
|
335
|
-
declare type styleSheetDeleteRule = {
|
|
336
|
-
index: number | number[];
|
|
337
|
-
};
|
|
338
|
-
declare type styleSheetRuleData = {
|
|
339
|
-
source: IncrementalSource.StyleSheetRule;
|
|
340
|
-
} & styleSheetRuleParam;
|
|
341
|
-
declare type styleSheetRuleParam = {
|
|
342
|
-
id?: number;
|
|
343
|
-
styleId?: number;
|
|
344
|
-
removes?: styleSheetDeleteRule[];
|
|
345
|
-
adds?: styleSheetAddRule[];
|
|
346
|
-
replace?: string;
|
|
347
|
-
replaceSync?: string;
|
|
348
|
-
};
|
|
349
|
-
declare type styleValueWithPriority = [string, string];
|
|
350
|
-
declare type textMutation = {
|
|
351
|
-
id: number;
|
|
352
|
-
value: string | null;
|
|
353
|
-
};
|
|
354
|
-
declare type textNode = {
|
|
355
|
-
type: NodeType.Text;
|
|
356
|
-
textContent: string;
|
|
357
|
-
isStyle?: true;
|
|
358
|
-
};
|
|
359
|
-
declare type viewportResizeData = {
|
|
360
|
-
source: IncrementalSource.ViewportResize;
|
|
361
|
-
} & viewportResizeDimension;
|
|
362
|
-
declare type viewportResizeDimension = {
|
|
363
|
-
width: number;
|
|
364
|
-
height: number;
|
|
365
|
-
};
|
|
366
|
-
declare global {
|
|
367
|
-
interface Window {
|
|
368
|
-
FontFace: typeof FontFace;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
//#endregion
|
|
372
|
-
//#region src/replay.d.ts
|
|
373
|
-
interface ReplayTrackerOptions {
|
|
374
|
-
siteKey: string;
|
|
375
|
-
baseUrl?: string;
|
|
376
|
-
debug?: boolean;
|
|
377
|
-
compress?: boolean;
|
|
378
|
-
samplingPercentage?: number;
|
|
379
|
-
flushInterval?: number;
|
|
380
|
-
maxEvents?: number;
|
|
381
|
-
maxPendingBatches?: number;
|
|
382
|
-
minReplayLengthMs?: number;
|
|
383
|
-
sampling?: recordOptions<eventWithTime>["sampling"];
|
|
384
|
-
slimDOMOptions?: SlimDOMOptions;
|
|
385
|
-
maskAllInputs?: boolean;
|
|
386
|
-
maskInputOptions?: recordOptions<eventWithTime>["maskInputOptions"];
|
|
387
|
-
blockClass?: string;
|
|
388
|
-
blockSelector?: string;
|
|
389
|
-
maskTextClass?: string;
|
|
390
|
-
maskTextSelector?: string;
|
|
391
|
-
checkoutEveryNms?: number;
|
|
392
|
-
checkoutEveryNth?: number;
|
|
393
|
-
recordConsole?: boolean;
|
|
394
|
-
}
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/utils/types.d.ts
|
|
397
|
-
interface SendDataOptions {
|
|
398
|
-
url: string;
|
|
399
|
-
data: string | Blob;
|
|
400
|
-
contentType?: string;
|
|
401
|
-
headers?: Record<string, string>;
|
|
402
|
-
debug?: boolean;
|
|
403
|
-
debugPrefix?: string;
|
|
404
|
-
useBeacon?: boolean;
|
|
405
|
-
keepalive?: boolean;
|
|
406
|
-
}
|
|
407
|
-
//#endregion
|
|
408
|
-
//#region src/analytics.d.ts
|
|
409
|
-
type Dict = Record<string, unknown>;
|
|
410
|
-
interface SamplingOptions {
|
|
411
|
-
percentage?: number;
|
|
412
|
-
}
|
|
413
|
-
interface WebVitalsConfig {
|
|
414
|
-
sampling?: SamplingOptions;
|
|
415
|
-
}
|
|
416
|
-
interface SessionReplayConfig {
|
|
417
|
-
enabled?: boolean;
|
|
418
|
-
sampling?: SamplingOptions;
|
|
419
|
-
}
|
|
420
|
-
type ConsentMode = "pending" | "granted" | "denied";
|
|
421
|
-
interface ConsentConfig {
|
|
422
|
-
mode?: ConsentMode;
|
|
423
|
-
cookielessWhilePending?: boolean;
|
|
424
|
-
}
|
|
425
|
-
interface IdentifyOptions {
|
|
426
|
-
name?: string;
|
|
427
|
-
phone?: string;
|
|
428
|
-
avatarUrl?: string;
|
|
429
|
-
traits?: Record<string, unknown>;
|
|
430
|
-
}
|
|
431
|
-
interface WebAnalyticsOptions {
|
|
432
|
-
siteKey: string;
|
|
433
|
-
baseUrl?: string;
|
|
434
|
-
featureFlagsBaseUrl?: string;
|
|
435
|
-
debug?: boolean;
|
|
436
|
-
autoTrack?: boolean;
|
|
437
|
-
trackHash?: boolean;
|
|
438
|
-
trackErrors?: boolean;
|
|
439
|
-
trackWebVitals?: boolean;
|
|
440
|
-
trackReplay?: boolean;
|
|
441
|
-
cookieless?: boolean;
|
|
442
|
-
consent?: ConsentConfig;
|
|
443
|
-
webVitals?: WebVitalsConfig;
|
|
444
|
-
sessionReplays?: SessionReplayConfig;
|
|
445
|
-
replayOptions?: Partial<ReplayTrackerOptions>;
|
|
446
|
-
}
|
|
447
|
-
declare function getInstance(): WebAnalytics | null;
|
|
448
|
-
declare function trackEvent(eventName: string, properties?: Record<string, unknown>): void;
|
|
449
|
-
declare function identify(externalId: string, email: string, options?: IdentifyOptions): void;
|
|
450
|
-
declare function logout(resetAnonymousIdentity?: boolean): void;
|
|
451
|
-
declare function setConsentMode(mode: ConsentMode): void;
|
|
452
|
-
declare function optIn(): void;
|
|
453
|
-
declare function optOut(): void;
|
|
454
|
-
declare function reportError(error: Error): void;
|
|
455
|
-
declare function isTrackingDisabled(): boolean;
|
|
456
|
-
declare function sendData(options: SendDataOptions): Promise<boolean>;
|
|
457
|
-
declare class WebAnalytics {
|
|
458
|
-
private readonly options;
|
|
459
|
-
private readonly webEndpoint;
|
|
460
|
-
private readonly baseUrl;
|
|
461
|
-
private readonly featureFlagsBaseUrl;
|
|
462
|
-
private readonly debug;
|
|
463
|
-
private started;
|
|
464
|
-
private destroyed;
|
|
465
|
-
private pageKey;
|
|
466
|
-
private navTimer;
|
|
467
|
-
private heartbeatTimer;
|
|
468
|
-
private scrollDepth;
|
|
469
|
-
private pageEntryTime;
|
|
470
|
-
private pagePath;
|
|
471
|
-
private pageUrl;
|
|
472
|
-
private pageHash;
|
|
473
|
-
private hasLeftCurrentPage;
|
|
474
|
-
private scrollHandler;
|
|
475
|
-
private consentMode;
|
|
476
|
-
private readonly cookielessWhilePending;
|
|
477
|
-
private readonly cleanupCallbacks;
|
|
478
|
-
private readonly childTrackers;
|
|
479
|
-
private readonly pendingReportedErrors;
|
|
480
|
-
private errorTracker;
|
|
481
|
-
private readonly handleVisibilityChange;
|
|
482
|
-
private readonly handlePageHide;
|
|
483
|
-
private readonly handlePopState;
|
|
484
|
-
private readonly handleHashChange;
|
|
485
|
-
constructor(options: WebAnalyticsOptions);
|
|
486
|
-
private log;
|
|
487
|
-
private init;
|
|
488
|
-
private registerCleanup;
|
|
489
|
-
private addWindowListener;
|
|
490
|
-
private addDocumentListener;
|
|
491
|
-
private patchHistory;
|
|
492
|
-
private ensureStarted;
|
|
493
|
-
private stopHeartbeat;
|
|
494
|
-
private stopNavigationTimer;
|
|
495
|
-
private stopChildTrackers;
|
|
496
|
-
private registerChildTracker;
|
|
497
|
-
private startErrorTracker;
|
|
498
|
-
private startWebVitalsTracker;
|
|
499
|
-
private startReplayTracker;
|
|
500
|
-
start(): Promise<void>;
|
|
501
|
-
destroy(): void;
|
|
502
|
-
pageview(extra?: Dict): void;
|
|
503
|
-
track(name: string, extra?: Dict): void;
|
|
504
|
-
identify(externalId: string, email: string, options?: IdentifyOptions): void;
|
|
505
|
-
logout(resetAnonymousIdentity?: boolean): void;
|
|
506
|
-
setConsentMode(mode: ConsentMode): void;
|
|
507
|
-
optIn(): void;
|
|
508
|
-
optOut(): void;
|
|
509
|
-
getConsentMode(): ConsentMode;
|
|
510
|
-
getAnonymousId(): string;
|
|
511
|
-
getSessionId(): string;
|
|
512
|
-
checkFeatureFlag(key: string, attributes?: Record<string, unknown>, opts?: {
|
|
513
|
-
externalId?: string;
|
|
514
|
-
signal?: AbortSignal;
|
|
515
|
-
}): Promise<FeatureFlagEvaluation>;
|
|
516
|
-
reportError(error: Error): void;
|
|
517
|
-
private isCookielessMode;
|
|
518
|
-
private send;
|
|
519
|
-
private enterPage;
|
|
520
|
-
private leavePage;
|
|
521
|
-
private trackScroll;
|
|
522
|
-
private startHeartbeat;
|
|
523
|
-
private navigate;
|
|
524
|
-
private links;
|
|
525
|
-
}
|
|
526
|
-
//#endregion
|
|
527
|
-
//#region src/utils/api-urls.d.ts
|
|
528
|
-
declare function normalizeFeatureFlagsBaseUrl(input?: string): string;
|
|
529
|
-
declare function featureFlagsCheckUrl(baseUrl?: string): string;
|
|
530
|
-
//#endregion
|
|
531
|
-
export { type ConsentMode, type FeatureFlagCheckContext, type FeatureFlagEvaluation, type IdentifyOptions, WebAnalytics, type WebAnalyticsOptions, featureFlagsCheckUrl, fetchFeatureFlagEvaluation, getInstance, identify, isTrackingDisabled, logout, normalizeFeatureFlagsBaseUrl, optIn, optOut, reportError, sendData, setConsentMode, trackEvent };
|
package/dist/module.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as e,l as t}from"./types-Df70G0eM.js";import{a as n,c as r,d as i,f as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./analytics-Ct-lghlf.js";export{f as WebAnalytics,t as featureFlagsCheckUrl,a as fetchFeatureFlagEvaluation,c as getInstance,u as identify,o as isTrackingDisabled,n as logout,e as normalizeFeatureFlagsBaseUrl,l as optIn,d as optOut,r as reportError,s as sendData,p as setConsentMode,i as trackEvent};
|
package/dist/replay-DUA5c3Jf.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,p as n,r,t as i}from"./types-Df70G0eM.js";import{l as a}from"./analytics-Ct-lghlf.js";import{getRecordConsolePlugin as o}from"@rrweb/rrweb-plugin-console-record";import{getRecordSequentialIdPlugin as s}from"@rrweb/rrweb-plugin-sequential-id-record";import{EventType as c,record as l}from"rrweb";const u={mousemove:50,mouseInteraction:!0,scroll:150,media:800,input:`last`},d={script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0};var f=class{endpoint;compressionSupported=typeof window<`u`&&`CompressionStream`in window;sampled;events=[];pending=[];sessionId;started=!1;startTime=0;sequence=0;intervalId=null;flushTask=null;retryTask=null;minLengthFlushTask=null;stopRecording;sending=!1;constructor(e){this.options=e,this.endpoint=n(e.baseUrl),this.sampled=Math.random()*100<i(e.samplingPercentage)}get debug(){return this.options.debug??!1}get flushInterval(){return this.options.flushInterval??1e4}get maxEvents(){return this.options.maxEvents??500}get maxPendingBatches(){return this.options.maxPendingBatches??30}get minReplayLengthMs(){return this.options.minReplayLengthMs??3e3}get shouldCompress(){return this.options.compress??!1}log(...e){this.debug&&console.log(`[Replay]`,...e)}start(){this.started||typeof window>`u`||!this.sampled||(this.started=!0,this.sessionId=r(),this.startTime=e(),this.stopRecording=l({emit:this.onEvent,sampling:this.options.sampling??u,slimDOMOptions:this.options.slimDOMOptions??d,maskAllInputs:this.options.maskAllInputs??!0,maskInputOptions:this.options.maskInputOptions??{password:!0,email:!0,tel:!0},blockClass:this.options.blockClass,blockSelector:this.options.blockSelector,maskTextClass:this.options.maskTextClass,maskTextSelector:this.options.maskTextSelector,checkoutEveryNms:this.options.checkoutEveryNms??6e4,checkoutEveryNth:this.options.checkoutEveryNth,plugins:[s({key:`_faststatsSeqId`}),...this.options.recordConsole??!0?[o()]:[]]}),this.intervalId=setInterval(this.requestFlush,this.flushInterval),window.addEventListener(`beforeunload`,this.onUnload),window.addEventListener(`pagehide`,this.onUnload),document.addEventListener(`visibilitychange`,this.onVisibilityChange),this.log(`Recording started`))}stop(){if(this.started){if(this.started=!1,this.stopRecording?.(),this.stopRecording=void 0,this.intervalId&&clearInterval(this.intervalId),this.flushTask&&clearTimeout(this.flushTask),this.retryTask&&clearTimeout(this.retryTask),this.minLengthFlushTask&&clearTimeout(this.minLengthFlushTask),this.intervalId=null,this.flushTask=null,this.retryTask=null,this.minLengthFlushTask=null,window.removeEventListener(`beforeunload`,this.onUnload),window.removeEventListener(`pagehide`,this.onUnload),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),!this.hasReachedMinLength()){this.events.length=0,this.sessionId=void 0,this.log(`Session too short (${Date.now()-this.startTime}ms), discarding events`);return}this.flush(!0),this.sessionId=void 0,this.log(`Recording stopped`)}}getSessionId(){return this.sessionId??r()}onEvent=(e,t)=>{if(this.events.push(e),t||this.events.length>=this.maxEvents||e.type===c.FullSnapshot&&this.hasReachedMinLength()){this.requestFlush();return}this.scheduleMinLengthFlush()};onUnload=()=>{this.flush(!0)};onVisibilityChange=()=>{document.visibilityState===`hidden`&&this.flush(!0)};hasReachedMinLength(){return this.minReplayLengthMs<=0||Date.now()-this.startTime>=this.minReplayLengthMs}requestFlush=()=>{this.flushTask||this.sending||this.events.length===0||(this.minLengthFlushTask&&=(clearTimeout(this.minLengthFlushTask),null),this.flushTask=setTimeout(()=>{this.flushTask=null,this.flush(!1)},0))};scheduleMinLengthFlush(){if(this.minLengthFlushTask||this.events.length===0||this.hasReachedMinLength())return;let e=Math.max(0,this.minReplayLengthMs-(Date.now()-this.startTime)),t=Math.min(e,2147483647);this.minLengthFlushTask=setTimeout(()=>{this.minLengthFlushTask=null,this.requestFlush()},t)}createBatch(e){let n=t();return{token:this.options.siteKey,sessionId:this.getSessionId(),...n?{identifier:n}:{},sequence:this.sequence++,timestamp:Date.now(),url:window.location.href,events:e}}async encodeBatch(e,t){let n=JSON.stringify(e);if(!this.shouldCompress||!this.compressionSupported||t)return{data:n,isCompressed:!1};try{return{data:await this.compress(n),isCompressed:!0}}catch{return this.log(`Compression failed, using uncompressed`),{data:new Blob([n],{type:`application/json`}),isCompressed:!1}}}async flush(e){if(!this.sending){if(this.events.length>0)if(!this.hasReachedMinLength())this.scheduleMinLengthFlush();else{let e=this.createBatch(this.events.splice(0));this.pending.push(e)}if(this.pending.length!==0){this.sending=!0;try{for(;this.pending.length>0;){let t=this.pending[0];if(!t)break;let n=await this.encodeBatch(t,e);if(!await this.send(n.data,n.isCompressed,e)){this.pending.length>=this.maxPendingBatches&&(this.log(`Pending buffer full, dropping batch ${t.sequence}`),this.pending.shift()),this.log(`Failed to send replay batch ${t.sequence}, retrying`),this.scheduleRetry();break}this.pending.shift(),e=!1}}finally{this.sending=!1}}}}scheduleRetry(){this.retryTask||=setTimeout(()=>{this.retryTask=null,this.flush(!1)},1e3)}async compress(e){let t=new TextEncoder().encode(e),n=new CompressionStream(`gzip`),r=n.writable.getWriter();await r.write(t),await r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;t&&i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return new Blob([s],{type:`application/octet-stream`})}send(e,t,n){return a({url:t?`${this.endpoint}?encoding=gzip`:this.endpoint,data:e,contentType:t?`application/octet-stream`:`application/json`,debug:!1,useBeacon:!1,keepalive:n})??Promise.resolve(!1)}};export{f as default};
|
package/dist/types-Df70G0eM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=`https://metrics.faststats.dev`,t=`https://flags.faststats.dev`;function n(e){return e.replace(/\/+$/,``)}function r(t){return t===void 0||t===``?e:n(t)||e}function i(e){return`${r(e)}/v1/web`}function a(e){return`${r(e)}/v1/identify`}function o(e){return`${r(e)}/v1/replay`}function s(e){return`${r(e)}/v1/vitals`}function c(e){return e===void 0||e===``?t:n(e)||t}function l(e){return`${c(e)}/v1/check`}let u=!1;function d(e){u=e}function f(e){return e??u?``:p()}function p(){if(typeof localStorage>`u`)return``;let e=localStorage.getItem(`faststats_anon_id`);if(e)return e;let t=crypto.randomUUID();return localStorage.setItem(`faststats_anon_id`,t),t}function m(e){return e||typeof localStorage>`u`?``:(localStorage.removeItem(`faststats_anon_id`),p())}function h(){if(typeof sessionStorage>`u`)return``;let e=sessionStorage.getItem(`session_id`),t=sessionStorage.getItem(`session_timestamp`);if(e&&t){if(Date.now()-Number.parseInt(t,10)<18e5)return sessionStorage.setItem(`session_timestamp`,Date.now().toString()),e;sessionStorage.removeItem(`session_id`),sessionStorage.removeItem(`session_timestamp`),sessionStorage.removeItem(`session_start`)}let n=Date.now().toString(),r=crypto.randomUUID();return sessionStorage.setItem(`session_id`,r),sessionStorage.setItem(`session_timestamp`,n),sessionStorage.setItem(`session_start`,n),r}function g(){return typeof sessionStorage>`u`?``:(sessionStorage.removeItem(`session_id`),sessionStorage.removeItem(`session_timestamp`),sessionStorage.removeItem(`session_start`),h())}function _(){typeof sessionStorage>`u`||sessionStorage.getItem(`session_id`)&&sessionStorage.setItem(`session_timestamp`,Date.now().toString())}function v(){if(typeof sessionStorage>`u`)return Date.now();let e=sessionStorage.getItem(`session_start`);if(e)return Number.parseInt(e,10);let t=sessionStorage.getItem(`session_timestamp`);return t?Number.parseInt(t,10):Date.now()}function y(e){return typeof e!=`number`||!Number.isFinite(e)?100:Math.max(0,Math.min(100,e))}export{_ as a,d as c,r as d,c as f,s as h,v as i,l,i as m,f as n,m as o,o as p,h as r,g as s,y as t,a as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e,r as t,t as n}from"./types-Df70G0eM.js";import{onCLS as r,onFCP as i,onINP as a,onLCP as o,onTTFB as s}from"web-vitals/attribution";const c=[r,a,o,i,s];var l=class{endpoint;metrics=new Map;sampled;started=!1;flushed=!1;constructor(t){this.options=t,this.endpoint=e(t.baseUrl),this.sampled=Math.random()*100<n(t.samplingPercentage)}get debug(){return this.options.debug??!1}log(...e){this.debug&&console.log(`[WebVitals]`,...e)}start(){if(!(this.started||typeof window>`u`)){this.started=!0,this.flushed=!1,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`pagehide`,this.flush),this.log(`Tracking started`);for(let e of c)e(this.captureMetric)}}stop(){!this.started||typeof window>`u`||(this.started=!1,document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`pagehide`,this.flush),this.flush())}onVisibilityChange=()=>{document.visibilityState===`hidden`&&this.flush()};captureMetric=e=>{if(this.flushed||!this.sampled)return;let t=e.name;this.metrics.set(t,{value:e.value,attributes:{id:e.id,rating:e.rating,delta:e.delta,navigationType:e.navigationType,...e.attribution??{}}}),this.log(`${t} captured: ${e.value}`)};flush=()=>{if(this.flushed||this.metrics.size===0)return;this.flushed=!0;let e=[...this.metrics.entries()].map(([e,t])=>({metric:e,value:t.value,attributes:t.attributes})),n=e.map(e=>e.metric).join(`, `);this.metrics.clear();let r=JSON.stringify({sessionId:t(),vitals:e,metadata:{url:window.location.href}});this.log(`Sending final metrics (${e.length}): ${n}`),typeof fetch==`function`&&fetch(this.endpoint,{method:`POST`,body:r,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${this.options.siteKey}`},keepalive:!0}).catch(()=>{this.log(`Failed to send metrics`)})}};export{l as default};
|
package/src/module.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
type ConsentMode,
|
|
3
|
-
getInstance,
|
|
4
|
-
type IdentifyOptions,
|
|
5
|
-
identify,
|
|
6
|
-
isTrackingDisabled,
|
|
7
|
-
logout,
|
|
8
|
-
optIn,
|
|
9
|
-
optOut,
|
|
10
|
-
reportError,
|
|
11
|
-
sendData,
|
|
12
|
-
setConsentMode,
|
|
13
|
-
trackEvent,
|
|
14
|
-
WebAnalytics,
|
|
15
|
-
type WebAnalyticsOptions,
|
|
16
|
-
} from "./analytics";
|
|
17
|
-
export {
|
|
18
|
-
type FeatureFlagCheckContext,
|
|
19
|
-
type FeatureFlagEvaluation,
|
|
20
|
-
fetchFeatureFlagEvaluation,
|
|
21
|
-
} from "./feature-flags";
|
|
22
|
-
export {
|
|
23
|
-
featureFlagsCheckUrl,
|
|
24
|
-
normalizeFeatureFlagsBaseUrl,
|
|
25
|
-
} from "./utils/api-urls";
|