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