@levo-so/insights 0.1.82 → 0.1.85
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/constants/storageKeys.d.ts +6 -0
- package/dist/index.js +629 -664
- package/dist/stores/config.d.ts +4 -0
- package/dist/stores/events.d.ts +9 -8
- package/dist/stores/session.d.ts +19 -0
- package/dist/stores.js +2 -14
- package/dist/textSelection-DJ23SrA-.js +558 -0
- package/dist/types/options.d.ts +1 -1
- package/package.json +3 -4
- package/dist/legacy/index.d.ts +0 -71
- package/dist/textSelection-D4i1m603.js +0 -583
- package/dist/textSelection-N3vefCQW.js +0 -583
- package/dist/utils/lock.d.ts +0 -20
package/dist/index.js
CHANGED
|
@@ -1,665 +1,630 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getLevoError as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
e && T({ mode: "proxy", insightsBaseUrl: e });
|
|
629
|
-
});
|
|
630
|
-
const y = Z.subscribe((w) => {
|
|
631
|
-
if (!(!w || !_) && !m) {
|
|
632
|
-
const p = be(a, c, () => m === p);
|
|
633
|
-
m = p, C().insightsBaseUrl && m && (x.push(
|
|
634
|
-
J(),
|
|
635
|
-
V(m),
|
|
636
|
-
ee(m),
|
|
637
|
-
fe(m),
|
|
638
|
-
pe(m),
|
|
639
|
-
te(),
|
|
640
|
-
ge(m),
|
|
641
|
-
me(m),
|
|
642
|
-
ne(m),
|
|
643
|
-
re(m)
|
|
644
|
-
), r(), m.page({ resource: "page" }));
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
x.push(y);
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
destroy: () => {
|
|
652
|
-
_ && (N(X()), Y(), x.forEach((o) => {
|
|
653
|
-
o();
|
|
654
|
-
}), x.length = 0, m = null, _ = !1);
|
|
655
|
-
},
|
|
656
|
-
track: c,
|
|
657
|
-
get instance() {
|
|
658
|
-
return m;
|
|
659
|
-
}
|
|
660
|
-
};
|
|
661
|
-
};
|
|
662
|
-
export {
|
|
663
|
-
Pe as AnalyticsEvents,
|
|
664
|
-
Le as createLevoInsights
|
|
1
|
+
import { A as e, C as t, D as n, E as r, M as i, O as a, S as o, T as s, b as c, c as l, f as u, i as d, j as f, k as p, l as m, m as h, n as g, o as _, s as v, u as y, v as b, w as x, x as S, y as C } from "./textSelection-DJ23SrA-.js";
|
|
2
|
+
import { AnalyticsEvents as w, getLevoError as T } from "@levo-so/core";
|
|
3
|
+
import { getVisitorSource as E } from "@analytics/visitor-source";
|
|
4
|
+
import D from "get-user-locale";
|
|
5
|
+
import { Analytics as O } from "analytics";
|
|
6
|
+
//#region src/utils/rageclick.ts
|
|
7
|
+
var k = 30, A = 1e3, j = 3, M = [], N = (e, t, n) => {
|
|
8
|
+
let r = M[M.length - 1];
|
|
9
|
+
if (r && Math.abs(e - r.x) + Math.abs(t - r.y) < k && n - r.timestamp < A) {
|
|
10
|
+
if (M.push({
|
|
11
|
+
x: e,
|
|
12
|
+
y: t,
|
|
13
|
+
timestamp: n
|
|
14
|
+
}), M.length >= j) return M = [], !0;
|
|
15
|
+
} else M = [{
|
|
16
|
+
x: e,
|
|
17
|
+
y: t,
|
|
18
|
+
timestamp: n
|
|
19
|
+
}];
|
|
20
|
+
return !1;
|
|
21
|
+
}, P = (e) => {
|
|
22
|
+
let t = e, n = 0;
|
|
23
|
+
for (; t && n < 10;) {
|
|
24
|
+
let e = t.getAttribute?.("href");
|
|
25
|
+
if (e) return e;
|
|
26
|
+
t = t.parentElement, n++;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}, F = (e) => {
|
|
30
|
+
let t = e.closest("a[href]"), n = t?.getAttribute("href") || P(e);
|
|
31
|
+
if (!n) return {
|
|
32
|
+
type: null,
|
|
33
|
+
href: null
|
|
34
|
+
};
|
|
35
|
+
if (t?.hasAttribute("download")) return {
|
|
36
|
+
type: "download",
|
|
37
|
+
href: n
|
|
38
|
+
};
|
|
39
|
+
if (n.startsWith("tel:")) return {
|
|
40
|
+
type: "tel",
|
|
41
|
+
href: n
|
|
42
|
+
};
|
|
43
|
+
if (n.startsWith("mailto:")) return {
|
|
44
|
+
type: "mailto",
|
|
45
|
+
href: n
|
|
46
|
+
};
|
|
47
|
+
if (n.startsWith("#")) return {
|
|
48
|
+
type: "anchor",
|
|
49
|
+
href: n
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
return {
|
|
53
|
+
type: new URL(n, window.location.origin).origin === window.location.origin ? "internal" : "external",
|
|
54
|
+
href: n
|
|
55
|
+
};
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return console.warn("[insights] Failed to classify link", T(e)), {
|
|
58
|
+
type: "internal",
|
|
59
|
+
href: n
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}, I = (e) => {
|
|
63
|
+
if (typeof window > "u") return () => {};
|
|
64
|
+
let t = 0, n = null, r = (e, t = !1, n) => {
|
|
65
|
+
let r = n ?? m(e), i = "clientX" in e ? e.clientX : e.changedTouches?.[0]?.clientX ?? 0, a = "clientY" in e ? e.clientY : e.changedTouches?.[0]?.clientY ?? 0, o = {
|
|
66
|
+
hostname: window.location.hostname,
|
|
67
|
+
pathname: window.location.pathname,
|
|
68
|
+
page_title: document.title,
|
|
69
|
+
url: window.location.href,
|
|
70
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
71
|
+
event_type: t ? "dblclick" : "click",
|
|
72
|
+
button_type: "button" in e ? e.button : 0
|
|
73
|
+
};
|
|
74
|
+
return r instanceof HTMLElement && (o.rage_click = N(i, a, Date.now()), o = {
|
|
75
|
+
...o,
|
|
76
|
+
...l(r)
|
|
77
|
+
}), o;
|
|
78
|
+
}, i = (n, i, a) => {
|
|
79
|
+
try {
|
|
80
|
+
if (Date.now() - t < 300) return;
|
|
81
|
+
let o = r(n, !1, a);
|
|
82
|
+
e.track("page.click", {
|
|
83
|
+
...o,
|
|
84
|
+
href: i.href || void 0,
|
|
85
|
+
link_type: i.type,
|
|
86
|
+
is_navigation: !0
|
|
87
|
+
});
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error("[insights] Failed to track navigation click", T(e));
|
|
90
|
+
}
|
|
91
|
+
}, a = (n, i = !1, a) => {
|
|
92
|
+
try {
|
|
93
|
+
let o = a ?? m(n);
|
|
94
|
+
if (!o || Date.now() - t < 300) return;
|
|
95
|
+
let s = r(n, i, o), c = F(o);
|
|
96
|
+
e.track("page.click", {
|
|
97
|
+
...s,
|
|
98
|
+
href: c.href || void 0,
|
|
99
|
+
link_type: c.type || void 0
|
|
100
|
+
});
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error("[insights] Failed to track click", T(e));
|
|
103
|
+
}
|
|
104
|
+
}, o = (e) => {
|
|
105
|
+
let t = m(e);
|
|
106
|
+
if (!t) return;
|
|
107
|
+
let r = F(t);
|
|
108
|
+
if (r.type === "external" || r.type === "download") {
|
|
109
|
+
i(e, r, t);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (n) {
|
|
113
|
+
clearTimeout(n), n = null;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
n = setTimeout(() => {
|
|
117
|
+
a(e, !1, t), n = null;
|
|
118
|
+
}, 250);
|
|
119
|
+
}, s = (e) => {
|
|
120
|
+
n &&= (clearTimeout(n), null), a(e, !0, m(e) ?? void 0);
|
|
121
|
+
}, c = (n) => {
|
|
122
|
+
try {
|
|
123
|
+
let i = m(n);
|
|
124
|
+
if (!i) return;
|
|
125
|
+
t = Date.now();
|
|
126
|
+
let a = F(i);
|
|
127
|
+
if (a.type === "external" || a.type === "download") {
|
|
128
|
+
let t = r(n, !1, i);
|
|
129
|
+
e.track("page.click", {
|
|
130
|
+
...t,
|
|
131
|
+
href: a.href || void 0,
|
|
132
|
+
link_type: a.type,
|
|
133
|
+
is_navigation: !0,
|
|
134
|
+
is_touch: !0
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
let o = r(n, !1, i);
|
|
139
|
+
e.track("page.click", {
|
|
140
|
+
...o,
|
|
141
|
+
href: a.href || void 0,
|
|
142
|
+
link_type: a.type || void 0,
|
|
143
|
+
is_touch: !0
|
|
144
|
+
});
|
|
145
|
+
} catch (e) {
|
|
146
|
+
console.error("[insights] Failed to track touch", T(e));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return document.addEventListener("click", o), document.addEventListener("dblclick", s), document.addEventListener("touchend", c, { passive: !0 }), () => {
|
|
150
|
+
document.removeEventListener("click", o), document.removeEventListener("dblclick", s), document.removeEventListener("touchend", c), n && clearTimeout(n);
|
|
151
|
+
};
|
|
152
|
+
}, L = (e) => {
|
|
153
|
+
if (typeof window > "u") return () => {};
|
|
154
|
+
let t = (t) => (n) => {
|
|
155
|
+
try {
|
|
156
|
+
let r = y(n, t);
|
|
157
|
+
r && e.track("page.copy", r);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.error(`[insights] Failed to track clipboard ${t}`, T(e));
|
|
160
|
+
}
|
|
161
|
+
}, n = t("copy"), r = t("cut");
|
|
162
|
+
return document.addEventListener("copy", n, { capture: !0 }), document.addEventListener("cut", r, { capture: !0 }), () => {
|
|
163
|
+
document.removeEventListener("copy", n, { capture: !0 }), document.removeEventListener("cut", r, { capture: !0 });
|
|
164
|
+
};
|
|
165
|
+
}, R = (e) => {
|
|
166
|
+
if (typeof window > "u") return () => {};
|
|
167
|
+
let t = (t) => (n) => {
|
|
168
|
+
try {
|
|
169
|
+
let r = y(n, t);
|
|
170
|
+
if (r) {
|
|
171
|
+
let n = t === "submit" ? "form.submit" : "form.change";
|
|
172
|
+
e.track(n, r);
|
|
173
|
+
}
|
|
174
|
+
} catch (e) {
|
|
175
|
+
console.error(`[insights] Failed to track form ${t}`, T(e));
|
|
176
|
+
}
|
|
177
|
+
}, n = t("change"), r = t("submit");
|
|
178
|
+
return document.addEventListener("change", n, { capture: !0 }), document.addEventListener("submit", r, { capture: !0 }), () => {
|
|
179
|
+
document.removeEventListener("change", n, { capture: !0 }), document.removeEventListener("submit", r, { capture: !0 });
|
|
180
|
+
};
|
|
181
|
+
}, z = (e) => {
|
|
182
|
+
if (typeof window > "u") return () => {};
|
|
183
|
+
let { page_id: t } = p.get(), n = t || "", r = typeof window < "u" ? window.location.href : "", i = () => {
|
|
184
|
+
let { isIdentified: t } = x.get();
|
|
185
|
+
if (t) try {
|
|
186
|
+
e.page({ resource: "page" });
|
|
187
|
+
} catch (e) {
|
|
188
|
+
console.error("[insights] Failed to send page view", T(e));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
if (t) {
|
|
192
|
+
let e = p.listen((e, t, r) => {
|
|
193
|
+
let { page_id: a } = e;
|
|
194
|
+
r === "page_id" && a && n !== a && (n = a, i());
|
|
195
|
+
});
|
|
196
|
+
return () => {
|
|
197
|
+
e();
|
|
198
|
+
};
|
|
199
|
+
} else {
|
|
200
|
+
let e = () => {
|
|
201
|
+
if (typeof window > "u") return;
|
|
202
|
+
let e = window.location.href;
|
|
203
|
+
e !== r && (r = e, i());
|
|
204
|
+
};
|
|
205
|
+
window.addEventListener("popstate", e);
|
|
206
|
+
let t = window.history.pushState;
|
|
207
|
+
return window.history.pushState = function(...n) {
|
|
208
|
+
t.apply(this, n), e();
|
|
209
|
+
}, () => {
|
|
210
|
+
window.removeEventListener("popstate", e), window.history.pushState = t;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}, B = async (e, t) => {
|
|
214
|
+
let n = null;
|
|
215
|
+
try {
|
|
216
|
+
let r = new AbortController();
|
|
217
|
+
return n = setTimeout(() => r.abort(), t), (await fetch(e, {
|
|
218
|
+
method: "GET",
|
|
219
|
+
signal: r.signal,
|
|
220
|
+
credentials: "omit"
|
|
221
|
+
})).ok;
|
|
222
|
+
} catch {
|
|
223
|
+
return !1;
|
|
224
|
+
} finally {
|
|
225
|
+
n && clearTimeout(n);
|
|
226
|
+
}
|
|
227
|
+
}, V = async (e) => {
|
|
228
|
+
let { mode: t = "auto", insightsUrl: n, directInsightsUrl: r, pingTimeout: i = 1e3, debug: a = !1 } = e;
|
|
229
|
+
if (a) return {
|
|
230
|
+
mode: "proxy",
|
|
231
|
+
url: n || "/debug-api"
|
|
232
|
+
};
|
|
233
|
+
let o = Number.isFinite(i) && i > 0 ? i : 1e3;
|
|
234
|
+
if (t === "direct") return {
|
|
235
|
+
mode: "direct",
|
|
236
|
+
url: r ?? null
|
|
237
|
+
};
|
|
238
|
+
if (t === "proxy" || !r) return {
|
|
239
|
+
mode: "proxy",
|
|
240
|
+
url: n ?? null
|
|
241
|
+
};
|
|
242
|
+
let [s, c] = await Promise.all([n ? B(`${n}/ping`, o) : Promise.resolve(!1), r ? B(`${r}/ping`, o) : Promise.resolve(!1)]);
|
|
243
|
+
return s ? {
|
|
244
|
+
mode: "proxy",
|
|
245
|
+
url: n ?? null
|
|
246
|
+
} : c ? {
|
|
247
|
+
mode: "direct",
|
|
248
|
+
url: r
|
|
249
|
+
} : {
|
|
250
|
+
mode: "proxy",
|
|
251
|
+
url: n ?? null
|
|
252
|
+
};
|
|
253
|
+
}, H = () => {
|
|
254
|
+
if (typeof document > "u") return {};
|
|
255
|
+
let { type: e, referrer: t, data: n = {} } = E({
|
|
256
|
+
referrer: document.referrer,
|
|
257
|
+
currentUrl: window.location.href,
|
|
258
|
+
mapper: null
|
|
259
|
+
}), r = Object.keys(n);
|
|
260
|
+
for (let e of r) n[e] && Array.isArray(n[e]) && n[e].length > 0 && (n[e] = n[e]?.[0]);
|
|
261
|
+
return {
|
|
262
|
+
type: e,
|
|
263
|
+
referrer: t,
|
|
264
|
+
data: n,
|
|
265
|
+
raw: document.referrer
|
|
266
|
+
};
|
|
267
|
+
}, U = () => new Promise((e, t) => {
|
|
268
|
+
let n = "Unknown";
|
|
269
|
+
function r(t) {
|
|
270
|
+
e({
|
|
271
|
+
isPrivate: t,
|
|
272
|
+
browserName: n
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function i() {
|
|
276
|
+
let e = navigator.userAgent;
|
|
277
|
+
return e.match(/Chrome/) ? navigator.brave === void 0 ? e.match(/Edg/) ? "Edge" : e.match(/OPR/) ? "Opera" : "Chrome" : "Brave" : "Chromium";
|
|
278
|
+
}
|
|
279
|
+
function a(e) {
|
|
280
|
+
return e === eval.toString().length;
|
|
281
|
+
}
|
|
282
|
+
function o() {
|
|
283
|
+
let e = navigator.vendor;
|
|
284
|
+
return e !== void 0 && e.indexOf("Apple") === 0 && a(37);
|
|
285
|
+
}
|
|
286
|
+
function s() {
|
|
287
|
+
let e = navigator.vendor;
|
|
288
|
+
return e !== void 0 && e.indexOf("Google") === 0 && a(33);
|
|
289
|
+
}
|
|
290
|
+
function c() {
|
|
291
|
+
return document.documentElement !== void 0 && document.documentElement.style.MozAppearance !== void 0 && a(37);
|
|
292
|
+
}
|
|
293
|
+
function l() {
|
|
294
|
+
return navigator.msSaveBlob !== void 0 && a(39);
|
|
295
|
+
}
|
|
296
|
+
function u() {
|
|
297
|
+
let e = String(Math.random());
|
|
298
|
+
try {
|
|
299
|
+
let t = window.indexedDB.open(e, 1);
|
|
300
|
+
t.onupgradeneeded = (t) => {
|
|
301
|
+
let n = t.target?.result;
|
|
302
|
+
try {
|
|
303
|
+
n.createObjectStore("test", { autoIncrement: !0 }).put(new Blob()), r(!1);
|
|
304
|
+
} catch (e) {
|
|
305
|
+
let t = e;
|
|
306
|
+
return e instanceof Error && (t = e.message ?? e), r(typeof t == "string" ? /BlobURLs are not yet supported/.test(t) : !1);
|
|
307
|
+
} finally {
|
|
308
|
+
n.close(), window.indexedDB.deleteDatabase(e);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
} catch {
|
|
312
|
+
return r(!1);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function d() {
|
|
316
|
+
let e = window.openDatabase, t = window.localStorage;
|
|
317
|
+
try {
|
|
318
|
+
e(null, null, null, null);
|
|
319
|
+
} catch {
|
|
320
|
+
return r(!0);
|
|
321
|
+
}
|
|
322
|
+
try {
|
|
323
|
+
t.setItem("test", "1"), t.removeItem("test");
|
|
324
|
+
} catch {
|
|
325
|
+
return r(!0);
|
|
326
|
+
}
|
|
327
|
+
return r(!1);
|
|
328
|
+
}
|
|
329
|
+
function f() {
|
|
330
|
+
navigator.maxTouchPoints === void 0 ? d() : u();
|
|
331
|
+
}
|
|
332
|
+
function p() {
|
|
333
|
+
let e = window;
|
|
334
|
+
return e.performance !== void 0 && e.performance.memory !== void 0 && e.performance.memory.jsHeapSizeLimit !== void 0 ? performance.memory.jsHeapSizeLimit : 1073741824;
|
|
335
|
+
}
|
|
336
|
+
function m() {
|
|
337
|
+
navigator.webkitTemporaryStorage.queryUsageAndQuota((e, t) => {
|
|
338
|
+
r(Math.round(t / (1024 * 1024)) < Math.round(p() / (1024 * 1024)) * 2);
|
|
339
|
+
}, (e) => {
|
|
340
|
+
t(/* @__PURE__ */ Error(`detectIncognito somehow failed to query storage quota: ${e.message}`));
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function h() {
|
|
344
|
+
let e = window.webkitRequestFileSystem;
|
|
345
|
+
e(0, 1, () => {
|
|
346
|
+
r(!1);
|
|
347
|
+
}, () => {
|
|
348
|
+
r(!0);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function g() {
|
|
352
|
+
self.Promise !== void 0 && self.Promise.allSettled !== void 0 ? m() : h();
|
|
353
|
+
}
|
|
354
|
+
function _() {
|
|
355
|
+
r(navigator.serviceWorker === void 0);
|
|
356
|
+
}
|
|
357
|
+
function v() {
|
|
358
|
+
r(window.indexedDB === void 0);
|
|
359
|
+
}
|
|
360
|
+
function y() {
|
|
361
|
+
o() ? (n = "Safari", f()) : s() ? (n = i(), g()) : c() ? (n = "Firefox", _()) : l() ? (n = "Internet Explorer", v()) : t(/* @__PURE__ */ Error("detectIncognito cannot determine the browser"));
|
|
362
|
+
}
|
|
363
|
+
y();
|
|
364
|
+
}), W = () => {
|
|
365
|
+
let e = document.createElement("canvas"), t = e?.getContext("webgl") || e?.getContext("experimental-webgl");
|
|
366
|
+
if (!t) return null;
|
|
367
|
+
let n = t?.getExtension("WEBGL_debug_renderer_info");
|
|
368
|
+
return n ? t?.getParameter(n.UNMASKED_RENDERER_WEBGL) : null;
|
|
369
|
+
}, G = async () => {
|
|
370
|
+
let e = "", t = "", n = !1, r = !1, i = {};
|
|
371
|
+
if (!window) return {
|
|
372
|
+
locale: e,
|
|
373
|
+
timezone: t,
|
|
374
|
+
dark_mode: n,
|
|
375
|
+
private_mode: r,
|
|
376
|
+
properties: i
|
|
377
|
+
};
|
|
378
|
+
let [a, o, s] = await Promise.allSettled([
|
|
379
|
+
U(),
|
|
380
|
+
navigator.getBattery?.() ?? Promise.reject(),
|
|
381
|
+
"mediaDevices" in navigator ? navigator.mediaDevices.enumerateDevices() : Promise.reject()
|
|
382
|
+
]);
|
|
383
|
+
a.status === "fulfilled" && (r = a.value.isPrivate);
|
|
384
|
+
try {
|
|
385
|
+
n = window.matchMedia?.("(prefers-color-scheme: dark)").matches;
|
|
386
|
+
} catch (e) {
|
|
387
|
+
console.error(e);
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
t = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
391
|
+
} catch (e) {
|
|
392
|
+
console.error(e);
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
e = D();
|
|
396
|
+
} catch (e) {
|
|
397
|
+
console.error(e);
|
|
398
|
+
}
|
|
399
|
+
let c = navigator, l = c.connection ?? c.mozConnection ?? c.webkitConnection;
|
|
400
|
+
if (l && (i.network_type = l.effectiveType), i.width = window?.innerWidth, i.height = window?.innerHeight, i.pixel_ratio = window?.devicePixelRatio, screen && (i.screen_width = screen?.width, i.screen_height = screen?.height, i.color_depth = screen?.colorDepth, i.orientation = screen?.orientation?.type), o.status === "fulfilled") {
|
|
401
|
+
let e = o.value;
|
|
402
|
+
i.battery_level = Number((e?.level * 100).toFixed(0)), i.battery_charging = e?.charging, i.battery_discharging_time = e?.dischargingTime, i.battery_full_charge_capacity = e?.fullChargeCapacity, i.battery_charging_time = e?.chargingTime;
|
|
403
|
+
}
|
|
404
|
+
if (navigator && "deviceMemory" in navigator && (i.device_memory = navigator?.deviceMemory), i.touch_supported = "ontouchstart" in window || navigator?.maxTouchPoints !== void 0 && navigator?.maxTouchPoints > 0, "hardwareConcurrency" in navigator && (i.hardware_concurrency = navigator?.hardwareConcurrency), s.status === "fulfilled") {
|
|
405
|
+
let e = s.value;
|
|
406
|
+
i.camera_supported = e.some((e) => e?.kind === "videoinput"), i.microphone_supported = e.some((e) => e?.kind === "audioinput");
|
|
407
|
+
}
|
|
408
|
+
return i.gpu = W(), {
|
|
409
|
+
locale: e,
|
|
410
|
+
timezone: t,
|
|
411
|
+
dark_mode: n,
|
|
412
|
+
private_mode: r,
|
|
413
|
+
properties: i
|
|
414
|
+
};
|
|
415
|
+
}, K = (t, r, i) => {
|
|
416
|
+
let { debug: l } = e();
|
|
417
|
+
if (!t) return null;
|
|
418
|
+
let u = {
|
|
419
|
+
name: t.workspace,
|
|
420
|
+
track: ({ payload: e }) => {
|
|
421
|
+
if (!i()) return;
|
|
422
|
+
let t = e?.properties || {};
|
|
423
|
+
r(e.event, t);
|
|
424
|
+
},
|
|
425
|
+
page: ({ payload: e }) => {
|
|
426
|
+
i() && (o(), r("page.view", {
|
|
427
|
+
...e?.properties || {},
|
|
428
|
+
resource: "page"
|
|
429
|
+
}));
|
|
430
|
+
},
|
|
431
|
+
identify: ({ payload: r }) => {
|
|
432
|
+
if (!i()) return;
|
|
433
|
+
let { workspace: o, site_id: l, debug: u } = e(), { mode: d, isIdentified: f, isIdentifying: p, sessionToken: m, deviceToken: h, insightsBaseUrl: g, identity: v } = s(), y = _(), b = s().allTabs.length;
|
|
434
|
+
if (!g || !v) return;
|
|
435
|
+
let x = {
|
|
436
|
+
private_mode: r.traits?.private_mode ?? v.privateMode ?? !1,
|
|
437
|
+
dark_mode: r.traits?.dark_mode ?? v.darkMode ?? !1,
|
|
438
|
+
timezone: r.traits?.timezone ?? v.timezone ?? "",
|
|
439
|
+
locale: r.traits?.locale ?? v.locale ?? "",
|
|
440
|
+
referrer: r.traits?.referrer ?? v.referrer ?? {
|
|
441
|
+
type: "",
|
|
442
|
+
referrer: {},
|
|
443
|
+
data: {}
|
|
444
|
+
},
|
|
445
|
+
properties: {
|
|
446
|
+
...v.properties,
|
|
447
|
+
...r.traits?.properties
|
|
448
|
+
},
|
|
449
|
+
workspace_id: o ?? "",
|
|
450
|
+
site_id: l ?? void 0,
|
|
451
|
+
hostname: window.location.hostname,
|
|
452
|
+
pathname: window.location.pathname,
|
|
453
|
+
page_title: document.title,
|
|
454
|
+
url: window.location.href,
|
|
455
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
456
|
+
tab_id: y ?? "",
|
|
457
|
+
tab_count: b ?? 0
|
|
458
|
+
};
|
|
459
|
+
if (u && console.log("[@levo-so/insights] Identification triggered:", {
|
|
460
|
+
isIdentified: f,
|
|
461
|
+
isIdentifying: p,
|
|
462
|
+
welcomeInput: x
|
|
463
|
+
}), f || p) return;
|
|
464
|
+
if (n({ isIdentifying: !0 }), u) {
|
|
465
|
+
console.log("[@levo-so/insights] Debug mode enabled. Mocking session identification."), n({
|
|
466
|
+
isIdentified: !0,
|
|
467
|
+
isIdentifying: !1,
|
|
468
|
+
sessionId: "debug-session",
|
|
469
|
+
deviceId: "debug-device"
|
|
470
|
+
}), C(c());
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
let S = {
|
|
474
|
+
Accept: "application/json",
|
|
475
|
+
"Content-Type": "application/json",
|
|
476
|
+
...a({
|
|
477
|
+
sessionToken: m,
|
|
478
|
+
deviceToken: h,
|
|
479
|
+
mode: d
|
|
480
|
+
})
|
|
481
|
+
}, w = (e = 0) => {
|
|
482
|
+
t.fetch.url(g, !0).url("/v1/insights/event/welcome").options({
|
|
483
|
+
keepalive: !0,
|
|
484
|
+
credentials: d === "proxy" ? "include" : "omit"
|
|
485
|
+
}).headers(S).post(x).json().then((e) => {
|
|
486
|
+
if (!i()) {
|
|
487
|
+
n({ isIdentifying: !1 });
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
let { isIdentified: t } = s();
|
|
491
|
+
if (t) n({ isIdentifying: !1 });
|
|
492
|
+
else {
|
|
493
|
+
let t = {
|
|
494
|
+
isIdentified: !0,
|
|
495
|
+
isIdentifying: !1
|
|
496
|
+
};
|
|
497
|
+
if (e?.content?.data?.session && (t.sessionId = e?.content?.data?.session), e?.content?.data?.device && (t.deviceId = e?.content?.data?.device), d === "direct" && e?.content?.meta) {
|
|
498
|
+
let n = e.content.meta;
|
|
499
|
+
n.device_token && (t.deviceToken = n.device_token), n.session_token && (t.sessionToken = n.session_token);
|
|
500
|
+
}
|
|
501
|
+
n(t), C(c());
|
|
502
|
+
}
|
|
503
|
+
}).catch((r) => {
|
|
504
|
+
if (t.logger?.error("/welcome failed with error", T(r)), e < 2 && i()) {
|
|
505
|
+
let t = 5e3 * 2 ** e;
|
|
506
|
+
setTimeout(() => {
|
|
507
|
+
i() && !s().isIdentified ? w(e + 1) : n({ isIdentifying: !1 });
|
|
508
|
+
}, t);
|
|
509
|
+
} else n({ isIdentifying: !1 });
|
|
510
|
+
});
|
|
511
|
+
};
|
|
512
|
+
w();
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
return O({
|
|
516
|
+
app: t.workspace || "",
|
|
517
|
+
debug: !!l,
|
|
518
|
+
plugins: [u]
|
|
519
|
+
});
|
|
520
|
+
}, q = null, J = !1, Y = [], X = (a, o) => {
|
|
521
|
+
let { insightsUrl: l, debug: p = !1, site: m = null } = o;
|
|
522
|
+
f({
|
|
523
|
+
workspace: a.workspace,
|
|
524
|
+
debug: p,
|
|
525
|
+
site_id: m
|
|
526
|
+
}), typeof window < "u" && Promise.all([G(), H()]).then(([e, t]) => {
|
|
527
|
+
let r = t?.type ? {
|
|
528
|
+
type: t.type,
|
|
529
|
+
referrer: t.referrer,
|
|
530
|
+
data: t.data,
|
|
531
|
+
raw: t.raw ?? ""
|
|
532
|
+
} : null;
|
|
533
|
+
n({ identity: {
|
|
534
|
+
locale: e.locale,
|
|
535
|
+
timezone: e.timezone,
|
|
536
|
+
darkMode: e.dark_mode,
|
|
537
|
+
privateMode: e.private_mode,
|
|
538
|
+
referrer: r,
|
|
539
|
+
properties: e.properties
|
|
540
|
+
} });
|
|
541
|
+
}).catch(() => {
|
|
542
|
+
n({ identity: {
|
|
543
|
+
locale: null,
|
|
544
|
+
timezone: null,
|
|
545
|
+
darkMode: null,
|
|
546
|
+
privateMode: null,
|
|
547
|
+
referrer: null,
|
|
548
|
+
properties: null
|
|
549
|
+
} });
|
|
550
|
+
});
|
|
551
|
+
let y = async (t, n) => {
|
|
552
|
+
if (typeof window > "u") return;
|
|
553
|
+
let { page_id: r } = e(), { allTabs: i } = s(), a = _(), o = i.length;
|
|
554
|
+
S({
|
|
555
|
+
event: t,
|
|
556
|
+
version: n?.version || 1,
|
|
557
|
+
properties: {
|
|
558
|
+
...n,
|
|
559
|
+
version: void 0,
|
|
560
|
+
resource: void 0,
|
|
561
|
+
identifier: void 0,
|
|
562
|
+
hostname: void 0,
|
|
563
|
+
pathname: void 0,
|
|
564
|
+
url: void 0,
|
|
565
|
+
page_title: void 0,
|
|
566
|
+
created_at: void 0
|
|
567
|
+
},
|
|
568
|
+
hostname: window.location.hostname,
|
|
569
|
+
pathname: window.location.pathname,
|
|
570
|
+
url: n?.url ?? window.location.href,
|
|
571
|
+
page_title: n?.page_title ?? document.title,
|
|
572
|
+
resource: n?.resource ?? "page",
|
|
573
|
+
identifier: n?.id ?? r ?? void 0,
|
|
574
|
+
created_at: n?.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
575
|
+
tab_id: a ?? "",
|
|
576
|
+
tab_count: o
|
|
577
|
+
});
|
|
578
|
+
}, x = (e) => {
|
|
579
|
+
!q || !J || q.identify("", { withLock: e?.withLock ?? !0 });
|
|
580
|
+
}, w = (t) => {
|
|
581
|
+
let { page_id: n } = e();
|
|
582
|
+
n !== t && i("page_id", t);
|
|
583
|
+
};
|
|
584
|
+
return {
|
|
585
|
+
init: (e = {}) => {
|
|
586
|
+
if (typeof window > "u") throw Error("[@levo-so/insights] init() should only be called on the client side.");
|
|
587
|
+
let { pageId: i } = e;
|
|
588
|
+
if (i && w(i), J || a.NODE_ENV === "development" && !p) return;
|
|
589
|
+
if (!l) {
|
|
590
|
+
console.error("[@levo-so/insights] The utility could not be initialized due to missing insights endpoint.");
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
J = !0;
|
|
594
|
+
let c = s();
|
|
595
|
+
c.mode === "direct" && c.isIdentified && (!c.sessionToken || !c.deviceToken) && n({ isIdentified: !1 }), r(() => {
|
|
596
|
+
if (!J) return;
|
|
597
|
+
let { insightsBaseUrl: e } = s();
|
|
598
|
+
e || V(o).then(({ mode: e, url: t }) => {
|
|
599
|
+
J && t && n({
|
|
600
|
+
mode: e,
|
|
601
|
+
insightsBaseUrl: t
|
|
602
|
+
});
|
|
603
|
+
}).catch(() => {
|
|
604
|
+
J && l && n({
|
|
605
|
+
mode: "proxy",
|
|
606
|
+
insightsBaseUrl: l
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
let r = t.subscribe((e) => {
|
|
610
|
+
if (!(!e || !J) && !q) {
|
|
611
|
+
let e = K(a, y, () => q === e);
|
|
612
|
+
q = e, s().insightsBaseUrl && q && (Y.push(h(q), u(q), I(q), L(q), v(q), R(q), z(q), d(q), g(q)), x(), q.page({ resource: "page" }));
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
Y.push(r);
|
|
616
|
+
});
|
|
617
|
+
},
|
|
618
|
+
destroy: () => {
|
|
619
|
+
J &&= (C(c()), b(), Y.forEach((e) => {
|
|
620
|
+
e();
|
|
621
|
+
}), Y.length = 0, q = null, !1);
|
|
622
|
+
},
|
|
623
|
+
track: y,
|
|
624
|
+
get instance() {
|
|
625
|
+
return q;
|
|
626
|
+
}
|
|
627
|
+
};
|
|
665
628
|
};
|
|
629
|
+
//#endregion
|
|
630
|
+
export { w as AnalyticsEvents, X as createLevoInsights };
|