Skip to content

Commit

Permalink
fix(replay): Ensure replay events go through preprocessEvent hook (#…
Browse files Browse the repository at this point in the history
…9034)

Replay events also go through global event
processors, so they should also go through this hook (replay events are
not sent via the regular baseclient methods).
  • Loading branch information
mydea committed Sep 19, 2023
1 parent d32b550 commit 252f450
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/replay/src/util/prepareReplayEvent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Scope } from '@sentry/core';
import { prepareEvent } from '@sentry/core';
import type { IntegrationIndex } from '@sentry/core/build/types/integration';
import type { Client, ReplayEvent } from '@sentry/types';
import type { Client, EventHint, ReplayEvent } from '@sentry/types';

/**
* Prepare a replay event & enrich it with the SDK metadata.
Expand All @@ -21,11 +21,19 @@ export async function prepareReplayEvent({
typeof client._integrations === 'object' && client._integrations !== null && !Array.isArray(client._integrations)
? Object.keys(client._integrations)
: undefined;

const eventHint: EventHint = { event_id, integrations };

if (client.emit) {
client.emit('preprocessEvent', event, eventHint);
}

const preparedEvent = (await prepareEvent(
client.getOptions(),
event,
{ event_id, integrations },
eventHint,
scope,
client,
)) as ReplayEvent | null;

// If e.g. a global event processor returned null
Expand Down

0 comments on commit 252f450

Please sign in to comment.