@extn/segi-js 0.2.9 → 0.2.12
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/cdn.global.js +27 -28
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/dist/replay/index.d.mts +5 -5
- package/dist/replay/index.d.ts +5 -5
- package/dist/replay/index.js +36 -183
- package/dist/replay/index.mjs +14 -161
- package/dist/{types-DfmnOA9D.d.mts → types-CsgcNSc1.d.mts} +5 -5
- package/dist/{types-DfmnOA9D.d.ts → types-CsgcNSc1.d.ts} +5 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SegiClientOptions, SegiEventDto, SegiUser, SegiBreadcrumb } from '@extn/segi-shared';
|
|
2
2
|
export { SegiBreadcrumb, SegiClientOptions, SegiEventDto, SegiUser } from '@extn/segi-shared';
|
|
3
|
-
import { R as ReplayConfig } from './types-
|
|
3
|
+
import { R as ReplayConfig } from './types-CsgcNSc1.mjs';
|
|
4
4
|
|
|
5
5
|
interface InitOptions {
|
|
6
6
|
/** Re-initialize even if already initialized. Replaces config and listeners. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SegiClientOptions, SegiEventDto, SegiUser, SegiBreadcrumb } from '@extn/segi-shared';
|
|
2
2
|
export { SegiBreadcrumb, SegiClientOptions, SegiEventDto, SegiUser } from '@extn/segi-shared';
|
|
3
|
-
import { R as ReplayConfig } from './types-
|
|
3
|
+
import { R as ReplayConfig } from './types-CsgcNSc1.js';
|
|
4
4
|
|
|
5
5
|
interface InitOptions {
|
|
6
6
|
/** Re-initialize even if already initialized. Replaces config and listeners. */
|
package/dist/index.js
CHANGED
|
@@ -151,6 +151,8 @@ function captureWindowError(event) {
|
|
|
151
151
|
if (event instanceof ErrorEvent) {
|
|
152
152
|
const err = event.error;
|
|
153
153
|
const message = _nullishCoalesce(_nullishCoalesce(_optionalChain([err, 'optionalAccess', _ => _.message]), () => ( event.message)), () => ( "Error"));
|
|
154
|
+
if (event.error == null && (!event.message || /^Script error\.?$/i.test(event.message)) && !event.filename)
|
|
155
|
+
return;
|
|
154
156
|
Segi.captureException(_nullishCoalesce(err, () => ( new Error(message))), {
|
|
155
157
|
message,
|
|
156
158
|
url: typeof location !== "undefined" ? location.href : void 0
|
package/dist/index.mjs
CHANGED
|
@@ -151,6 +151,8 @@ function captureWindowError(event) {
|
|
|
151
151
|
if (event instanceof ErrorEvent) {
|
|
152
152
|
const err = event.error;
|
|
153
153
|
const message = err?.message ?? event.message ?? "Error";
|
|
154
|
+
if (event.error == null && (!event.message || /^Script error\.?$/i.test(event.message)) && !event.filename)
|
|
155
|
+
return;
|
|
154
156
|
Segi.captureException(err ?? new Error(message), {
|
|
155
157
|
message,
|
|
156
158
|
url: typeof location !== "undefined" ? location.href : void 0
|
package/dist/replay/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ReplayConfig, a as ReplayOptions } from '../types-
|
|
1
|
+
import { R as ReplayConfig, a as ReplayOptions } from '../types-CsgcNSc1.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Replay orchestrator. Exposed at `@extn/segi-js/replay`.
|
|
@@ -20,13 +20,13 @@ import { R as ReplayConfig, a as ReplayOptions } from '../types-DfmnOA9D.mjs';
|
|
|
20
20
|
* Segi.replay.notifyRouteChange();
|
|
21
21
|
*
|
|
22
22
|
* Activation is async because:
|
|
23
|
-
* - we POST /api/trace/session/start before
|
|
24
|
-
*
|
|
23
|
+
* - we POST /api/trace/session/start before rrweb attaches, so the server
|
|
24
|
+
* can short-circuit a recording-off project
|
|
25
25
|
* - this also lets the client honor the project-level recording toggle
|
|
26
26
|
* without redeploying the SDK
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* rrweb DOM replay is dynamic-imported (see ./rrweb) so apps that don't opt
|
|
29
|
+
* in pay zero rrweb bytes. Chunks POST to /api/trace/replay.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
declare function withReplay(options?: ReplayOptions): ReplayConfig;
|
package/dist/replay/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ReplayConfig, a as ReplayOptions } from '../types-
|
|
1
|
+
import { R as ReplayConfig, a as ReplayOptions } from '../types-CsgcNSc1.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Replay orchestrator. Exposed at `@extn/segi-js/replay`.
|
|
@@ -20,13 +20,13 @@ import { R as ReplayConfig, a as ReplayOptions } from '../types-DfmnOA9D.js';
|
|
|
20
20
|
* Segi.replay.notifyRouteChange();
|
|
21
21
|
*
|
|
22
22
|
* Activation is async because:
|
|
23
|
-
* - we POST /api/trace/session/start before
|
|
24
|
-
*
|
|
23
|
+
* - we POST /api/trace/session/start before rrweb attaches, so the server
|
|
24
|
+
* can short-circuit a recording-off project
|
|
25
25
|
* - this also lets the client honor the project-level recording toggle
|
|
26
26
|
* without redeploying the SDK
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* rrweb DOM replay is dynamic-imported (see ./rrweb) so apps that don't opt
|
|
29
|
+
* in pay zero rrweb bytes. Chunks POST to /api/trace/replay.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
declare function withReplay(options?: ReplayOptions): ReplayConfig;
|
package/dist/replay/index.js
CHANGED
|
@@ -1,143 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/replay/
|
|
2
|
-
var FLUSH_CLICK_INTERVAL_MS = 5e3;
|
|
3
|
-
var FLUSH_CLICK_BUFFER = 50;
|
|
4
|
-
var SCROLL_THROTTLE_MS = 1e3;
|
|
5
|
-
function deviceClass(w) {
|
|
6
|
-
if (w < 640) return "mobile";
|
|
7
|
-
if (w < 1024) return "tablet";
|
|
8
|
-
return "desktop";
|
|
9
|
-
}
|
|
10
|
-
function isMaskedElement(el, maskClass) {
|
|
11
|
-
let cur = el;
|
|
12
|
-
while (cur) {
|
|
13
|
-
if (_optionalChain([cur, 'access', _ => _.classList, 'optionalAccess', _2 => _2.contains, 'call', _3 => _3(maskClass)])) return true;
|
|
14
|
-
cur = cur.parentElement;
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
function buildSelector(el) {
|
|
19
|
-
try {
|
|
20
|
-
if (el.id) return `#${el.id}`;
|
|
21
|
-
const tag = _optionalChain([el, 'access', _4 => _4.tagName, 'optionalAccess', _5 => _5.toLowerCase, 'call', _6 => _6()]);
|
|
22
|
-
if (!tag) return void 0;
|
|
23
|
-
const cls = (el.className && typeof el.className === "string" ? el.className.split(/\s+/).filter(Boolean).slice(0, 2) : []).map((c) => `.${c}`);
|
|
24
|
-
return `${tag}${cls.join("")}`.slice(0, 512);
|
|
25
|
-
} catch (e2) {
|
|
26
|
-
return void 0;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function startHeatmap(args) {
|
|
30
|
-
const maskClass = _nullishCoalesce(_optionalChain([args, 'access', _7 => _7.options, 'access', _8 => _8.mask, 'optionalAccess', _9 => _9.class]), () => ( "segi-mask"));
|
|
31
|
-
let paused = false;
|
|
32
|
-
const buffer = [];
|
|
33
|
-
let lastScrollPct = -1;
|
|
34
|
-
let lastScrollPostAt = 0;
|
|
35
|
-
const flushClicks = (opts = {}) => {
|
|
36
|
-
if (buffer.length === 0) return;
|
|
37
|
-
const batch = buffer.splice(0, buffer.length);
|
|
38
|
-
args.sendClicks(batch, Boolean(opts.useBeacon));
|
|
39
|
-
};
|
|
40
|
-
const interval = setInterval(() => {
|
|
41
|
-
if (!paused) flushClicks();
|
|
42
|
-
}, FLUSH_CLICK_INTERVAL_MS);
|
|
43
|
-
const onClick = (e) => {
|
|
44
|
-
if (paused) return;
|
|
45
|
-
try {
|
|
46
|
-
const target = e.target;
|
|
47
|
-
if (!target) return;
|
|
48
|
-
if (isMaskedElement(target, maskClass)) return;
|
|
49
|
-
const docW = Math.max(
|
|
50
|
-
document.documentElement.scrollWidth,
|
|
51
|
-
_nullishCoalesce(_optionalChain([document, 'access', _10 => _10.body, 'optionalAccess', _11 => _11.scrollWidth]), () => ( 0)),
|
|
52
|
-
1
|
|
53
|
-
);
|
|
54
|
-
const docH = Math.max(
|
|
55
|
-
document.documentElement.scrollHeight,
|
|
56
|
-
_nullishCoalesce(_optionalChain([document, 'access', _12 => _12.body, 'optionalAccess', _13 => _13.scrollHeight]), () => ( 0)),
|
|
57
|
-
1
|
|
58
|
-
);
|
|
59
|
-
const pageX = e.pageX;
|
|
60
|
-
const pageY = e.pageY;
|
|
61
|
-
const w = window.innerWidth;
|
|
62
|
-
const row = {
|
|
63
|
-
sessionUid: args.sessionUid,
|
|
64
|
-
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65
|
-
urlPath: location.pathname.slice(0, 255),
|
|
66
|
-
device: deviceClass(w),
|
|
67
|
-
viewportW: w,
|
|
68
|
-
viewportH: window.innerHeight,
|
|
69
|
-
x: Math.round(e.clientX),
|
|
70
|
-
y: Math.round(e.clientY),
|
|
71
|
-
pageX: Math.round(pageX),
|
|
72
|
-
pageY: Math.round(pageY),
|
|
73
|
-
relX: Math.max(0, Math.min(1, pageX / docW)),
|
|
74
|
-
relY: Math.max(0, Math.min(1, pageY / docH)),
|
|
75
|
-
selector: buildSelector(target),
|
|
76
|
-
tag: _optionalChain([target, 'access', _14 => _14.tagName, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16(), 'access', _17 => _17.slice, 'call', _18 => _18(0, 32)]),
|
|
77
|
-
text: _optionalChain([(_nullishCoalesce(target.textContent, () => ( void 0))), 'optionalAccess', _19 => _19.trim, 'call', _20 => _20(), 'access', _21 => _21.slice, 'call', _22 => _22(0, 128)]) || void 0
|
|
78
|
-
};
|
|
79
|
-
buffer.push(row);
|
|
80
|
-
if (buffer.length >= FLUSH_CLICK_BUFFER) flushClicks();
|
|
81
|
-
} catch (e3) {
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const onScroll = () => {
|
|
85
|
-
if (paused) return;
|
|
86
|
-
const now = Date.now();
|
|
87
|
-
if (now - lastScrollPostAt < SCROLL_THROTTLE_MS) return;
|
|
88
|
-
try {
|
|
89
|
-
const docH = Math.max(
|
|
90
|
-
document.documentElement.scrollHeight,
|
|
91
|
-
_nullishCoalesce(_optionalChain([document, 'access', _23 => _23.body, 'optionalAccess', _24 => _24.scrollHeight]), () => ( 0)),
|
|
92
|
-
1
|
|
93
|
-
);
|
|
94
|
-
const viewH = window.innerHeight;
|
|
95
|
-
const maxY = Math.round(window.scrollY + viewH);
|
|
96
|
-
const pct = Math.max(0, Math.min(100, Math.round(maxY / docH * 100)));
|
|
97
|
-
if (pct <= lastScrollPct) return;
|
|
98
|
-
lastScrollPct = pct;
|
|
99
|
-
lastScrollPostAt = now;
|
|
100
|
-
const w = window.innerWidth;
|
|
101
|
-
args.sendScroll(
|
|
102
|
-
{
|
|
103
|
-
sessionUid: args.sessionUid,
|
|
104
|
-
urlPath: location.pathname.slice(0, 255),
|
|
105
|
-
device: deviceClass(w),
|
|
106
|
-
viewportH: viewH,
|
|
107
|
-
docH,
|
|
108
|
-
maxScrollY: maxY,
|
|
109
|
-
maxScrollPct: pct
|
|
110
|
-
},
|
|
111
|
-
false
|
|
112
|
-
);
|
|
113
|
-
} catch (e4) {
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const onPageHide = () => {
|
|
117
|
-
flushClicks({ useBeacon: true });
|
|
118
|
-
};
|
|
119
|
-
window.addEventListener("click", onClick, true);
|
|
120
|
-
window.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
121
|
-
window.addEventListener("pagehide", onPageHide);
|
|
122
|
-
return {
|
|
123
|
-
pause() {
|
|
124
|
-
paused = true;
|
|
125
|
-
},
|
|
126
|
-
resume() {
|
|
127
|
-
paused = false;
|
|
128
|
-
},
|
|
129
|
-
stop() {
|
|
130
|
-
clearInterval(interval);
|
|
131
|
-
window.removeEventListener("click", onClick, true);
|
|
132
|
-
window.removeEventListener("scroll", onScroll, true);
|
|
133
|
-
window.removeEventListener("pagehide", onPageHide);
|
|
134
|
-
flushClicks({ useBeacon: true });
|
|
135
|
-
},
|
|
136
|
-
flushClicks
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// src/replay/session.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/replay/session.ts
|
|
141
2
|
var UID_KEY = "_bd_session_uid";
|
|
142
3
|
var UID_TS_KEY = "_bd_session_at";
|
|
143
4
|
var ANON_KEY = "_bd_anon";
|
|
@@ -161,7 +22,7 @@ function readSession() {
|
|
|
161
22
|
const at = Number(_nullishCoalesce(sessionStorage.getItem(UID_TS_KEY), () => ( "0")));
|
|
162
23
|
if (!uid || !at) return null;
|
|
163
24
|
return { uid, at };
|
|
164
|
-
} catch (
|
|
25
|
+
} catch (e) {
|
|
165
26
|
return null;
|
|
166
27
|
}
|
|
167
28
|
}
|
|
@@ -170,7 +31,7 @@ function writeSession(uid, at) {
|
|
|
170
31
|
if (typeof sessionStorage === "undefined") return;
|
|
171
32
|
sessionStorage.setItem(UID_KEY, uid);
|
|
172
33
|
sessionStorage.setItem(UID_TS_KEY, String(at));
|
|
173
|
-
} catch (
|
|
34
|
+
} catch (e2) {
|
|
174
35
|
}
|
|
175
36
|
}
|
|
176
37
|
function getOrCreateSessionUid() {
|
|
@@ -200,7 +61,7 @@ function getOrCreateAnonId() {
|
|
|
200
61
|
const fresh = uuid();
|
|
201
62
|
localStorage.setItem(ANON_KEY, fresh);
|
|
202
63
|
return fresh;
|
|
203
|
-
} catch (
|
|
64
|
+
} catch (e3) {
|
|
204
65
|
if (!memAnon) memAnon = uuid();
|
|
205
66
|
return memAnon;
|
|
206
67
|
}
|
|
@@ -229,7 +90,7 @@ async function postTrace(cfg, path, body) {
|
|
|
229
90
|
// instead (separate API, no throw).
|
|
230
91
|
});
|
|
231
92
|
return res;
|
|
232
|
-
} catch (
|
|
93
|
+
} catch (e4) {
|
|
233
94
|
return null;
|
|
234
95
|
}
|
|
235
96
|
}
|
|
@@ -239,7 +100,7 @@ function beaconTrace(cfg, path, body) {
|
|
|
239
100
|
const url = `${normalizeBase(cfg.endpoint)}/api/trace${path}?pk=${encodeURIComponent(cfg.projectKey)}`;
|
|
240
101
|
const blob = new Blob([JSON.stringify(body)], { type: "application/json" });
|
|
241
102
|
return navigator.sendBeacon(url, blob);
|
|
242
|
-
} catch (
|
|
103
|
+
} catch (e5) {
|
|
243
104
|
return false;
|
|
244
105
|
}
|
|
245
106
|
}
|
|
@@ -249,7 +110,7 @@ function withReplay(options = {}) {
|
|
|
249
110
|
return { __segi_replay: true, options };
|
|
250
111
|
}
|
|
251
112
|
var active = null;
|
|
252
|
-
function
|
|
113
|
+
function deviceClass() {
|
|
253
114
|
if (typeof window === "undefined") return "desktop";
|
|
254
115
|
const w = window.innerWidth;
|
|
255
116
|
if (w < 640) return "mobile";
|
|
@@ -260,7 +121,7 @@ function readQuery(name) {
|
|
|
260
121
|
if (typeof location === "undefined") return void 0;
|
|
261
122
|
try {
|
|
262
123
|
return _nullishCoalesce(new URLSearchParams(location.search).get(name), () => ( void 0));
|
|
263
|
-
} catch (
|
|
124
|
+
} catch (e6) {
|
|
264
125
|
return void 0;
|
|
265
126
|
}
|
|
266
127
|
}
|
|
@@ -286,10 +147,10 @@ async function activateReplay(args) {
|
|
|
286
147
|
sessionUid,
|
|
287
148
|
anonId,
|
|
288
149
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
289
|
-
device:
|
|
150
|
+
device: deviceClass(),
|
|
290
151
|
viewportW: window.innerWidth,
|
|
291
152
|
viewportH: window.innerHeight,
|
|
292
|
-
ua: _optionalChain([navigator, 'access',
|
|
153
|
+
ua: _optionalChain([navigator, 'access', _ => _.userAgent, 'optionalAccess', _2 => _2.slice, 'call', _3 => _3(0, 512)]),
|
|
293
154
|
referrer: document.referrer || void 0,
|
|
294
155
|
landingUrl: location.href.slice(0, 512),
|
|
295
156
|
utmSource: readQuery("utm_source"),
|
|
@@ -307,14 +168,13 @@ async function activateReplay(args) {
|
|
|
307
168
|
const body = await res.json().catch(() => ({}));
|
|
308
169
|
if (body.recordingEnabled === false) recordingEnabled = false;
|
|
309
170
|
}
|
|
310
|
-
} catch (
|
|
171
|
+
} catch (e7) {
|
|
311
172
|
}
|
|
312
173
|
if (!recordingEnabled) {
|
|
313
174
|
active = {
|
|
314
175
|
sessionUid,
|
|
315
176
|
config: transportCfg,
|
|
316
177
|
options,
|
|
317
|
-
heatmap: null,
|
|
318
178
|
rrweb: null,
|
|
319
179
|
replayBlocked: false,
|
|
320
180
|
paused: true,
|
|
@@ -326,22 +186,10 @@ async function activateReplay(args) {
|
|
|
326
186
|
};
|
|
327
187
|
return;
|
|
328
188
|
}
|
|
329
|
-
const heatmap = startHeatmap({
|
|
330
|
-
sessionUid,
|
|
331
|
-
options,
|
|
332
|
-
sendClicks: (rows, useBeacon) => {
|
|
333
|
-
if (useBeacon) beaconTrace(transportCfg, "/heatmap/clicks", { clicks: rows });
|
|
334
|
-
else void postTrace(transportCfg, "/heatmap/clicks", { clicks: rows });
|
|
335
|
-
},
|
|
336
|
-
sendScroll: (row) => {
|
|
337
|
-
void postTrace(transportCfg, "/heatmap/scroll", row);
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
189
|
active = {
|
|
341
190
|
sessionUid,
|
|
342
191
|
config: transportCfg,
|
|
343
192
|
options,
|
|
344
|
-
heatmap,
|
|
345
193
|
rrweb: null,
|
|
346
194
|
replayBlocked: false,
|
|
347
195
|
paused: false,
|
|
@@ -351,6 +199,16 @@ async function activateReplay(args) {
|
|
|
351
199
|
clickCount: 0,
|
|
352
200
|
recordingEnabled: true
|
|
353
201
|
};
|
|
202
|
+
let lastSessionBump = Date.now();
|
|
203
|
+
const bumpIfStale = () => {
|
|
204
|
+
const now = Date.now();
|
|
205
|
+
if (now - lastSessionBump < 6e4) return;
|
|
206
|
+
lastSessionBump = now;
|
|
207
|
+
bumpSessionActivity();
|
|
208
|
+
};
|
|
209
|
+
for (const ev of ["mousedown", "keydown", "scroll", "touchstart"]) {
|
|
210
|
+
window.addEventListener(ev, bumpIfStale, { passive: true, capture: true });
|
|
211
|
+
}
|
|
354
212
|
const w = window;
|
|
355
213
|
const scheduleRrwebStart = (run) => {
|
|
356
214
|
let fired = false;
|
|
@@ -389,7 +247,7 @@ async function activateReplay(args) {
|
|
|
389
247
|
if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
390
248
|
navigator.sendBeacon(url, blob);
|
|
391
249
|
}
|
|
392
|
-
} catch (
|
|
250
|
+
} catch (e8) {
|
|
393
251
|
}
|
|
394
252
|
return;
|
|
395
253
|
}
|
|
@@ -405,11 +263,11 @@ async function activateReplay(args) {
|
|
|
405
263
|
if (res.status === 429) {
|
|
406
264
|
if (active) {
|
|
407
265
|
active.replayBlocked = true;
|
|
408
|
-
_optionalChain([active, 'access',
|
|
266
|
+
_optionalChain([active, 'access', _4 => _4.rrweb, 'optionalAccess', _5 => _5.stop, 'call', _6 => _6()]);
|
|
409
267
|
active.rrweb = null;
|
|
410
268
|
}
|
|
411
269
|
}
|
|
412
|
-
} catch (
|
|
270
|
+
} catch (e9) {
|
|
413
271
|
}
|
|
414
272
|
}
|
|
415
273
|
}).then(resolve, () => resolve(null));
|
|
@@ -432,7 +290,7 @@ async function activateReplay(args) {
|
|
|
432
290
|
});
|
|
433
291
|
window.addEventListener("pagehide", () => {
|
|
434
292
|
if (!active) return;
|
|
435
|
-
_optionalChain([active, 'access',
|
|
293
|
+
_optionalChain([active, 'access', _7 => _7.rrweb, 'optionalAccess', _8 => _8.flush, 'call', _9 => _9(true)]);
|
|
436
294
|
beaconTrace(active.config, "/session/end", {
|
|
437
295
|
sessionUid: active.sessionUid,
|
|
438
296
|
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -444,11 +302,9 @@ async function activateReplay(args) {
|
|
|
444
302
|
const MAX_SESSION_DURATION_MS = 30 * 6e4;
|
|
445
303
|
setTimeout(() => {
|
|
446
304
|
if (!active) return;
|
|
447
|
-
_optionalChain([active, 'access',
|
|
448
|
-
_optionalChain([active, 'access',
|
|
305
|
+
_optionalChain([active, 'access', _10 => _10.rrweb, 'optionalAccess', _11 => _11.flush, 'call', _12 => _12(true)]);
|
|
306
|
+
_optionalChain([active, 'access', _13 => _13.rrweb, 'optionalAccess', _14 => _14.stop, 'call', _15 => _15()]);
|
|
449
307
|
active.rrweb = null;
|
|
450
|
-
_optionalChain([active, 'access', _40 => _40.heatmap, 'optionalAccess', _41 => _41.stop, 'call', _42 => _42()]);
|
|
451
|
-
active.heatmap = null;
|
|
452
308
|
beaconTrace(active.config, "/session/end", {
|
|
453
309
|
sessionUid: active.sessionUid,
|
|
454
310
|
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -462,25 +318,23 @@ async function activateReplay(args) {
|
|
|
462
318
|
}
|
|
463
319
|
var replayApi = {
|
|
464
320
|
pause() {
|
|
465
|
-
_optionalChain([active, 'optionalAccess',
|
|
466
|
-
_optionalChain([active, 'optionalAccess', _46 => _46.rrweb, 'optionalAccess', _47 => _47.pause, 'call', _48 => _48()]);
|
|
321
|
+
_optionalChain([active, 'optionalAccess', _16 => _16.rrweb, 'optionalAccess', _17 => _17.pause, 'call', _18 => _18()]);
|
|
467
322
|
if (active) active.paused = true;
|
|
468
323
|
},
|
|
469
324
|
resume() {
|
|
470
|
-
_optionalChain([active, 'optionalAccess',
|
|
471
|
-
_optionalChain([active, 'optionalAccess', _52 => _52.rrweb, 'optionalAccess', _53 => _53.resume, 'call', _54 => _54()]);
|
|
325
|
+
_optionalChain([active, 'optionalAccess', _19 => _19.rrweb, 'optionalAccess', _20 => _20.resume, 'call', _21 => _21()]);
|
|
472
326
|
if (active) active.paused = false;
|
|
473
327
|
bumpSessionActivity();
|
|
474
328
|
},
|
|
475
329
|
setUser(user) {
|
|
476
330
|
if (!active) return;
|
|
477
|
-
active.userId = _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
331
|
+
active.userId = _nullishCoalesce(_optionalChain([user, 'optionalAccess', _22 => _22.id]), () => ( null));
|
|
478
332
|
void postTrace(active.config, "/session/start", {
|
|
479
333
|
sessionUid: active.sessionUid,
|
|
480
334
|
anonId: getOrCreateAnonId(),
|
|
481
335
|
userId: active.userId,
|
|
482
336
|
startedAt: active.startedAt,
|
|
483
|
-
device:
|
|
337
|
+
device: deviceClass(),
|
|
484
338
|
viewportW: window.innerWidth,
|
|
485
339
|
viewportH: window.innerHeight
|
|
486
340
|
});
|
|
@@ -506,22 +360,21 @@ var replayApi = {
|
|
|
506
360
|
*/
|
|
507
361
|
notifyRouteChange(url, title) {
|
|
508
362
|
if (!active) return;
|
|
363
|
+
bumpSessionActivity();
|
|
509
364
|
const nowBlocked = isPathBlocked(active.options, location.pathname);
|
|
510
365
|
if (nowBlocked) {
|
|
511
366
|
if (!active.paused) {
|
|
512
|
-
_optionalChain([active, 'access',
|
|
513
|
-
_optionalChain([active, 'access', _59 => _59.rrweb, 'optionalAccess', _60 => _60.pause, 'call', _61 => _61()]);
|
|
367
|
+
_optionalChain([active, 'access', _23 => _23.rrweb, 'optionalAccess', _24 => _24.pause, 'call', _25 => _25()]);
|
|
514
368
|
active.paused = true;
|
|
515
369
|
}
|
|
516
370
|
return;
|
|
517
371
|
}
|
|
518
372
|
if (active.paused) {
|
|
519
|
-
_optionalChain([active, 'access',
|
|
520
|
-
_optionalChain([active, 'access', _65 => _65.rrweb, 'optionalAccess', _66 => _66.resume, 'call', _67 => _67()]);
|
|
373
|
+
_optionalChain([active, 'access', _26 => _26.rrweb, 'optionalAccess', _27 => _27.resume, 'call', _28 => _28()]);
|
|
521
374
|
active.paused = false;
|
|
522
375
|
}
|
|
523
376
|
active.pagesVisited += 1;
|
|
524
|
-
_optionalChain([active, 'access',
|
|
377
|
+
_optionalChain([active, 'access', _29 => _29.rrweb, 'optionalAccess', _30 => _30.takeFullSnapshot, 'call', _31 => _31()]);
|
|
525
378
|
void postTrace(active.config, "/events", {
|
|
526
379
|
events: [
|
|
527
380
|
{
|
|
@@ -536,7 +389,7 @@ var replayApi = {
|
|
|
536
389
|
},
|
|
537
390
|
/** Test seam: returns null when replay was not activated for this session. */
|
|
538
391
|
_sessionUid() {
|
|
539
|
-
return _nullishCoalesce(_optionalChain([active, 'optionalAccess',
|
|
392
|
+
return _nullishCoalesce(_optionalChain([active, 'optionalAccess', _32 => _32.sessionUid]), () => ( null));
|
|
540
393
|
}
|
|
541
394
|
};
|
|
542
395
|
|