@extn/segi-js 0.2.1 → 0.2.3

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.
@@ -350,13 +350,24 @@ async function activateReplay(args) {
350
350
  };
351
351
  const w = window;
352
352
  const scheduleRrwebStart = (run) => {
353
- if (typeof w.requestIdleCallback === "function") {
354
- w.requestIdleCallback(run, { timeout: 2e3 });
353
+ let fired = false;
354
+ const onIdle = () => {
355
+ if (fired) return;
356
+ fired = true;
357
+ if (typeof w.requestIdleCallback === "function") {
358
+ w.requestIdleCallback(run, { timeout: 2e3 });
359
+ } else {
360
+ setTimeout(run, 1e3);
361
+ }
362
+ };
363
+ if (typeof document !== "undefined" && document.readyState === "complete") {
364
+ onIdle();
355
365
  } else {
356
- setTimeout(run, 1e3);
366
+ window.addEventListener("load", onIdle, { once: true });
367
+ setTimeout(onIdle, 5e3);
357
368
  }
358
369
  };
359
- void Promise.resolve().then(() => _interopRequireWildcard(require("../rrweb-3KMD3KRA.js"))).then(
370
+ void Promise.resolve().then(() => _interopRequireWildcard(require("../rrweb-IYWAVI4X.js"))).then(
360
371
  ({ startRrweb }) => new Promise((resolve) => {
361
372
  scheduleRrwebStart(() => {
362
373
  startRrweb({
@@ -468,6 +479,7 @@ var replayApi = {
468
479
  active.paused = false;
469
480
  }
470
481
  active.pagesVisited += 1;
482
+ _optionalChain([active, 'access', _59 => _59.rrweb, 'optionalAccess', _60 => _60.takeFullSnapshot, 'call', _61 => _61()]);
471
483
  void postTrace(active.config, "/events", {
472
484
  events: [
473
485
  {
@@ -482,7 +494,7 @@ var replayApi = {
482
494
  },
483
495
  /** Test seam: returns null when replay was not activated for this session. */
484
496
  _sessionUid() {
485
- return _nullishCoalesce(_optionalChain([active, 'optionalAccess', _59 => _59.sessionUid]), () => ( null));
497
+ return _nullishCoalesce(_optionalChain([active, 'optionalAccess', _62 => _62.sessionUid]), () => ( null));
486
498
  }
487
499
  };
488
500
 
@@ -350,13 +350,24 @@ async function activateReplay(args) {
350
350
  };
351
351
  const w = window;
352
352
  const scheduleRrwebStart = (run) => {
353
- if (typeof w.requestIdleCallback === "function") {
354
- w.requestIdleCallback(run, { timeout: 2e3 });
353
+ let fired = false;
354
+ const onIdle = () => {
355
+ if (fired) return;
356
+ fired = true;
357
+ if (typeof w.requestIdleCallback === "function") {
358
+ w.requestIdleCallback(run, { timeout: 2e3 });
359
+ } else {
360
+ setTimeout(run, 1e3);
361
+ }
362
+ };
363
+ if (typeof document !== "undefined" && document.readyState === "complete") {
364
+ onIdle();
355
365
  } else {
356
- setTimeout(run, 1e3);
366
+ window.addEventListener("load", onIdle, { once: true });
367
+ setTimeout(onIdle, 5e3);
357
368
  }
358
369
  };
359
- void import("../rrweb-VLNL5J73.mjs").then(
370
+ void import("../rrweb-YPWAT5PS.mjs").then(
360
371
  ({ startRrweb }) => new Promise((resolve) => {
361
372
  scheduleRrwebStart(() => {
362
373
  startRrweb({
@@ -468,6 +479,7 @@ var replayApi = {
468
479
  active.paused = false;
469
480
  }
470
481
  active.pagesVisited += 1;
482
+ active.rrweb?.takeFullSnapshot();
471
483
  void postTrace(active.config, "/events", {
472
484
  events: [
473
485
  {
@@ -69,13 +69,27 @@ async function startRrweb(args) {
69
69
  maskTextClass: maskClass,
70
70
  recordCanvas: false,
71
71
  collectFonts: false,
72
- checkoutEveryNms: CHECKOUT_EVERY_MS
72
+ checkoutEveryNms: CHECKOUT_EVERY_MS,
73
+ // Explicit (rather than relying on default) so we don't regress
74
+ // when the rrweb default changes between alpha builds. Inlines
75
+ // <link rel="stylesheet"> CSS at snapshot time — playback in the
76
+ // admin iframe doesn't have access to the customer's origin to
77
+ // fetch them otherwise.
78
+ inlineStylesheet: true
73
79
  });
74
80
  stopFn = typeof stop === "function" ? stop : null;
81
+ setTimeout(() => {
82
+ if (stopped || paused) return;
83
+ try {
84
+ const rec = rrweb.record;
85
+ _optionalChain([rec, 'access', _7 => _7.takeFullSnapshot, 'optionalCall', _8 => _8()]);
86
+ } catch (e3) {
87
+ }
88
+ }, 100);
75
89
  }
76
90
  function stopRrwebOnly() {
77
91
  try {
78
- _optionalChain([stopFn, 'optionalCall', _7 => _7()]);
92
+ _optionalChain([stopFn, 'optionalCall', _9 => _9()]);
79
93
  } finally {
80
94
  stopFn = null;
81
95
  }
@@ -88,7 +102,7 @@ async function startRrweb(args) {
88
102
  bufferBytes = 0;
89
103
  try {
90
104
  args.sendChunk(chunk, useBeacon);
91
- } catch (e3) {
105
+ } catch (e4) {
92
106
  }
93
107
  }
94
108
  function onActivity() {
@@ -132,7 +146,15 @@ async function startRrweb(args) {
132
146
  document.removeEventListener("visibilitychange", onVisibilityChange);
133
147
  }
134
148
  },
135
- flush
149
+ flush,
150
+ takeFullSnapshot() {
151
+ if (stopped || paused) return;
152
+ try {
153
+ const rec = rrweb.record;
154
+ _optionalChain([rec, 'access', _10 => _10.takeFullSnapshot, 'optionalCall', _11 => _11()]);
155
+ } catch (e5) {
156
+ }
157
+ }
136
158
  };
137
159
  }
138
160
 
@@ -69,9 +69,23 @@ async function startRrweb(args) {
69
69
  maskTextClass: maskClass,
70
70
  recordCanvas: false,
71
71
  collectFonts: false,
72
- checkoutEveryNms: CHECKOUT_EVERY_MS
72
+ checkoutEveryNms: CHECKOUT_EVERY_MS,
73
+ // Explicit (rather than relying on default) so we don't regress
74
+ // when the rrweb default changes between alpha builds. Inlines
75
+ // <link rel="stylesheet"> CSS at snapshot time — playback in the
76
+ // admin iframe doesn't have access to the customer's origin to
77
+ // fetch them otherwise.
78
+ inlineStylesheet: true
73
79
  });
74
80
  stopFn = typeof stop === "function" ? stop : null;
81
+ setTimeout(() => {
82
+ if (stopped || paused) return;
83
+ try {
84
+ const rec = rrweb.record;
85
+ rec.takeFullSnapshot?.();
86
+ } catch {
87
+ }
88
+ }, 100);
75
89
  }
76
90
  function stopRrwebOnly() {
77
91
  try {
@@ -132,7 +146,15 @@ async function startRrweb(args) {
132
146
  document.removeEventListener("visibilitychange", onVisibilityChange);
133
147
  }
134
148
  },
135
- flush
149
+ flush,
150
+ takeFullSnapshot() {
151
+ if (stopped || paused) return;
152
+ try {
153
+ const rec = rrweb.record;
154
+ rec.takeFullSnapshot?.();
155
+ } catch {
156
+ }
157
+ }
136
158
  };
137
159
  }
138
160
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extn/segi-js",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Browser JavaScript SDK for the segi error monitoring service",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "rrweb": "2.0.0-alpha.4",
31
+ "rrweb": "2.0.0-alpha.20",
32
32
  "@extn/segi-shared": "0.2.0"
33
33
  },
34
34
  "devDependencies": {