@extn/segi-js 0.2.5 → 0.2.7

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.
@@ -221,9 +221,12 @@ async function postTrace(cfg, path, body) {
221
221
  "Content-Type": "application/json",
222
222
  "X-Segi-Project-Key": cfg.projectKey
223
223
  },
224
- body: JSON.stringify(body),
225
- // Keep the request alive past page unload (best-effort flush).
226
- keepalive: true
224
+ body: JSON.stringify(body)
225
+ // No `keepalive: true` — Chrome caps keepalive request bodies at
226
+ // 64 KB and rejects larger ones synchronously with "Failed to
227
+ // fetch", which silently nukes uploads (FullSnapshots routinely
228
+ // exceed 64 KB). Unload-path flushing goes through sendBeacon
229
+ // instead (separate API, no throw).
227
230
  });
228
231
  return res;
229
232
  } catch (e8) {
@@ -367,7 +370,7 @@ async function activateReplay(args) {
367
370
  setTimeout(onIdle, 5e3);
368
371
  }
369
372
  };
370
- void Promise.resolve().then(() => _interopRequireWildcard(require("../rrweb-KAUSOLTH.js"))).then(
373
+ void Promise.resolve().then(() => _interopRequireWildcard(require("../rrweb-VXG3W6SS.js"))).then(
371
374
  ({ startRrweb }) => new Promise((resolve) => {
372
375
  scheduleRrwebStart(() => {
373
376
  startRrweb({
@@ -397,17 +400,8 @@ async function activateReplay(args) {
397
400
  "Content-Type": "application/json",
398
401
  "X-Segi-Project-Key": transportCfg.projectKey
399
402
  },
400
- body: bodyStr,
401
- keepalive: true
403
+ body: bodyStr
402
404
  });
403
- if (typeof console !== "undefined") {
404
- console.log(
405
- "[segi.replay] /replay POST",
406
- res.status,
407
- bodyStr.length,
408
- "bytes"
409
- );
410
- }
411
405
  if (res.status === 429) {
412
406
  if (active) {
413
407
  active.replayBlocked = true;
@@ -415,13 +409,7 @@ async function activateReplay(args) {
415
409
  active.rrweb = null;
416
410
  }
417
411
  }
418
- } catch (err) {
419
- if (typeof console !== "undefined") {
420
- console.log(
421
- "[segi.replay] /replay POST FETCH FAILED:",
422
- err.message
423
- );
424
- }
412
+ } catch (e13) {
425
413
  }
426
414
  }
427
415
  }).then(resolve, () => resolve(null));
@@ -499,11 +487,14 @@ var replayApi = {
499
487
  * Bumps the page-views counter and emits a fresh page_view event.
500
488
  */
501
489
  notifyRouteChange(url, title) {
502
- if (!active || active.paused) return;
503
- if (isPathBlocked(active.options, location.pathname)) {
504
- _optionalChain([active, 'access', _47 => _47.heatmap, 'optionalAccess', _48 => _48.pause, 'call', _49 => _49()]);
505
- _optionalChain([active, 'access', _50 => _50.rrweb, 'optionalAccess', _51 => _51.pause, 'call', _52 => _52()]);
506
- active.paused = true;
490
+ if (!active) return;
491
+ const nowBlocked = isPathBlocked(active.options, location.pathname);
492
+ if (nowBlocked) {
493
+ if (!active.paused) {
494
+ _optionalChain([active, 'access', _47 => _47.heatmap, 'optionalAccess', _48 => _48.pause, 'call', _49 => _49()]);
495
+ _optionalChain([active, 'access', _50 => _50.rrweb, 'optionalAccess', _51 => _51.pause, 'call', _52 => _52()]);
496
+ active.paused = true;
497
+ }
507
498
  return;
508
499
  }
509
500
  if (active.paused) {
@@ -221,9 +221,12 @@ async function postTrace(cfg, path, body) {
221
221
  "Content-Type": "application/json",
222
222
  "X-Segi-Project-Key": cfg.projectKey
223
223
  },
224
- body: JSON.stringify(body),
225
- // Keep the request alive past page unload (best-effort flush).
226
- keepalive: true
224
+ body: JSON.stringify(body)
225
+ // No `keepalive: true` — Chrome caps keepalive request bodies at
226
+ // 64 KB and rejects larger ones synchronously with "Failed to
227
+ // fetch", which silently nukes uploads (FullSnapshots routinely
228
+ // exceed 64 KB). Unload-path flushing goes through sendBeacon
229
+ // instead (separate API, no throw).
227
230
  });
228
231
  return res;
229
232
  } catch {
@@ -367,7 +370,7 @@ async function activateReplay(args) {
367
370
  setTimeout(onIdle, 5e3);
368
371
  }
369
372
  };
370
- void import("../rrweb-DCBIDQEX.mjs").then(
373
+ void import("../rrweb-O2KFXCVA.mjs").then(
371
374
  ({ startRrweb }) => new Promise((resolve) => {
372
375
  scheduleRrwebStart(() => {
373
376
  startRrweb({
@@ -397,17 +400,8 @@ async function activateReplay(args) {
397
400
  "Content-Type": "application/json",
398
401
  "X-Segi-Project-Key": transportCfg.projectKey
399
402
  },
400
- body: bodyStr,
401
- keepalive: true
403
+ body: bodyStr
402
404
  });
403
- if (typeof console !== "undefined") {
404
- console.log(
405
- "[segi.replay] /replay POST",
406
- res.status,
407
- bodyStr.length,
408
- "bytes"
409
- );
410
- }
411
405
  if (res.status === 429) {
412
406
  if (active) {
413
407
  active.replayBlocked = true;
@@ -415,13 +409,7 @@ async function activateReplay(args) {
415
409
  active.rrweb = null;
416
410
  }
417
411
  }
418
- } catch (err) {
419
- if (typeof console !== "undefined") {
420
- console.log(
421
- "[segi.replay] /replay POST FETCH FAILED:",
422
- err.message
423
- );
424
- }
412
+ } catch {
425
413
  }
426
414
  }
427
415
  }).then(resolve, () => resolve(null));
@@ -499,11 +487,14 @@ var replayApi = {
499
487
  * Bumps the page-views counter and emits a fresh page_view event.
500
488
  */
501
489
  notifyRouteChange(url, title) {
502
- if (!active || active.paused) return;
503
- if (isPathBlocked(active.options, location.pathname)) {
504
- active.heatmap?.pause();
505
- active.rrweb?.pause();
506
- active.paused = true;
490
+ if (!active) return;
491
+ const nowBlocked = isPathBlocked(active.options, location.pathname);
492
+ if (nowBlocked) {
493
+ if (!active.paused) {
494
+ active.heatmap?.pause();
495
+ active.rrweb?.pause();
496
+ active.paused = true;
497
+ }
507
498
  return;
508
499
  }
509
500
  if (active.paused) {
@@ -48,39 +48,15 @@ async function startRrweb(args) {
48
48
  }, IDLE_CHECK_MS);
49
49
  function startRecorder() {
50
50
  if (stopFn) return;
51
- let emitCount = 0;
52
- const log = (...args2) => {
53
- if (typeof console !== "undefined") {
54
- console.log("[segi.replay]", ...args2);
55
- }
56
- };
57
- log("startRecorder() called, rrweb keys:", Object.keys(rrweb).slice(0, 12));
58
51
  const stop = rrweb.record({
59
52
  emit(event) {
60
- emitCount++;
61
- const e = event;
62
53
  if (paused || stopped) return;
63
54
  let serialized;
64
55
  try {
65
56
  serialized = JSON.stringify(event);
66
- } catch (err) {
67
- log(
68
- `emit #${emitCount} type:${e.type} source:${e.data?.source} STRINGIFY_FAILED:`,
69
- err.message
70
- );
57
+ } catch {
71
58
  return;
72
59
  }
73
- if (emitCount <= 10) {
74
- log(
75
- `emit #${emitCount}`,
76
- "type:",
77
- e.type,
78
- "source:",
79
- e.data?.source,
80
- "size:",
81
- serialized.length
82
- );
83
- }
84
60
  buffer.push(serialized);
85
61
  bufferBytes += serialized.length;
86
62
  if (bufferBytes >= FLUSH_BYTES) flush();
@@ -104,34 +80,21 @@ async function startRrweb(args) {
104
80
  // emit the FullSnapshot immediately and inline async-best-effort.
105
81
  });
106
82
  stopFn = typeof stop === "function" ? stop : null;
107
- log(
108
- "record() returned, stopFn:",
109
- typeof stop,
110
- "rrweb.record.takeFullSnapshot:",
111
- typeof rrweb.record.takeFullSnapshot,
112
- "rrweb.takeFullSnapshot:",
113
- typeof rrweb.takeFullSnapshot
114
- );
115
- const forceSnapshot = (label) => {
83
+ const forceSnapshot = () => {
116
84
  if (stopped || paused) return;
117
85
  try {
118
86
  const rrwebMod = rrweb;
119
87
  if (typeof rrwebMod.record.takeFullSnapshot === "function") {
120
- log(`forceSnapshot[${label}] via record.takeFullSnapshot`);
121
88
  rrwebMod.record.takeFullSnapshot(true);
122
89
  } else if (typeof rrwebMod.takeFullSnapshot === "function") {
123
- log(`forceSnapshot[${label}] via top-level takeFullSnapshot`);
124
90
  rrwebMod.takeFullSnapshot(true);
125
- } else {
126
- log(`forceSnapshot[${label}] no takeFullSnapshot found`);
127
91
  }
128
- } catch (err) {
129
- log(`forceSnapshot[${label}] threw:`, err);
92
+ } catch {
130
93
  }
131
94
  };
132
- setTimeout(() => forceSnapshot("100ms"), 100);
133
- setTimeout(() => forceSnapshot("500ms"), 500);
134
- setTimeout(() => forceSnapshot("2000ms"), 2e3);
95
+ setTimeout(forceSnapshot, 100);
96
+ setTimeout(forceSnapshot, 500);
97
+ setTimeout(forceSnapshot, 2e3);
135
98
  }
136
99
  function stopRrwebOnly() {
137
100
  try {
@@ -146,25 +109,6 @@ async function startRrweb(args) {
146
109
  const chunk = buffer;
147
110
  buffer = [];
148
111
  bufferBytes = 0;
149
- if (typeof console !== "undefined") {
150
- const totalSize = chunk.reduce((a, s) => a + s.length, 0);
151
- const types = {};
152
- for (const s of chunk) {
153
- const m = s.match(/^\{"type":(\d+)/);
154
- const t = m ? m[1] : "?";
155
- types[t] = (types[t] ?? 0) + 1;
156
- }
157
- console.log(
158
- "[segi.replay] flush:",
159
- chunk.length,
160
- "events,",
161
- totalSize,
162
- "bytes, types:",
163
- types,
164
- "useBeacon:",
165
- useBeacon
166
- );
167
- }
168
112
  try {
169
113
  args.sendChunk(chunk, useBeacon);
170
114
  } catch {
@@ -17,7 +17,7 @@ async function startRrweb(args) {
17
17
  let rrweb;
18
18
  try {
19
19
  rrweb = await Promise.resolve().then(() => _interopRequireWildcard(require("rrweb")));
20
- } catch (e2) {
20
+ } catch (e) {
21
21
  return null;
22
22
  }
23
23
  const maskClass = _nullishCoalesce(_optionalChain([args, 'access', _ => _.options, 'access', _2 => _2.mask, 'optionalAccess', _3 => _3.class]), () => ( "segi-mask"));
@@ -48,39 +48,15 @@ async function startRrweb(args) {
48
48
  }, IDLE_CHECK_MS);
49
49
  function startRecorder() {
50
50
  if (stopFn) return;
51
- let emitCount = 0;
52
- const log = (...args2) => {
53
- if (typeof console !== "undefined") {
54
- console.log("[segi.replay]", ...args2);
55
- }
56
- };
57
- log("startRecorder() called, rrweb keys:", Object.keys(rrweb).slice(0, 12));
58
51
  const stop = rrweb.record({
59
52
  emit(event) {
60
- emitCount++;
61
- const e = event;
62
53
  if (paused || stopped) return;
63
54
  let serialized;
64
55
  try {
65
56
  serialized = JSON.stringify(event);
66
- } catch (err) {
67
- log(
68
- `emit #${emitCount} type:${e.type} source:${_optionalChain([e, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.source])} STRINGIFY_FAILED:`,
69
- err.message
70
- );
57
+ } catch (e2) {
71
58
  return;
72
59
  }
73
- if (emitCount <= 10) {
74
- log(
75
- `emit #${emitCount}`,
76
- "type:",
77
- e.type,
78
- "source:",
79
- _optionalChain([e, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.source]),
80
- "size:",
81
- serialized.length
82
- );
83
- }
84
60
  buffer.push(serialized);
85
61
  bufferBytes += serialized.length;
86
62
  if (bufferBytes >= FLUSH_BYTES) flush();
@@ -104,38 +80,25 @@ async function startRrweb(args) {
104
80
  // emit the FullSnapshot immediately and inline async-best-effort.
105
81
  });
106
82
  stopFn = typeof stop === "function" ? stop : null;
107
- log(
108
- "record() returned, stopFn:",
109
- typeof stop,
110
- "rrweb.record.takeFullSnapshot:",
111
- typeof rrweb.record.takeFullSnapshot,
112
- "rrweb.takeFullSnapshot:",
113
- typeof rrweb.takeFullSnapshot
114
- );
115
- const forceSnapshot = (label) => {
83
+ const forceSnapshot = () => {
116
84
  if (stopped || paused) return;
117
85
  try {
118
86
  const rrwebMod = rrweb;
119
87
  if (typeof rrwebMod.record.takeFullSnapshot === "function") {
120
- log(`forceSnapshot[${label}] via record.takeFullSnapshot`);
121
88
  rrwebMod.record.takeFullSnapshot(true);
122
89
  } else if (typeof rrwebMod.takeFullSnapshot === "function") {
123
- log(`forceSnapshot[${label}] via top-level takeFullSnapshot`);
124
90
  rrwebMod.takeFullSnapshot(true);
125
- } else {
126
- log(`forceSnapshot[${label}] no takeFullSnapshot found`);
127
91
  }
128
- } catch (err) {
129
- log(`forceSnapshot[${label}] threw:`, err);
92
+ } catch (e3) {
130
93
  }
131
94
  };
132
- setTimeout(() => forceSnapshot("100ms"), 100);
133
- setTimeout(() => forceSnapshot("500ms"), 500);
134
- setTimeout(() => forceSnapshot("2000ms"), 2e3);
95
+ setTimeout(forceSnapshot, 100);
96
+ setTimeout(forceSnapshot, 500);
97
+ setTimeout(forceSnapshot, 2e3);
135
98
  }
136
99
  function stopRrwebOnly() {
137
100
  try {
138
- _optionalChain([stopFn, 'optionalCall', _11 => _11()]);
101
+ _optionalChain([stopFn, 'optionalCall', _7 => _7()]);
139
102
  } finally {
140
103
  stopFn = null;
141
104
  }
@@ -146,28 +109,9 @@ async function startRrweb(args) {
146
109
  const chunk = buffer;
147
110
  buffer = [];
148
111
  bufferBytes = 0;
149
- if (typeof console !== "undefined") {
150
- const totalSize = chunk.reduce((a, s) => a + s.length, 0);
151
- const types = {};
152
- for (const s of chunk) {
153
- const m = s.match(/^\{"type":(\d+)/);
154
- const t = m ? m[1] : "?";
155
- types[t] = (_nullishCoalesce(types[t], () => ( 0))) + 1;
156
- }
157
- console.log(
158
- "[segi.replay] flush:",
159
- chunk.length,
160
- "events,",
161
- totalSize,
162
- "bytes, types:",
163
- types,
164
- "useBeacon:",
165
- useBeacon
166
- );
167
- }
168
112
  try {
169
113
  args.sendChunk(chunk, useBeacon);
170
- } catch (e3) {
114
+ } catch (e4) {
171
115
  }
172
116
  }
173
117
  function onActivity() {
@@ -216,8 +160,8 @@ async function startRrweb(args) {
216
160
  if (stopped || paused) return;
217
161
  try {
218
162
  const rec = rrweb.record;
219
- _optionalChain([rec, 'access', _12 => _12.takeFullSnapshot, 'optionalCall', _13 => _13()]);
220
- } catch (e4) {
163
+ _optionalChain([rec, 'access', _8 => _8.takeFullSnapshot, 'optionalCall', _9 => _9()]);
164
+ } catch (e5) {
221
165
  }
222
166
  }
223
167
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extn/segi-js",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Browser JavaScript SDK for the segi error monitoring service",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",