1
1
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
2
/* eslint-disable max-lines */
3
3
import { getCurrentHub } from '@sentry/core' ;
4
- import { Event , Integration } from '@sentry/types' ;
4
+ import { Integration } from '@sentry/types' ;
5
5
import {
6
6
addInstrumentationHandler ,
7
- getEventDescription ,
8
7
getGlobalObject ,
9
8
htmlTreeAsString ,
10
9
parseUrl ,
@@ -22,6 +21,8 @@ interface BreadcrumbsOptions {
22
21
xhr : boolean ;
23
22
}
24
23
24
+ export const BREADCRUMB_INTEGRATION_ID = 'Breadcrumbs' ;
25
+
25
26
/**
26
27
* Default Breadcrumbs instrumentations
27
28
* TODO: Deprecated - with v6, this will be renamed to `Instrument`
@@ -30,21 +31,24 @@ export class Breadcrumbs implements Integration {
30
31
/**
31
32
* @inheritDoc
32
33
*/
33
- public static id : string = 'Breadcrumbs' ;
34
+ public static id : string = BREADCRUMB_INTEGRATION_ID ;
34
35
35
36
/**
36
37
* @inheritDoc
37
38
*/
38
39
public name : string = Breadcrumbs . id ;
39
40
40
- /** JSDoc */
41
- private readonly _options : BreadcrumbsOptions ;
41
+ /**
42
+ * Options of the breadcrumbs integration.
43
+ */
44
+ // This field is public, because we use it in the browser client to check if the `sentry` option is enabled.
45
+ public readonly options : Readonly < BreadcrumbsOptions > ;
42
46
43
47
/**
44
48
* @inheritDoc
45
49
*/
46
50
public constructor ( options ?: Partial < BreadcrumbsOptions > ) {
47
- this . _options = {
51
+ this . options = {
48
52
console : true ,
49
53
dom : true ,
50
54
fetch : true ,
@@ -55,26 +59,6 @@ export class Breadcrumbs implements Integration {
55
59
} ;
56
60
}
57
61
58
- /**
59
- * Create a breadcrumb of `sentry` from the events themselves
60
- */
61
- public addSentryBreadcrumb ( event : Event ) : void {
62
- if ( ! this . _options . sentry ) {
63
- return ;
64
- }
65
- getCurrentHub ( ) . addBreadcrumb (
66
- {
67
- category : `sentry.${ event . type === 'transaction' ? 'transaction' : 'event' } ` ,
68
- event_id : event . event_id ,
69
- level : event . level ,
70
- message : getEventDescription ( event ) ,
71
- } ,
72
- {
73
- event,
74
- } ,
75
- ) ;
76
- }
77
-
78
62
/**
79
63
* Instrument browser built-ins w/ breadcrumb capturing
80
64
* - Console API
@@ -84,19 +68,19 @@ export class Breadcrumbs implements Integration {
84
68
* - History API
85
69
*/
86
70
public setupOnce ( ) : void {
87
- if ( this . _options . console ) {
71
+ if ( this . options . console ) {
88
72
addInstrumentationHandler ( 'console' , _consoleBreadcrumb ) ;
89
73
}
90
- if ( this . _options . dom ) {
91
- addInstrumentationHandler ( 'dom' , _domBreadcrumb ( this . _options . dom ) ) ;
74
+ if ( this . options . dom ) {
75
+ addInstrumentationHandler ( 'dom' , _domBreadcrumb ( this . options . dom ) ) ;
92
76
}
93
- if ( this . _options . xhr ) {
77
+ if ( this . options . xhr ) {
94
78
addInstrumentationHandler ( 'xhr' , _xhrBreadcrumb ) ;
95
79
}
96
- if ( this . _options . fetch ) {
80
+ if ( this . options . fetch ) {
97
81
addInstrumentationHandler ( 'fetch' , _fetchBreadcrumb ) ;
98
82
}
99
- if ( this . _options . history ) {
83
+ if ( this . options . history ) {
100
84
addInstrumentationHandler ( 'history' , _historyBreadcrumb ) ;
101
85
}
102
86
}
0 commit comments