@extn/segi-js 0.2.11 → 0.2.13
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 +26 -26
- 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 +45 -185
- package/dist/replay/index.mjs +23 -163
- 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
|
}
|
|
@@ -248,8 +109,21 @@ function beaconTrace(cfg, path, body) {
|
|
|
248
109
|
function withReplay(options = {}) {
|
|
249
110
|
return { __segi_replay: true, options };
|
|
250
111
|
}
|
|
112
|
+
async function gzipString(str) {
|
|
113
|
+
try {
|
|
114
|
+
if (typeof CompressionStream === "undefined") return null;
|
|
115
|
+
const cs = new CompressionStream("gzip");
|
|
116
|
+
const writer = cs.writable.getWriter();
|
|
117
|
+
void writer.write(new TextEncoder().encode(str));
|
|
118
|
+
void writer.close();
|
|
119
|
+
const buf = await new Response(cs.readable).arrayBuffer();
|
|
120
|
+
return new Uint8Array(buf);
|
|
121
|
+
} catch (e6) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
251
125
|
var active = null;
|
|
252
|
-
function
|
|
126
|
+
function deviceClass() {
|
|
253
127
|
if (typeof window === "undefined") return "desktop";
|
|
254
128
|
const w = window.innerWidth;
|
|
255
129
|
if (w < 640) return "mobile";
|
|
@@ -260,7 +134,7 @@ function readQuery(name) {
|
|
|
260
134
|
if (typeof location === "undefined") return void 0;
|
|
261
135
|
try {
|
|
262
136
|
return _nullishCoalesce(new URLSearchParams(location.search).get(name), () => ( void 0));
|
|
263
|
-
} catch (
|
|
137
|
+
} catch (e7) {
|
|
264
138
|
return void 0;
|
|
265
139
|
}
|
|
266
140
|
}
|
|
@@ -286,10 +160,10 @@ async function activateReplay(args) {
|
|
|
286
160
|
sessionUid,
|
|
287
161
|
anonId,
|
|
288
162
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
289
|
-
device:
|
|
163
|
+
device: deviceClass(),
|
|
290
164
|
viewportW: window.innerWidth,
|
|
291
165
|
viewportH: window.innerHeight,
|
|
292
|
-
ua: _optionalChain([navigator, 'access',
|
|
166
|
+
ua: _optionalChain([navigator, 'access', _ => _.userAgent, 'optionalAccess', _2 => _2.slice, 'call', _3 => _3(0, 512)]),
|
|
293
167
|
referrer: document.referrer || void 0,
|
|
294
168
|
landingUrl: location.href.slice(0, 512),
|
|
295
169
|
utmSource: readQuery("utm_source"),
|
|
@@ -307,14 +181,13 @@ async function activateReplay(args) {
|
|
|
307
181
|
const body = await res.json().catch(() => ({}));
|
|
308
182
|
if (body.recordingEnabled === false) recordingEnabled = false;
|
|
309
183
|
}
|
|
310
|
-
} catch (
|
|
184
|
+
} catch (e8) {
|
|
311
185
|
}
|
|
312
186
|
if (!recordingEnabled) {
|
|
313
187
|
active = {
|
|
314
188
|
sessionUid,
|
|
315
189
|
config: transportCfg,
|
|
316
190
|
options,
|
|
317
|
-
heatmap: null,
|
|
318
191
|
rrweb: null,
|
|
319
192
|
replayBlocked: false,
|
|
320
193
|
paused: true,
|
|
@@ -326,22 +199,10 @@ async function activateReplay(args) {
|
|
|
326
199
|
};
|
|
327
200
|
return;
|
|
328
201
|
}
|
|
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
202
|
active = {
|
|
341
203
|
sessionUid,
|
|
342
204
|
config: transportCfg,
|
|
343
205
|
options,
|
|
344
|
-
heatmap,
|
|
345
206
|
rrweb: null,
|
|
346
207
|
replayBlocked: false,
|
|
347
208
|
paused: false,
|
|
@@ -399,27 +260,32 @@ async function activateReplay(args) {
|
|
|
399
260
|
if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
400
261
|
navigator.sendBeacon(url, blob);
|
|
401
262
|
}
|
|
402
|
-
} catch (
|
|
263
|
+
} catch (e9) {
|
|
403
264
|
}
|
|
404
265
|
return;
|
|
405
266
|
}
|
|
406
267
|
try {
|
|
268
|
+
const gz = await gzipString(bodyStr);
|
|
407
269
|
const res = await fetch(`${base}/api/trace/replay`, {
|
|
408
270
|
method: "POST",
|
|
409
|
-
headers: {
|
|
271
|
+
headers: gz ? {
|
|
272
|
+
"Content-Type": "application/json",
|
|
273
|
+
"Content-Encoding": "gzip",
|
|
274
|
+
"X-Segi-Project-Key": transportCfg.projectKey
|
|
275
|
+
} : {
|
|
410
276
|
"Content-Type": "application/json",
|
|
411
277
|
"X-Segi-Project-Key": transportCfg.projectKey
|
|
412
278
|
},
|
|
413
|
-
body: bodyStr
|
|
279
|
+
body: _nullishCoalesce(gz, () => ( bodyStr))
|
|
414
280
|
});
|
|
415
281
|
if (res.status === 429) {
|
|
416
282
|
if (active) {
|
|
417
283
|
active.replayBlocked = true;
|
|
418
|
-
_optionalChain([active, 'access',
|
|
284
|
+
_optionalChain([active, 'access', _4 => _4.rrweb, 'optionalAccess', _5 => _5.stop, 'call', _6 => _6()]);
|
|
419
285
|
active.rrweb = null;
|
|
420
286
|
}
|
|
421
287
|
}
|
|
422
|
-
} catch (
|
|
288
|
+
} catch (e10) {
|
|
423
289
|
}
|
|
424
290
|
}
|
|
425
291
|
}).then(resolve, () => resolve(null));
|
|
@@ -442,7 +308,7 @@ async function activateReplay(args) {
|
|
|
442
308
|
});
|
|
443
309
|
window.addEventListener("pagehide", () => {
|
|
444
310
|
if (!active) return;
|
|
445
|
-
_optionalChain([active, 'access',
|
|
311
|
+
_optionalChain([active, 'access', _7 => _7.rrweb, 'optionalAccess', _8 => _8.flush, 'call', _9 => _9(true)]);
|
|
446
312
|
beaconTrace(active.config, "/session/end", {
|
|
447
313
|
sessionUid: active.sessionUid,
|
|
448
314
|
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -454,11 +320,9 @@ async function activateReplay(args) {
|
|
|
454
320
|
const MAX_SESSION_DURATION_MS = 30 * 6e4;
|
|
455
321
|
setTimeout(() => {
|
|
456
322
|
if (!active) return;
|
|
457
|
-
_optionalChain([active, 'access',
|
|
458
|
-
_optionalChain([active, 'access',
|
|
323
|
+
_optionalChain([active, 'access', _10 => _10.rrweb, 'optionalAccess', _11 => _11.flush, 'call', _12 => _12(true)]);
|
|
324
|
+
_optionalChain([active, 'access', _13 => _13.rrweb, 'optionalAccess', _14 => _14.stop, 'call', _15 => _15()]);
|
|
459
325
|
active.rrweb = null;
|
|
460
|
-
_optionalChain([active, 'access', _40 => _40.heatmap, 'optionalAccess', _41 => _41.stop, 'call', _42 => _42()]);
|
|
461
|
-
active.heatmap = null;
|
|
462
326
|
beaconTrace(active.config, "/session/end", {
|
|
463
327
|
sessionUid: active.sessionUid,
|
|
464
328
|
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -472,25 +336,23 @@ async function activateReplay(args) {
|
|
|
472
336
|
}
|
|
473
337
|
var replayApi = {
|
|
474
338
|
pause() {
|
|
475
|
-
_optionalChain([active, 'optionalAccess',
|
|
476
|
-
_optionalChain([active, 'optionalAccess', _46 => _46.rrweb, 'optionalAccess', _47 => _47.pause, 'call', _48 => _48()]);
|
|
339
|
+
_optionalChain([active, 'optionalAccess', _16 => _16.rrweb, 'optionalAccess', _17 => _17.pause, 'call', _18 => _18()]);
|
|
477
340
|
if (active) active.paused = true;
|
|
478
341
|
},
|
|
479
342
|
resume() {
|
|
480
|
-
_optionalChain([active, 'optionalAccess',
|
|
481
|
-
_optionalChain([active, 'optionalAccess', _52 => _52.rrweb, 'optionalAccess', _53 => _53.resume, 'call', _54 => _54()]);
|
|
343
|
+
_optionalChain([active, 'optionalAccess', _19 => _19.rrweb, 'optionalAccess', _20 => _20.resume, 'call', _21 => _21()]);
|
|
482
344
|
if (active) active.paused = false;
|
|
483
345
|
bumpSessionActivity();
|
|
484
346
|
},
|
|
485
347
|
setUser(user) {
|
|
486
348
|
if (!active) return;
|
|
487
|
-
active.userId = _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
349
|
+
active.userId = _nullishCoalesce(_optionalChain([user, 'optionalAccess', _22 => _22.id]), () => ( null));
|
|
488
350
|
void postTrace(active.config, "/session/start", {
|
|
489
351
|
sessionUid: active.sessionUid,
|
|
490
352
|
anonId: getOrCreateAnonId(),
|
|
491
353
|
userId: active.userId,
|
|
492
354
|
startedAt: active.startedAt,
|
|
493
|
-
device:
|
|
355
|
+
device: deviceClass(),
|
|
494
356
|
viewportW: window.innerWidth,
|
|
495
357
|
viewportH: window.innerHeight
|
|
496
358
|
});
|
|
@@ -520,19 +382,17 @@ var replayApi = {
|
|
|
520
382
|
const nowBlocked = isPathBlocked(active.options, location.pathname);
|
|
521
383
|
if (nowBlocked) {
|
|
522
384
|
if (!active.paused) {
|
|
523
|
-
_optionalChain([active, 'access',
|
|
524
|
-
_optionalChain([active, 'access', _59 => _59.rrweb, 'optionalAccess', _60 => _60.pause, 'call', _61 => _61()]);
|
|
385
|
+
_optionalChain([active, 'access', _23 => _23.rrweb, 'optionalAccess', _24 => _24.pause, 'call', _25 => _25()]);
|
|
525
386
|
active.paused = true;
|
|
526
387
|
}
|
|
527
388
|
return;
|
|
528
389
|
}
|
|
529
390
|
if (active.paused) {
|
|
530
|
-
_optionalChain([active, 'access',
|
|
531
|
-
_optionalChain([active, 'access', _65 => _65.rrweb, 'optionalAccess', _66 => _66.resume, 'call', _67 => _67()]);
|
|
391
|
+
_optionalChain([active, 'access', _26 => _26.rrweb, 'optionalAccess', _27 => _27.resume, 'call', _28 => _28()]);
|
|
532
392
|
active.paused = false;
|
|
533
393
|
}
|
|
534
394
|
active.pagesVisited += 1;
|
|
535
|
-
_optionalChain([active, 'access',
|
|
395
|
+
_optionalChain([active, 'access', _29 => _29.rrweb, 'optionalAccess', _30 => _30.takeFullSnapshot, 'call', _31 => _31()]);
|
|
536
396
|
void postTrace(active.config, "/events", {
|
|
537
397
|
events: [
|
|
538
398
|
{
|
|
@@ -547,7 +407,7 @@ var replayApi = {
|
|
|
547
407
|
},
|
|
548
408
|
/** Test seam: returns null when replay was not activated for this session. */
|
|
549
409
|
_sessionUid() {
|
|
550
|
-
return _nullishCoalesce(_optionalChain([active, 'optionalAccess',
|
|
410
|
+
return _nullishCoalesce(_optionalChain([active, 'optionalAccess', _32 => _32.sessionUid]), () => ( null));
|
|
551
411
|
}
|
|
552
412
|
};
|
|
553
413
|
|