@sentry/replay 11.0.0-rc.0 → 11.0.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.
@@ -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
  }