@extn/segi-js 0.2.6 → 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.
@@ -370,7 +370,7 @@ async function activateReplay(args) {
370
370
  setTimeout(onIdle, 5e3);
371
371
  }
372
372
  };
373
- void Promise.resolve().then(() => _interopRequireWildcard(require("../rrweb-KAUSOLTH.js"))).then(
373
+ void Promise.resolve().then(() => _interopRequireWildcard(require("../rrweb-VXG3W6SS.js"))).then(
374
374
  ({ startRrweb }) => new Promise((resolve) => {
375
375
  scheduleRrwebStart(() => {
376
376
  startRrweb({
@@ -402,14 +402,6 @@ async function activateReplay(args) {
402
402
  },
403
403
  body: bodyStr
404
404
  });
405
- if (typeof console !== "undefined") {
406
- console.log(
407
- "[segi.replay] /replay POST",
408
- res.status,
409
- bodyStr.length,
410
- "bytes"
411
- );
412
- }
413
405
  if (res.status === 429) {
414
406
  if (active) {
415
407
  active.replayBlocked = true;
@@ -417,13 +409,7 @@ async function activateReplay(args) {
417
409
  active.rrweb = null;
418
410
  }
419
411
  }
420
- } catch (err) {
421
- if (typeof console !== "undefined") {
422
- console.log(
423
- "[segi.replay] /replay POST FETCH FAILED:",
424
- err.message
425
- );
426
- }
412
+ } catch (e13) {
427
413
  }
428
414
  }
429
415
  }).then(resolve, () => resolve(null));
@@ -501,11 +487,14 @@ var replayApi = {
501
487
  * Bumps the page-views counter and emits a fresh page_view event.
502
488
  */
503
489
  notifyRouteChange(url, title) {
504
- if (!active || active.paused) return;
505
- if (isPathBlocked(active.options, location.pathname)) {
506
- _optionalChain([active, 'access', _47 => _47.heatmap, 'optionalAccess', _48 => _48.pause, 'call', _49 => _49()]);
507
- _optionalChain([active, 'access', _50 => _50.rrweb, 'optionalAccess', _51 => _51.pause, 'call', _52 => _52()]);
508
- 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
+ }
509
498
  return;
510
499
  }
511
500
  if (active.paused) {
@@ -370,7 +370,7 @@ async function activateReplay(args) {
370
370
  setTimeout(onIdle, 5e3);
371
371
  }
372
372
  };
373
- void import("../rrweb-DCBIDQEX.mjs").then(
373
+ void import("../rrweb-O2KFXCVA.mjs").then(
374
374
  ({ startRrweb }) => new Promise((resolve) => {
375
375
  scheduleRrwebStart(() => {
376
376
  startRrweb({
@@ -402,14 +402,6 @@ async function activateReplay(args) {
402
402
  },
403
403
  body: bodyStr
404
404
  });
405
- if (typeof console !== "undefined") {
406
- console.log(
407
- "[segi.replay] /replay POST",
408
- res.status,
409
- bodyStr.length,
410
- "bytes"
411
- );
412
- }
413
405
  if (res.status === 429) {
414
406
  if (active) {
415
407
  active.replayBlocked = true;
@@ -417,13 +409,7 @@ async function activateReplay(args) {
417
409
  active.rrweb = null;
418
410
  }
419
411
  }
420
- } catch (err) {
421
- if (typeof console !== "undefined") {
422
- console.log(
423
- "[segi.replay] /replay POST FETCH FAILED:",
424
- err.message
425
- );
426
- }
412
+ } catch {
427
413
  }
428
414
  }
429
415
  }).then(resolve, () => resolve(null));
@@ -501,11 +487,14 @@ var replayApi = {
501
487
  * Bumps the page-views counter and emits a fresh page_view event.
502
488
  */
503
489
  notifyRouteChange(url, title) {
504
- if (!active || active.paused) return;
505
- if (isPathBlocked(active.options, location.pathname)) {
506
- active.heatmap?.pause();
507
- active.rrweb?.pause();
508
- 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
+ }
509
498
  return;
510
499
  }
511
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.6",
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",