@sentry/replay 11.0.0-alpha.1 → 11.0.0-alpha.2

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,6 +23,8 @@ const MIN_REPLAY_DURATION = 4999;
23
23
  const MIN_REPLAY_DURATION_LIMIT = 5e4;
24
24
  const MAX_REPLAY_DURATION = 36e5;
25
25
 
26
+ const jd="sentry.segment.name.source";
27
+
26
28
  var __defProp = Object.defineProperty;
27
29
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
28
30
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -4917,11 +4919,9 @@ const ATTRIBUTES_TO_RECORD = /* @__PURE__ */ new Set([
4917
4919
  "aria-disabled",
4918
4920
  "data-sentry-component"
4919
4921
  ]);
4922
+ const BREADCRUMB_RELEVANT_ATTRIBUTES = /* @__PURE__ */ new Set([...ATTRIBUTES_TO_RECORD, "data-sentry-element"]);
4920
4923
  function getAttributesToRecord(attributes) {
4921
4924
  const obj = {};
4922
- if (!attributes["data-sentry-component"] && attributes["data-sentry-element"]) {
4923
- attributes["data-sentry-component"] = attributes["data-sentry-element"];
4924
- }
4925
4925
  for (const key in attributes) {
4926
4926
  if (ATTRIBUTES_TO_RECORD.has(key)) {
4927
4927
  let normalizedKey = key;
@@ -4931,6 +4931,9 @@ function getAttributesToRecord(attributes) {
4931
4931
  obj[normalizedKey] = attributes[key];
4932
4932
  }
4933
4933
  }
4934
+ if (!obj["data-sentry-component"] && attributes["data-sentry-element"]) {
4935
+ obj["data-sentry-component"] = attributes["data-sentry-element"];
4936
+ }
4934
4937
  return obj;
4935
4938
  }
4936
4939
 
@@ -5291,6 +5294,11 @@ class EventBufferSizeExceededError extends Error {
5291
5294
  super(`Event buffer exceeded maximum size of ${REPLAY_MAX_EVENT_BUFFER_SIZE}.`);
5292
5295
  }
5293
5296
  }
5297
+ class WorkerDestroyedError extends Error {
5298
+ constructor() {
5299
+ super("Worker destroyed");
5300
+ }
5301
+ }
5294
5302
 
5295
5303
  class EventBufferArray {
5296
5304
  constructor() {
@@ -5410,7 +5418,7 @@ class WorkerHandler {
5410
5418
  destroy() {
5411
5419
  DEBUG_BUILD && debug.log("Destroying compression worker");
5412
5420
  this._worker.removeEventListener("message", this._onMessage);
5413
- this._pending.forEach((pending) => pending.reject(new Error("Worker destroyed")));
5421
+ this._pending.forEach((pending) => pending.reject(new WorkerDestroyedError()));
5414
5422
  this._pending.clear();
5415
5423
  this._worker.terminate();
5416
5424
  }
@@ -5607,6 +5615,9 @@ class EventBufferProxy {
5607
5615
  await Promise.all(addEventPromises);
5608
5616
  this._fallback.clear();
5609
5617
  } catch (error) {
5618
+ if (error instanceof WorkerDestroyedError) {
5619
+ return;
5620
+ }
5610
5621
  DEBUG_BUILD && debug.exception(error, "Failed to add events when switching buffers.");
5611
5622
  }
5612
5623
  }
@@ -5970,7 +5981,7 @@ function handleHydrationError(replay, event) {
5970
5981
  const breadcrumb = createBreadcrumb({
5971
5982
  category: "replay.hydrate-error",
5972
5983
  data: {
5973
- url: core.getLocationHref()
5984
+ url: browserUtils.getLocationHref()
5974
5985
  }
5975
5986
  });
5976
5987
  addBreadcrumbEvent(replay, breadcrumb);
@@ -6908,15 +6919,24 @@ function syncMirrorAttributesFromMutationEvent(event) {
6908
6919
  for (const mutation of data.attributes) {
6909
6920
  const node = record.mirror.getNode(mutation.id);
6910
6921
  const meta = node && record.mirror.getMeta(node);
6911
- if (meta?.type !== NodeType.Element) {
6922
+ if (!node || meta?.type !== NodeType.Element) {
6912
6923
  continue;
6913
6924
  }
6925
+ const attributes = { ...meta.attributes };
6926
+ let changed = false;
6914
6927
  for (const [attributeName, value] of Object.entries(mutation.attributes)) {
6928
+ if (!BREADCRUMB_RELEVANT_ATTRIBUTES.has(attributeName)) {
6929
+ continue;
6930
+ }
6915
6931
  if (value === null) {
6916
- delete meta.attributes[attributeName];
6932
+ delete attributes[attributeName];
6917
6933
  } else {
6918
- meta.attributes[attributeName] = value;
6934
+ attributes[attributeName] = value;
6919
6935
  }
6936
+ changed = true;
6937
+ }
6938
+ if (changed) {
6939
+ record.mirror.add(node, { ...meta, attributes });
6920
6940
  }
6921
6941
  }
6922
6942
  }
@@ -7677,7 +7697,7 @@ class ReplayContainer {
7677
7697
  return void 0;
7678
7698
  }
7679
7699
  const spanJson = core.spanToJSON(lastRootSpan);
7680
- const source = spanJson.attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
7700
+ const source = spanJson.attributes[jd];
7681
7701
  if (!source || !["route", "custom"].includes(source)) {
7682
7702
  return void 0;
7683
7703
  }