@sentry/replay 11.0.0-rc.1 → 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.
@@ -6161,8 +6161,13 @@ function handleGlobalEventListener(replay) {
6161
6161
  return event;
6162
6162
  }
6163
6163
  if (isFeedbackEvent(event)) {
6164
+ const sessionId = replay.getSessionId();
6165
+ const feedbackReplayId = event.contexts.feedback.replay_id;
6166
+ if (feedbackReplayId && feedbackReplayId !== sessionId) {
6167
+ return event;
6168
+ }
6164
6169
  replay.flush();
6165
- event.contexts.feedback.replay_id = replay.getSessionId();
6170
+ event.contexts.feedback.replay_id = sessionId;
6166
6171
  addFeedbackBreadcrumb(replay, event);
6167
6172
  return event;
6168
6173
  }
@@ -6797,17 +6802,29 @@ function addGlobalListeners(replay) {
6797
6802
  client.on("spanEnd", (span) => {
6798
6803
  replay.lastActiveSpan = span;
6799
6804
  });
6805
+ let replayIdOnFeedbackOpen;
6800
6806
  client.on("beforeSendFeedback", async (feedbackEvent, options) => {
6807
+ const feedbackContext = feedbackEvent.contexts?.feedback;
6808
+ if (!options?.includeReplay || !feedbackContext) {
6809
+ return;
6810
+ }
6811
+ if (feedbackContext.source === "widget" && replayIdOnFeedbackOpen) {
6812
+ feedbackContext.replay_id = replayIdOnFeedbackOpen;
6813
+ replayIdOnFeedbackOpen = void 0;
6814
+ return;
6815
+ }
6801
6816
  const replayId = replay.getSessionId();
6802
- if (options?.includeReplay && replay.isEnabled() && replayId && feedbackEvent.contexts?.feedback) {
6803
- if (feedbackEvent.contexts.feedback.source === "api") {
6817
+ if (replay.isEnabled() && replayId) {
6818
+ if (feedbackContext.source === "api") {
6804
6819
  await replay.sendBufferedReplayOrFlush();
6805
6820
  }
6806
- feedbackEvent.contexts.feedback.replay_id = replayId;
6821
+ feedbackContext.replay_id = replayId;
6807
6822
  }
6808
6823
  });
6809
6824
  client.on("openFeedbackWidget", async () => {
6825
+ replayIdOnFeedbackOpen = void 0;
6810
6826
  await replay.sendBufferedReplayOrFlush();
6827
+ replayIdOnFeedbackOpen = replay.isEnabled() ? replay.getSessionId() : void 0;
6811
6828
  });
6812
6829
  }
6813
6830
  }