@@ -8,7 +8,11 @@ import {
88 makeMultiplexedTransport ,
99 parseEnvelope ,
1010} from '../../../src' ;
11- import { eventFromEnvelope } from '../../../src/transports/multiplexed' ;
11+ import {
12+ eventFromEnvelope ,
13+ makeSimpleMultiplexedTransport ,
14+ SIMPLE_MULTIPLEXED_TRANSPORT_EXTRA_ROUTING_KEY ,
15+ } from '../../../src/transports/multiplexed' ;
1216import type { ClientReport } from '../../../src/types-hoist/clientreport' ;
1317import type { Envelope , EventEnvelope , EventItem } from '../../../src/types-hoist/envelope' ;
1418import type { TransactionEvent } from '../../../src/types-hoist/event' ;
@@ -242,3 +246,82 @@ describe('makeMultiplexedTransport', () => {
242246 await transport . send ( TRANSACTION_ENVELOPE ) ;
243247 } ) ;
244248} ) ;
249+
250+ describe ( 'makeSimpleMultiplexedTransport()' , ( ) => {
251+ it ( 'sends events to targets provided in event.extra[SIMPLE_MULTIPLEXED_TRANSPORT_EXTRA_ROUTING_KEY]' , async ( ) => {
252+ expect . assertions ( 2 ) ;
253+
254+ const makeTransport = makeSimpleMultiplexedTransport (
255+ createTestTransport (
256+ url => {
257+ expect ( url ) . toBe ( DSN1_URL ) ;
258+ } ,
259+ url => {
260+ expect ( url ) . toBe ( DSN2_URL ) ;
261+ } ,
262+ ) ,
263+ ) ;
264+
265+ const envelope = createEnvelope < EventEnvelope > ( { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' , sent_at : '123' } , [
266+ [
267+ { type : 'event' } ,
268+ {
269+ event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,
270+ extra : {
271+ [ SIMPLE_MULTIPLEXED_TRANSPORT_EXTRA_ROUTING_KEY ] : [ DSN1 , DSN2 ] ,
272+ } ,
273+ } ,
274+ ] as EventItem ,
275+ ] ) ;
276+
277+ const transport = makeTransport ( { url : DSN1_URL , ...transportOptions } ) ;
278+ await transport . send ( envelope ) ;
279+ } ) ;
280+
281+ it ( 'sends events to default DSN if event.extra[SIMPLE_MULTIPLEXED_TRANSPORT_EXTRA_ROUTING_KEY] is not set' , async ( ) => {
282+ expect . assertions ( 1 ) ;
283+
284+ const makeTransport = makeSimpleMultiplexedTransport (
285+ createTestTransport ( url => {
286+ expect ( url ) . toBe ( DSN1_URL ) ;
287+ } ) ,
288+ ) ;
289+
290+ const envelope = createEnvelope < EventEnvelope > ( { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' , sent_at : '123' } , [
291+ [
292+ { type : 'event' } ,
293+ {
294+ event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,
295+ } ,
296+ ] as EventItem ,
297+ ] ) ;
298+
299+ const transport = makeTransport ( { url : DSN1_URL , ...transportOptions } ) ;
300+ await transport . send ( envelope ) ;
301+ } ) ;
302+
303+ it ( 'sends events to default DSN if event.extra[SIMPLE_MULTIPLEXED_TRANSPORT_EXTRA_ROUTING_KEY] is an empty array' , async ( ) => {
304+ expect . assertions ( 1 ) ;
305+
306+ const makeTransport = makeSimpleMultiplexedTransport (
307+ createTestTransport ( url => {
308+ expect ( url ) . toBe ( DSN1_URL ) ;
309+ } ) ,
310+ ) ;
311+
312+ const envelope = createEnvelope < EventEnvelope > ( { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' , sent_at : '123' } , [
313+ [
314+ { type : 'event' } ,
315+ {
316+ event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,
317+ extra : {
318+ [ SIMPLE_MULTIPLEXED_TRANSPORT_EXTRA_ROUTING_KEY ] : [ ] ,
319+ } ,
320+ } ,
321+ ] as EventItem ,
322+ ] ) ;
323+
324+ const transport = makeTransport ( { url : DSN1_URL , ...transportOptions } ) ;
325+ await transport . send ( envelope ) ;
326+ } ) ;
327+ } ) ;
0 commit comments