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' ;
2
9
import { createClientReportEnvelope , createEnvelope , dsnFromString } from '@sentry/utils' ;
3
10
import { TextEncoder } from 'util' ;
4
11
@@ -15,9 +22,10 @@ const ERROR_ENVELOPE = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4b
15
22
[ { type : 'event' } , ERROR_EVENT ] as EventItem ,
16
23
] ) ;
17
24
25
+ const TRANSACTION_EVENT : TransactionEvent = { type : 'transaction' , event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' } ;
18
26
const TRANSACTION_ENVELOPE = createEnvelope < EventEnvelope > (
19
27
{ event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' , sent_at : '123' } ,
20
- [ [ { type : 'transaction' } , { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' } ] as EventItem ] ,
28
+ [ [ { type : 'transaction' } , TRANSACTION_EVENT ] as EventItem ] ,
21
29
) ;
22
30
23
31
const DEFAULT_DISCARDED_EVENTS : ClientReport [ 'discarded_events' ] = [
@@ -143,15 +151,32 @@ describe('makeMultiplexedTransport', () => {
143
151
await transport . send ( CLIENT_REPORT_ENVELOPE ) ;
144
152
} ) ;
145
153
146
- it ( 'callback getEvent can ignore transactions' , async ( ) => {
154
+ it ( 'callback getEvent ignores transactions by default ' , async ( ) => {
147
155
expect . assertions ( 2 ) ;
148
156
149
157
const makeTransport = makeMultiplexedTransport (
150
158
createTestTransport ( url => {
151
159
expect ( url ) . toBe ( DSN2_URL ) ;
152
160
} ) ,
153
161
( { 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 ) ;
155
180
return [ DSN2 ] ;
156
181
} ,
157
182
) ;
0 commit comments