1- import type { BaseTransportOptions , ClientReport , EventEnvelope , EventItem , Transport } from '@sentry/types' ;
1+ import type {
2+ BaseTransportOptions ,
3+ ClientReport ,
4+ EventEnvelope ,
5+ EventItem ,
6+ TransactionEvent ,
7+ Transport ,
8+ } from '@sentry/types' ;
29import { createClientReportEnvelope , createEnvelope , dsnFromString } from '@sentry/utils' ;
310import { TextEncoder } from 'util' ;
411
@@ -15,9 +22,10 @@ const ERROR_ENVELOPE = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4b
1522 [ { type : 'event' } , ERROR_EVENT ] as EventItem ,
1623] ) ;
1724
25+ const TRANSACTION_EVENT : TransactionEvent = { type : 'transaction' , event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' } ;
1826const TRANSACTION_ENVELOPE = createEnvelope < EventEnvelope > (
1927 { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' , sent_at : '123' } ,
20- [ [ { type : 'transaction' } , { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' } ] as EventItem ] ,
28+ [ [ { type : 'transaction' } , TRANSACTION_EVENT ] as EventItem ] ,
2129) ;
2230
2331const DEFAULT_DISCARDED_EVENTS : ClientReport [ 'discarded_events' ] = [
@@ -143,15 +151,32 @@ describe('makeMultiplexedTransport', () => {
143151 await transport . send ( CLIENT_REPORT_ENVELOPE ) ;
144152 } ) ;
145153
146- it ( 'callback getEvent can ignore transactions' , async ( ) => {
154+ it ( 'callback getEvent ignores transactions by default ' , async ( ) => {
147155 expect . assertions ( 2 ) ;
148156
149157 const makeTransport = makeMultiplexedTransport (
150158 createTestTransport ( url => {
151159 expect ( url ) . toBe ( DSN2_URL ) ;
152160 } ) ,
153161 ( { getEvent } ) => {
154- expect ( getEvent ( [ 'event' ] ) ) . toBeUndefined ( ) ;
162+ expect ( getEvent ( ) ) . toBeUndefined ( ) ;
163+ return [ DSN2 ] ;
164+ } ,
165+ ) ;
166+
167+ const transport = makeTransport ( { url : DSN1_URL , ...transportOptions } ) ;
168+ await transport . send ( TRANSACTION_ENVELOPE ) ;
169+ } ) ;
170+
171+ it ( 'callback getEvent can define envelope types' , async ( ) => {
172+ expect . assertions ( 2 ) ;
173+
174+ const makeTransport = makeMultiplexedTransport (
175+ createTestTransport ( url => {
176+ expect ( url ) . toBe ( DSN2_URL ) ;
177+ } ) ,
178+ ( { getEvent } ) => {
179+ expect ( getEvent ( [ 'event' , 'transaction' ] ) ) . toBe ( TRANSACTION_EVENT ) ;
155180 return [ DSN2 ] ;
156181 } ,
157182 ) ;
0 commit comments