11import { CoreClientSetup } from './builder/CoreClientSetup.js' ;
22import { Events } from './common/Events.js' ;
3- import { ReportEvents } from './events/ReportEvents .js' ;
3+ import { ClientEvents } from './events/ClientEvents .js' ;
44import {
55 BacktraceAttachment ,
66 BacktraceAttributeProvider ,
@@ -34,7 +34,9 @@ import { MetricsBuilder } from './modules/metrics/MetricsBuilder.js';
3434import { SingleSessionProvider } from './modules/metrics/SingleSessionProvider.js' ;
3535import { RateLimitWatcher } from './modules/rateLimiter/RateLimitWatcher.js' ;
3636
37- export abstract class BacktraceCoreClient < O extends BacktraceConfiguration = BacktraceConfiguration > {
37+ export abstract class BacktraceCoreClient <
38+ O extends BacktraceConfiguration = BacktraceConfiguration ,
39+ > extends Events < ClientEvents > {
3840 /**
3941 * Backtrace client instance
4042 */
@@ -112,7 +114,7 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
112114 }
113115
114116 protected readonly options : O ;
115- protected readonly reportEvents : Events < ReportEvents > ;
117+
116118 protected readonly attributeManager : AttributeManager ;
117119 protected readonly attachmentManager : AttachmentManager ;
118120 protected readonly fileSystem ?: FileSystem ;
@@ -128,7 +130,7 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
128130 private _enabled = false ;
129131
130132 protected constructor ( setup : CoreClientSetup < O > ) {
131- this . reportEvents = new Events ( ) ;
133+ super ( ) ;
132134
133135 this . options = setup . options ;
134136 this . fileSystem = setup . fileSystem ;
@@ -316,7 +318,7 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
316318 skipFrames : this . skipFrameOnMessage ( data ) ,
317319 } ) ;
318320
319- this . reportEvents . emit ( 'before-skip' , report ) ;
321+ this . emit ( 'before-skip' , report ) ;
320322
321323 if ( this . options . skipReport && this . options . skipReport ( report ) ) {
322324 return Promise . resolve ( BacktraceReportSubmissionResult . ReportSkipped ( ) ) ;
@@ -329,12 +331,12 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
329331
330332 const submissionAttachments = this . generateSubmissionAttachments ( report , reportAttachments ) ;
331333
332- this . reportEvents . emit ( 'before-send' , report , backtraceData , submissionAttachments ) ;
334+ this . emit ( 'before-send' , report , backtraceData , submissionAttachments ) ;
333335
334336 return this . _reportSubmission
335337 . send ( backtraceData , submissionAttachments , abortSignal )
336338 . then ( ( submissionResult ) => {
337- this . reportEvents . emit ( 'after-send' , report , backtraceData , submissionAttachments , submissionResult ) ;
339+ this . emit ( 'after-send' , report , backtraceData , submissionAttachments , submissionResult ) ;
338340 return submissionResult ;
339341 } ) ;
340342 }
@@ -403,7 +405,6 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
403405 return {
404406 client : this ,
405407 options : this . options ,
406- reportEvents : this . reportEvents ,
407408 attributeManager : this . attributeManager ,
408409 attachmentManager : this . attachmentManager ,
409410 reportSubmission : this . _reportSubmission ,
0 commit comments