1
- import { API , getCurrentHub } from '@sentry/core' ;
2
- import { Integration , Severity } from '@sentry/types' ;
1
+ import { getCurrentHub } from '@sentry/core' ;
2
+ import { Event , Integration , Severity } from '@sentry/types' ;
3
3
import {
4
4
addInstrumentationHandler ,
5
5
getEventDescription ,
6
6
getGlobalObject ,
7
7
htmlTreeAsString ,
8
- logger ,
9
8
parseUrl ,
10
9
safeJoin ,
11
10
} from '@sentry/utils' ;
12
11
13
- import { BrowserClient } from '../client' ;
14
-
15
12
/**
16
13
* @hidden
17
14
*/
@@ -67,6 +64,26 @@ export class Breadcrumbs implements Integration {
67
64
} ;
68
65
}
69
66
67
+ /**
68
+ * Create a breadcrumb of `sentry` from the events themselves
69
+ */
70
+ public addSentryBreadcrumb ( event : Event ) : void {
71
+ if ( ! this . _options . sentry ) {
72
+ return ;
73
+ }
74
+ getCurrentHub ( ) . addBreadcrumb (
75
+ {
76
+ category : `sentry.${ event . type === 'transaction' ? 'transaction' : 'event' } ` ,
77
+ event_id : event . event_id ,
78
+ level : event . level ,
79
+ message : getEventDescription ( event ) ,
80
+ } ,
81
+ {
82
+ event,
83
+ } ,
84
+ ) ;
85
+ }
86
+
70
87
/**
71
88
* Creates breadcrumbs from console API calls
72
89
*/
@@ -151,11 +168,6 @@ export class Breadcrumbs implements Integration {
151
168
152
169
return ;
153
170
}
154
-
155
- // We only capture issued sentry requests
156
- if ( this . _options . sentry && handlerData . xhr . __sentry_own_request__ ) {
157
- addSentryBreadcrumb ( handlerData . args [ 0 ] ) ;
158
- }
159
171
}
160
172
161
173
/**
@@ -167,24 +179,6 @@ export class Breadcrumbs implements Integration {
167
179
return ;
168
180
}
169
181
170
- const client = getCurrentHub ( ) . getClient < BrowserClient > ( ) ;
171
- const dsn = client && client . getDsn ( ) ;
172
- if ( this . _options . sentry && dsn ) {
173
- const filterUrl = new API ( dsn ) . getBaseApiEndpoint ( ) ;
174
- // if Sentry key appears in URL, don't capture it as a request
175
- // but rather as our own 'sentry' type breadcrumb
176
- if (
177
- filterUrl &&
178
- handlerData . fetchData . url . indexOf ( filterUrl ) !== - 1 &&
179
- handlerData . fetchData . method === 'POST' &&
180
- handlerData . args [ 1 ] &&
181
- handlerData . args [ 1 ] . body
182
- ) {
183
- addSentryBreadcrumb ( handlerData . args [ 1 ] . body ) ;
184
- return ;
185
- }
186
- }
187
-
188
182
if ( handlerData . error ) {
189
183
getCurrentHub ( ) . addBreadcrumb (
190
184
{
@@ -306,26 +300,3 @@ export class Breadcrumbs implements Integration {
306
300
}
307
301
}
308
302
}
309
-
310
- /**
311
- * Create a breadcrumb of `sentry` from the events themselves
312
- */
313
- function addSentryBreadcrumb ( serializedData : string ) : void {
314
- // There's always something that can go wrong with deserialization...
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
- ) ;
328
- } catch ( _oO ) {
329
- logger . error ( 'Error while adding sentry type breadcrumb' ) ;
330
- }
331
- }
0 commit comments