@@ -313,18 +313,38 @@ export class Breadcrumbs implements Integration {
313
313
function addSentryBreadcrumb ( serializedData : string ) : void {
314
314
// There's always something that can go wrong with deserialization...
315
315
try {
316
- const event = JSON . parse ( serializedData ) ;
317
- getCurrentHub ( ) . addBreadcrumb (
318
- {
319
- category : `sentry.${ event . type === 'transaction' ? 'transaction' : 'event' } ` ,
320
- event_id : event . event_id ,
321
- level : event . level || Severity . fromString ( 'error' ) ,
322
- message : getEventDescription ( event ) ,
323
- } ,
324
- {
325
- event,
326
- } ,
327
- ) ;
316
+ try {
317
+ const event = JSON . parse ( serializedData ) ;
318
+ getCurrentHub ( ) . addBreadcrumb (
319
+ {
320
+ category : `sentry.${ event . type === 'transaction' ? 'transaction' : 'event' } ` ,
321
+ event_id : event . event_id ,
322
+ level : event . level || Severity . fromString ( 'error' ) ,
323
+ message : getEventDescription ( event ) ,
324
+ } ,
325
+ {
326
+ event,
327
+ } ,
328
+ ) ;
329
+ } catch ( _oO ) {
330
+ // We are dealing with an envelope here
331
+ // For simplicity we only deal with transactions
332
+ const envelopeLines = serializedData . split ( '\n' ) ;
333
+ const envelopeHeader = JSON . parse ( envelopeLines [ 0 ] ) ;
334
+ const itemHeader = JSON . parse ( envelopeLines [ 1 ] ) ;
335
+ const item = JSON . parse ( envelopeLines [ 2 ] ) ;
336
+ getCurrentHub ( ) . addBreadcrumb (
337
+ {
338
+ category : `sentry.${ itemHeader . type } ` ,
339
+ event_id : envelopeHeader . event_id ,
340
+ level : item . level ,
341
+ message : getEventDescription ( item ) ,
342
+ } ,
343
+ {
344
+ item,
345
+ } ,
346
+ ) ;
347
+ }
328
348
} catch ( _oO ) {
329
349
logger . error ( 'Error while adding sentry type breadcrumb' ) ;
330
350
}
0 commit comments