@sentry/replay 11.0.0-rc.1 → 11.1.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.
@@ -21,7 +21,7 @@ const MIN_REPLAY_DURATION = 4999;
21
21
  const MIN_REPLAY_DURATION_LIMIT = 5e4;
22
22
  const MAX_REPLAY_DURATION = 36e5;
23
23
 
24
- const wd="sentry.segment.name.source";
24
+ const Wd="sentry.segment.name.source";
25
25
 
26
26
  var __defProp = Object.defineProperty;
27
27
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -6159,8 +6159,13 @@ function handleGlobalEventListener(replay) {
6159
6159
  return event;
6160
6160
  }
6161
6161
  if (isFeedbackEvent(event)) {
6162
+ const sessionId = replay.getSessionId();
6163
+ const feedbackReplayId = event.contexts.feedback.replay_id;
6164
+ if (feedbackReplayId && feedbackReplayId !== sessionId) {
6165
+ return event;
6166
+ }
6162
6167
  replay.flush();
6163
- event.contexts.feedback.replay_id = replay.getSessionId();
6168
+ event.contexts.feedback.replay_id = sessionId;
6164
6169
  addFeedbackBreadcrumb(replay, event);
6165
6170
  return event;
6166
6171
  }
@@ -6795,17 +6800,29 @@ function addGlobalListeners(replay) {
6795
6800
  client.on("spanEnd", (span) => {
6796
6801
  replay.lastActiveSpan = span;
6797
6802
  });
6803
+ let replayIdOnFeedbackOpen;
6798
6804
  client.on("beforeSendFeedback", async (feedbackEvent, options) => {
6805
+ const feedbackContext = feedbackEvent.contexts?.feedback;
6806
+ if (!options?.includeReplay || !feedbackContext) {
6807
+ return;
6808
+ }
6809
+ if (feedbackContext.source === "widget" && replayIdOnFeedbackOpen) {
6810
+ feedbackContext.replay_id = replayIdOnFeedbackOpen;
6811
+ replayIdOnFeedbackOpen = void 0;
6812
+ return;
6813
+ }
6799
6814
  const replayId = replay.getSessionId();
6800
- if (options?.includeReplay && replay.isEnabled() && replayId && feedbackEvent.contexts?.feedback) {
6801
- if (feedbackEvent.contexts.feedback.source === "api") {
6815
+ if (replay.isEnabled() && replayId) {
6816
+ if (feedbackContext.source === "api") {
6802
6817
  await replay.sendBufferedReplayOrFlush();
6803
6818
  }
6804
- feedbackEvent.contexts.feedback.replay_id = replayId;
6819
+ feedbackContext.replay_id = replayId;
6805
6820
  }
6806
6821
  });
6807
6822
  client.on("openFeedbackWidget", async () => {
6823
+ replayIdOnFeedbackOpen = void 0;
6808
6824
  await replay.sendBufferedReplayOrFlush();
6825
+ replayIdOnFeedbackOpen = replay.isEnabled() ? replay.getSessionId() : void 0;
6809
6826
  });
6810
6827
  }
6811
6828
  }
@@ -7694,7 +7711,7 @@ class ReplayContainer {
7694
7711
  return void 0;
7695
7712
  }
7696
7713
  const spanJson = spanToJSON(lastRootSpan);
7697
- const source = spanJson.attributes[wd];
7714
+ const source = spanJson.attributes[Wd];
7698
7715
  if (!source || !["route", "custom"].includes(source)) {
7699
7716
  return void 0;
7700
7717
  }