Skip to content

Commit 614e71b

Browse files
committed
browser fixes
1 parent 55189fa commit 614e71b

File tree

3 files changed

+49
-43
lines changed

3 files changed

+49
-43
lines changed

packages/browser/src/integrations/dedupe.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ export class Dedupe implements Integration {
4343
__DEBUG_BUILD__ && logger.warn('Event dropped due to being a duplicate of previously captured event.');
4444
return null;
4545
}
46-
} catch (_oO) {
47-
return (this._previousEvent = currentEvent);
48-
}
46+
} catch (_oO) {} // eslint-disable-line no-empty
4947

5048
return (this._previousEvent = currentEvent);
5149
}

packages/replay/src/coreHandlers/handleGlobalEvent.ts

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,54 @@ export function handleGlobalEventListener(
1616
): (event: Event, hint: EventHint) => Event | null {
1717
const afterSendHandler = includeAfterSendEventHandling ? handleAfterSendEvent(replay) : undefined;
1818

19-
return (event: Event, hint: EventHint) => {
20-
// Do nothing if replay has been disabled
21-
if (!replay.isEnabled()) {
22-
return event;
23-
}
19+
return Object.assign(
20+
(event: Event, hint: EventHint) => {
21+
// Do nothing if replay has been disabled
22+
if (!replay.isEnabled()) {
23+
return event;
24+
}
2425

25-
if (isReplayEvent(event)) {
26-
// Replays have separate set of breadcrumbs, do not include breadcrumbs
27-
// from core SDK
28-
delete event.breadcrumbs;
29-
return event;
30-
}
26+
if (isReplayEvent(event)) {
27+
// Replays have separate set of breadcrumbs, do not include breadcrumbs
28+
// from core SDK
29+
delete event.breadcrumbs;
30+
return event;
31+
}
3132

32-
// We only want to handle errors & transactions, nothing else
33-
if (!isErrorEvent(event) && !isTransactionEvent(event)) {
34-
return event;
35-
}
33+
// We only want to handle errors & transactions, nothing else
34+
if (!isErrorEvent(event) && !isTransactionEvent(event)) {
35+
return event;
36+
}
3637

37-
// Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
38-
// As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
39-
if (isRrwebError(event, hint) && !replay.getOptions()._experiments.captureExceptions) {
40-
__DEBUG_BUILD__ && logger.log('[Replay] Ignoring error from rrweb internals', event);
41-
return null;
42-
}
38+
// Unless `captureExceptions` is enabled, we want to ignore errors coming from rrweb
39+
// As there can be a bunch of stuff going wrong in internals there, that we don't want to bubble up to users
40+
if (isRrwebError(event, hint) && !replay.getOptions()._experiments.captureExceptions) {
41+
__DEBUG_BUILD__ && logger.log('[Replay] Ignoring error from rrweb internals', event);
42+
return null;
43+
}
4344

44-
// When in buffer mode, we decide to sample here.
45-
// Later, in `handleAfterSendEvent`, if the replayId is set, we know that we sampled
46-
// And convert the buffer session to a full session
47-
const isErrorEventSampled = shouldSampleForBufferEvent(replay, event);
45+
// When in buffer mode, we decide to sample here.
46+
// Later, in `handleAfterSendEvent`, if the replayId is set, we know that we sampled
47+
// And convert the buffer session to a full session
48+
const isErrorEventSampled = shouldSampleForBufferEvent(replay, event);
4849

49-
// Tag errors if it has been sampled in buffer mode, or if it is session mode
50-
// Only tag transactions if in session mode
51-
const shouldTagReplayId = isErrorEventSampled || replay.recordingMode === 'session';
50+
// Tag errors if it has been sampled in buffer mode, or if it is session mode
51+
// Only tag transactions if in session mode
52+
const shouldTagReplayId = isErrorEventSampled || replay.recordingMode === 'session';
5253

53-
if (shouldTagReplayId) {
54-
event.tags = { ...event.tags, replayId: replay.getSessionId() };
55-
}
54+
if (shouldTagReplayId) {
55+
event.tags = { ...event.tags, replayId: replay.getSessionId() };
56+
}
5657

57-
// In cases where a custom client is used that does not support the new hooks (yet),
58-
// we manually call this hook method here
59-
if (afterSendHandler) {
60-
// Pretend the error had a 200 response so we always capture it
61-
afterSendHandler(event, { statusCode: 200 });
62-
}
58+
// In cases where a custom client is used that does not support the new hooks (yet),
59+
// we manually call this hook method here
60+
if (afterSendHandler) {
61+
// Pretend the error had a 200 response so we always capture it
62+
afterSendHandler(event, { statusCode: 200 });
63+
}
6364

64-
return event;
65-
};
65+
return event;
66+
},
67+
{ id: 'Replay' },
68+
);
6669
}

packages/replay/src/util/addGlobalListeners.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ export function addGlobalListeners(replay: ReplayContainer): void {
2626

2727
// Tag all (non replay) events that get sent to Sentry with the current
2828
// replay ID so that we can reference them later in the UI
29-
addGlobalEventProcessor(handleGlobalEventListener(replay, !hasHooks(client)));
29+
const eventProcessor = handleGlobalEventListener(replay, !hasHooks(client));
30+
if (client && client.addEventProcessor) {
31+
client.addEventProcessor(eventProcessor);
32+
} else {
33+
addGlobalEventProcessor(eventProcessor);
34+
}
3035

3136
// If a custom client has no hooks yet, we continue to use the "old" implementation
3237
if (hasHooks(client)) {

0 commit comments

Comments
 (0)