Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/transports/multiplexed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function makeMultiplexedTransport<TO extends BaseTransportOptions>(
const actualMatcher: Matcher =
matcher ||
(args => {
const event = args.getEvent();
const event = args.getEvent(['event', 'replay_event']);
if (
event?.extra?.[MULTIPLEXED_TRANSPORT_EXTRA_KEY] &&
Array.isArray(event.extra[MULTIPLEXED_TRANSPORT_EXTRA_KEY])
Expand Down
31 changes: 31 additions & 0 deletions packages/core/test/lib/transports/multiplexed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const TRANSACTION_ENVELOPE = createEnvelope<EventEnvelope>(
{ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' },
[[{ type: 'transaction' }, TRANSACTION_EVENT] as EventItem],
);
const REPLAY_EVENT = { type: 'replay_event', event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2' };

const DEFAULT_DISCARDED_EVENTS: ClientReport['discarded_events'] = [
{
Expand Down Expand Up @@ -320,4 +321,34 @@ describe('makeMultiplexedTransport() with default matcher', () => {
const transport = makeTransport({ url: DSN1_URL, ...transportOptions });
await transport.send(envelope);
});

it('sends replay events to targets provided in event.extra[MULTIPLEXED_TRANSPORT_EXTRA_KEY]', async () => {
expect.assertions(2);

const makeTransport = makeMultiplexedTransport(
createTestTransport(
url => {
expect(url).toBe(DSN1_URL);
},
url => {
expect(url).toBe(DSN2_URL);
},
),
);

const envelope = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, [
[
{ type: 'replay_event' },
{
...REPLAY_EVENT,
extra: {
[MULTIPLEXED_TRANSPORT_EXTRA_KEY]: [DSN1, DSN2],
},
},
] as EventItem,
]);
Comment on lines +339 to +349
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test creates a replay_event envelope item but asserts it as EventEnvelope / EventItem. Using the wrong envelope/item types in tests can hide real shape differences for replay envelopes. Consider typing the envelope/item as a generic Envelope/EnvelopeItem (or ReplayEnvelope if you include the full replay envelope structure) instead of asserting EventItem.

Copilot uses AI. Check for mistakes.

const transport = makeTransport({ url: DSN1_URL, ...transportOptions });
await transport.send(envelope);
});
});
Loading