@sentry/replay 11.4.0 → 11.6.0

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.
@@ -23,7 +23,7 @@ const MIN_REPLAY_DURATION = 4999;
23
23
  const MIN_REPLAY_DURATION_LIMIT = 5e4;
24
24
  const MAX_REPLAY_DURATION = 36e5;
25
25
 
26
- const Hd="sentry.segment.name.source";
26
+ const jd="sentry.segment.name.source";
27
27
 
28
28
  var __defProp = Object.defineProperty;
29
29
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -158,6 +158,9 @@ class Mirror {
158
158
  (childNode) => this.removeNodeFromMap(childNode)
159
159
  );
160
160
  }
161
+ if (isElement$1(n) && n.shadowRoot) {
162
+ this.removeNodeFromMap(n.shadowRoot);
163
+ }
161
164
  }
162
165
  has(id) {
163
166
  return this.idNodeMap.has(id);
@@ -274,8 +277,9 @@ function getImplementation$1(name) {
274
277
  if (cached) {
275
278
  return cached;
276
279
  }
280
+ const windowImpl = window[name].bind(window);
281
+ let impl = windowImpl;
277
282
  const document2 = window.document;
278
- let impl = window[name];
279
283
  if (document2 && typeof document2.createElement === "function") {
280
284
  try {
281
285
  const sandbox = document2.createElement("iframe");
@@ -283,16 +287,21 @@ function getImplementation$1(name) {
283
287
  document2.head.appendChild(sandbox);
284
288
  const contentWindow = sandbox.contentWindow;
285
289
  if (contentWindow && contentWindow[name]) {
286
- impl = // eslint-disable-next-line @typescript-eslint/unbound-method
287
- contentWindow[name];
290
+ const sandboxImpl = contentWindow[name].bind(window);
291
+ impl = (...args) => {
292
+ try {
293
+ return sandboxImpl(...args);
294
+ } catch {
295
+ cachedImplementations$1[name] = windowImpl;
296
+ return windowImpl(...args);
297
+ }
298
+ };
288
299
  }
289
300
  document2.head.removeChild(sandbox);
290
301
  } catch (e) {
291
302
  }
292
303
  }
293
- return cachedImplementations$1[name] = impl.bind(
294
- window
295
- );
304
+ return cachedImplementations$1[name] = impl;
296
305
  }
297
306
  function setTimeout$1(...rest) {
298
307
  return getImplementation$1("setTimeout")(...rest);
@@ -551,6 +560,9 @@ function elementClassMatchesRegex(el, regex) {
551
560
  }
552
561
  function distanceToMatch(node, matchPredicate, limit = Infinity, distance = 0) {
553
562
  if (!node) return -1;
563
+ if (isShadowRoot(node)) {
564
+ return distanceToMatch(node.host, matchPredicate, limit, distance + 1);
565
+ }
554
566
  if (node.nodeType !== node.ELEMENT_NODE) return -1;
555
567
  if (distance > limit) return -1;
556
568
  if (matchPredicate(node)) return distance;
@@ -1751,8 +1763,9 @@ function getImplementation(name) {
1751
1763
  if (cached) {
1752
1764
  return cached;
1753
1765
  }
1766
+ const windowImpl = window[name].bind(window);
1767
+ let impl = windowImpl;
1754
1768
  const document2 = window.document;
1755
- let impl = window[name];
1756
1769
  if (document2 && typeof document2.createElement === "function") {
1757
1770
  try {
1758
1771
  const sandbox = document2.createElement("iframe");
@@ -1760,16 +1773,21 @@ function getImplementation(name) {
1760
1773
  document2.head.appendChild(sandbox);
1761
1774
  const contentWindow = sandbox.contentWindow;
1762
1775
  if (contentWindow && contentWindow[name]) {
1763
- impl = // eslint-disable-next-line @typescript-eslint/unbound-method
1764
- contentWindow[name];
1776
+ const sandboxImpl = contentWindow[name].bind(window);
1777
+ impl = (...args) => {
1778
+ try {
1779
+ return sandboxImpl(...args);
1780
+ } catch {
1781
+ cachedImplementations[name] = windowImpl;
1782
+ return windowImpl(...args);
1783
+ }
1784
+ };
1765
1785
  }
1766
1786
  document2.head.removeChild(sandbox);
1767
1787
  } catch (e) {
1768
1788
  }
1769
1789
  }
1770
- return cachedImplementations[name] = impl.bind(
1771
- window
1772
- );
1790
+ return cachedImplementations[name] = impl;
1773
1791
  }
1774
1792
  function onRequestAnimationFrame(...rest) {
1775
1793
  return getImplementation("requestAnimationFrame")(...rest);
@@ -3906,10 +3924,14 @@ class ShadowDomManager {
3906
3924
  const iframeDoc = getIFrameContentDocument(iframeElement);
3907
3925
  const iframeWindow = getIFrameContentWindow(iframeElement);
3908
3926
  if (!iframeDoc || !iframeWindow) return;
3909
- this.patchAttachShadow(
3910
- iframeWindow.Element,
3911
- iframeDoc
3912
- );
3927
+ let iframeElementConstructor;
3928
+ try {
3929
+ iframeElementConstructor = iframeWindow.Element;
3930
+ } catch (e2) {
3931
+ return;
3932
+ }
3933
+ if (!iframeElementConstructor) return;
3934
+ this.patchAttachShadow(iframeElementConstructor, iframeDoc);
3913
3935
  }
3914
3936
  /**
3915
3937
  * Patch 'attachShadow' to observe newly added shadow doms.
@@ -5056,8 +5078,8 @@ function createPerformanceEntry(entry) {
5056
5078
  }
5057
5079
  return entryType(entry);
5058
5080
  }
5059
- function getAbsoluteTime(time) {
5060
- return ((core.browserPerformanceTimeOrigin() || WINDOW.performance.timeOrigin) + time) / 1e3;
5081
+ function getAbsoluteTime(time, entryStartTime = time) {
5082
+ return core._INTERNAL_performanceTimeToSeconds(time, entryStartTime);
5061
5083
  }
5062
5084
  function createPaintEntry(entry) {
5063
5085
  const { duration, entryType, name, startTime } = entry;
@@ -5094,7 +5116,7 @@ function createNavigationEntry(entry) {
5094
5116
  return {
5095
5117
  type: `${entryType}.${type}`,
5096
5118
  start: getAbsoluteTime(startTime),
5097
- end: getAbsoluteTime(domComplete),
5119
+ end: getAbsoluteTime(domComplete, startTime),
5098
5120
  name,
5099
5121
  data: {
5100
5122
  size: transferSize,
@@ -5129,7 +5151,7 @@ function createResourceEntry(entry) {
5129
5151
  return {
5130
5152
  type: `${entryType}.${initiatorType}`,
5131
5153
  start: getAbsoluteTime(startTime),
5132
- end: getAbsoluteTime(responseEnd),
5154
+ end: getAbsoluteTime(responseEnd, startTime),
5133
5155
  name,
5134
5156
  data: {
5135
5157
  size: transferSize,
@@ -5175,7 +5197,8 @@ function getInteractionToNextPaint(metric) {
5175
5197
  function getWebVital(metric, name, nodes, attributions) {
5176
5198
  const value = metric.value;
5177
5199
  const rating = metric.rating;
5178
- const end = getAbsoluteTime(value);
5200
+ const lastEntry = metric.entries[metric.entries.length - 1];
5201
+ const end = getAbsoluteTime(lastEntry?.startTime ?? (metric.navigationStartTime ?? 0) + value);
5179
5202
  return {
5180
5203
  type: "web-vital",
5181
5204
  name,
@@ -7713,7 +7736,7 @@ class ReplayContainer {
7713
7736
  return void 0;
7714
7737
  }
7715
7738
  const spanJson = core.spanToJSON(lastRootSpan);
7716
- const source = spanJson.attributes[Hd];
7739
+ const source = spanJson.attributes[jd];
7717
7740
  if (!source || !["route", "custom"].includes(source)) {
7718
7741
  return void 0;
7719
7742
  }