@sentry/replay 7.70.0 → 7.71.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.
package/esm/index.js CHANGED
@@ -4998,53 +4998,56 @@ function handleGlobalEventListener(
4998
4998
  ) {
4999
4999
  const afterSendHandler = includeAfterSendEventHandling ? handleAfterSendEvent(replay) : undefined;
5000
5000
 
5001
- return (event, hint) => {
5002
- // Do nothing if replay has been disabled
5003
- if (!replay.isEnabled()) {
5004
- return event;
5005
- }
5001
+ return Object.assign(
5002
+ (event, hint) => {
5003
+ // Do nothing if replay has been disabled
5004
+ if (!replay.isEnabled()) {
5005
+ return event;
5006
+ }
5006
5007
 
5007
- if (isReplayEvent(event)) {
5008
- // Replays have separate set of breadcrumbs, do not include breadcrumbs
5009
- // from core SDK
5010
- delete event.breadcrumbs;
5011
- return event;
5012
- }
5008
+ if (isReplayEvent(event)) {
5009
+ // Replays have separate set of breadcrumbs, do not include breadcrumbs
5010
+ // from core SDK
5011
+ delete event.breadcrumbs;
5012
+ return event;
5013
+ }
5013
5014
 
5014
- // We only want to handle errors & transactions, nothing else
5015
- if (!isErrorEvent(event) && !isTransactionEvent(event)) {
5016
- return event;
5017
- }
5015
+ // We only want to handle errors & transactions, nothing else
5016
+ if (!isErrorEvent(event) && !isTransactionEvent(event)) {
5017
+ return event;
5018
+ }
5018
5019
 
5019
- // Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
5020
- // As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
5021
- if (isRrwebError(event, hint) && !replay.getOptions()._experiments.captureExceptions) {
5022
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Ignoring error from rrweb internals', event);
5023
- return null;
5024
- }
5020
+ // Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
5021
+ // As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
5022
+ if (isRrwebError(event, hint) && !replay.getOptions()._experiments.captureExceptions) {
5023
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Ignoring error from rrweb internals', event);
5024
+ return null;
5025
+ }
5025
5026
 
5026
- // When in buffer mode, we decide to sample here.
5027
- // Later, in `handleAfterSendEvent`, if the replayId is set, we know that we sampled
5028
- // And convert the buffer session to a full session
5029
- const isErrorEventSampled = shouldSampleForBufferEvent(replay, event);
5027
+ // When in buffer mode, we decide to sample here.
5028
+ // Later, in `handleAfterSendEvent`, if the replayId is set, we know that we sampled
5029
+ // And convert the buffer session to a full session
5030
+ const isErrorEventSampled = shouldSampleForBufferEvent(replay, event);
5030
5031
 
5031
- // Tag errors if it has been sampled in buffer mode, or if it is session mode
5032
- // Only tag transactions if in session mode
5033
- const shouldTagReplayId = isErrorEventSampled || replay.recordingMode === 'session';
5032
+ // Tag errors if it has been sampled in buffer mode, or if it is session mode
5033
+ // Only tag transactions if in session mode
5034
+ const shouldTagReplayId = isErrorEventSampled || replay.recordingMode === 'session';
5034
5035
 
5035
- if (shouldTagReplayId) {
5036
- event.tags = { ...event.tags, replayId: replay.getSessionId() };
5037
- }
5036
+ if (shouldTagReplayId) {
5037
+ event.tags = { ...event.tags, replayId: replay.getSessionId() };
5038
+ }
5038
5039
 
5039
- // In cases where a custom client is used that does not support the new hooks (yet),
5040
- // we manually call this hook method here
5041
- if (afterSendHandler) {
5042
- // Pretend the error had a 200 response so we always capture it
5043
- afterSendHandler(event, { statusCode: 200 });
5044
- }
5040
+ // In cases where a custom client is used that does not support the new hooks (yet),
5041
+ // we manually call this hook method here
5042
+ if (afterSendHandler) {
5043
+ // Pretend the error had a 200 response so we always capture it
5044
+ afterSendHandler(event, { statusCode: 200 });
5045
+ }
5045
5046
 
5046
- return event;
5047
- };
5047
+ return event;
5048
+ },
5049
+ { id: 'Replay' },
5050
+ );
5048
5051
  }
5049
5052
 
5050
5053
  /**
@@ -6420,7 +6423,12 @@ function addGlobalListeners(replay) {
6420
6423
 
6421
6424
  // Tag all (non replay) events that get sent to Sentry with the current
6422
6425
  // replay ID so that we can reference them later in the UI
6423
- addGlobalEventProcessor(handleGlobalEventListener(replay, !hasHooks(client)));
6426
+ const eventProcessor = handleGlobalEventListener(replay, !hasHooks(client));
6427
+ if (client && client.addEventProcessor) {
6428
+ client.addEventProcessor(eventProcessor);
6429
+ } else {
6430
+ addGlobalEventProcessor(eventProcessor);
6431
+ }
6424
6432
 
6425
6433
  // If a custom client has no hooks yet, we continue to use the "old" implementation
6426
6434
  if (hasHooks(client)) {