@@ -110,55 +110,58 @@ export const electronBreadcrumbsIntegration = defineIntegration(
110110 ...normalizeOptions ( userOptions ) ,
111111 } ;
112112
113- function patchEventEmitter (
114- emitter : NodeJS . EventEmitter | WebContents | BrowserWindow ,
115- category : string ,
116- shouldCapture : EventFunction | undefined | false ,
117- id ?: number | undefined ,
118- ) : void {
119- const emit = emitter . emit . bind ( emitter ) as ( event : string , ...args : unknown [ ] ) => boolean ;
120-
121- emitter . emit = ( event : string , ...args : unknown [ ] ) => {
122- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
123- if ( shouldCapture && shouldCapture ( event ) ) {
124- const breadcrumb : Breadcrumb = {
125- category : 'electron' ,
126- message : `${ category } .${ event } ` ,
127- timestamp : new Date ( ) . getTime ( ) / 1_000 ,
128- type : 'ui' ,
129- } ;
130-
131- if ( id ) {
132- breadcrumb . data = { ...getRendererProperties ( id ) } ;
133-
134- if ( ! options . captureWindowTitles && breadcrumb . data ?. title ) {
135- delete breadcrumb . data ?. title ;
136- }
137- }
138-
139- addBreadcrumb ( breadcrumb ) ;
140-
141- const attributes : Record < string , unknown > = { } ;
142-
143- if ( breadcrumb . data ?. id ) {
144- attributes . id = breadcrumb . data . id ;
145- }
146-
147- if ( breadcrumb . data ?. url ) {
148- attributes . url = breadcrumb . data . url ;
149- }
150-
151- logger . info ( logger . fmt `electron.${ category } .${ event } ` , attributes ) ;
152- }
153-
154- return emit ( event , ...args ) ;
155- } ;
156- }
157-
158113 return {
159114 name : 'ElectronBreadcrumbs' ,
160115 setup ( client : NodeClient ) {
161116 const clientOptions = client . getOptions ( ) as ElectronMainOptions | undefined ;
117+ const enableLogs = ! ! clientOptions ?. enableLogs ;
118+
119+ function patchEventEmitter (
120+ emitter : NodeJS . EventEmitter | WebContents | BrowserWindow ,
121+ category : string ,
122+ shouldCapture : EventFunction | undefined | false ,
123+ id ?: number | undefined ,
124+ ) : void {
125+ const emit = emitter . emit . bind ( emitter ) as ( event : string , ...args : unknown [ ] ) => boolean ;
126+
127+ emitter . emit = ( event : string , ...args : unknown [ ] ) => {
128+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
129+ if ( shouldCapture && shouldCapture ( event ) ) {
130+ const breadcrumb : Breadcrumb = {
131+ category : 'electron' ,
132+ message : `${ category } .${ event } ` ,
133+ timestamp : new Date ( ) . getTime ( ) / 1_000 ,
134+ type : 'ui' ,
135+ } ;
136+
137+ if ( id ) {
138+ breadcrumb . data = { ...getRendererProperties ( id ) } ;
139+
140+ if ( ! options . captureWindowTitles && breadcrumb . data ?. title ) {
141+ delete breadcrumb . data ?. title ;
142+ }
143+ }
144+
145+ addBreadcrumb ( breadcrumb ) ;
146+
147+ const attributes : Record < string , unknown > = { } ;
148+
149+ if ( breadcrumb . data ?. id ) {
150+ attributes . id = breadcrumb . data . id ;
151+ }
152+
153+ if ( breadcrumb . data ?. url ) {
154+ attributes . url = breadcrumb . data . url ;
155+ }
156+
157+ if ( enableLogs ) {
158+ logger . info ( logger . fmt `electron.${ category } .${ event } ` , attributes ) ;
159+ }
160+ }
161+
162+ return emit ( event , ...args ) ;
163+ } ;
164+ }
162165
163166 trackRendererProperties ( ) ;
164167
0 commit comments