11import { API , getCurrentHub , logger } from '@sentry/core' ;
2- import { Integration , Severity } from '@sentry/types' ;
2+ import { Breadcrumb , Integration , SentryBreadcrumbHint , Severity } from '@sentry/types' ;
33import { isFunction , isString } from '@sentry/utils/is' ;
44import { getEventDescription , getGlobalObject , parseUrl } from '@sentry/utils/misc' ;
55import { deserialize , fill } from '@sentry/utils/object' ;
@@ -27,7 +27,7 @@ function addSentryBreadcrumb(serializedData: string): void {
2727 try {
2828 const event : { [ key : string ] : any } = deserialize ( serializedData ) ;
2929
30- getCurrentHub ( ) . addBreadcrumb (
30+ Breadcrumbs . addBreadcrumb (
3131 {
3232 category : 'sentry' ,
3333 event_id : event . event_id ,
@@ -113,7 +113,7 @@ export class Breadcrumbs implements Integration {
113113 breadcrumbData . level = Severity . Error ;
114114 }
115115
116- getCurrentHub ( ) . addBreadcrumb ( breadcrumbData , {
116+ Breadcrumbs . addBreadcrumb ( breadcrumbData , {
117117 input : args ,
118118 result,
119119 } ) ;
@@ -156,7 +156,7 @@ export class Breadcrumbs implements Integration {
156156 }
157157 }
158158
159- getCurrentHub ( ) . addBreadcrumb ( breadcrumbData , {
159+ Breadcrumbs . addBreadcrumb ( breadcrumbData , {
160160 input : args ,
161161 level,
162162 } ) ;
@@ -230,7 +230,7 @@ export class Breadcrumbs implements Integration {
230230 . apply ( global , args )
231231 . then ( ( response : Response ) => {
232232 fetchData . status_code = response . status ;
233- getCurrentHub ( ) . addBreadcrumb (
233+ Breadcrumbs . addBreadcrumb (
234234 {
235235 category : 'fetch' ,
236236 data : fetchData ,
@@ -244,7 +244,7 @@ export class Breadcrumbs implements Integration {
244244 return response ;
245245 } )
246246 . catch ( ( error : Error ) => {
247- getCurrentHub ( ) . addBreadcrumb (
247+ Breadcrumbs . addBreadcrumb (
248248 {
249249 category : 'fetch' ,
250250 data : fetchData ,
@@ -295,7 +295,7 @@ export class Breadcrumbs implements Integration {
295295 from = parsedFrom . relative ;
296296 }
297297
298- getCurrentHub ( ) . addBreadcrumb ( {
298+ Breadcrumbs . addBreadcrumb ( {
299299 category : 'navigation' ,
300300 data : {
301301 from,
@@ -404,7 +404,7 @@ export class Breadcrumbs implements Integration {
404404 } catch ( e ) {
405405 /* do nothing */
406406 }
407- getCurrentHub ( ) . addBreadcrumb (
407+ Breadcrumbs . addBreadcrumb (
408408 {
409409 category : 'xhr' ,
410410 data : xhr . __sentry_xhr__ ,
@@ -447,6 +447,13 @@ export class Breadcrumbs implements Integration {
447447 } ,
448448 ) ;
449449 }
450+
451+ public static addBreadcrumb ( breadcrumb : Breadcrumb , hint ?: SentryBreadcrumbHint ) : void {
452+ if ( getCurrentHub ( ) . getIntegration ( 'Breadcrumbs' ) ) {
453+ getCurrentHub ( ) . addBreadcrumb ( breadcrumb , hint ) ;
454+ }
455+ }
456+
450457 /**
451458 * Instrument browser built-ins w/ breadcrumb capturing
452459 * - Console API
0 commit comments