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,11 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
112114 }
113115
114116 protected readonly options : O ;
115- protected readonly reportEvents : Events < ReportEvents > ;
117+
118+ /**
119+ * @deprecated use client instance directly
120+ */
121+ protected readonly reportEvents : Events < ClientEvents > ;
116122 protected readonly attributeManager : AttributeManager ;
117123 protected readonly attachmentManager : AttachmentManager ;
118124 protected readonly fileSystem ?: FileSystem ;
@@ -128,7 +134,9 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
128134 private _enabled = false ;
129135
130136 protected constructor ( setup : CoreClientSetup < O > ) {
131- this . reportEvents = new Events ( ) ;
137+ super ( ) ;
138+
139+ this . reportEvents = this ;
132140
133141 this . options = setup . options ;
134142 this . fileSystem = setup . fileSystem ;
@@ -329,12 +337,12 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
329337
330338 const submissionAttachments = this . generateSubmissionAttachments ( report , reportAttachments ) ;
331339
332- this . reportEvents . emit ( 'before-send' , report , backtraceData , submissionAttachments ) ;
340+ this . emit ( 'before-send' , report , backtraceData , submissionAttachments ) ;
333341
334342 return this . _reportSubmission
335343 . send ( backtraceData , submissionAttachments , abortSignal )
336344 . then ( ( submissionResult ) => {
337- this . reportEvents . emit ( 'after-send' , report , backtraceData , submissionAttachments , submissionResult ) ;
345+ this . emit ( 'after-send' , report , backtraceData , submissionAttachments , submissionResult ) ;
338346 return submissionResult ;
339347 } ) ;
340348 }
@@ -403,7 +411,7 @@ export abstract class BacktraceCoreClient<O extends BacktraceConfiguration = Bac
403411 return {
404412 client : this ,
405413 options : this . options ,
406- reportEvents : this . reportEvents ,
414+ reportEvents : this ,
407415 attributeManager : this . attributeManager ,
408416 attachmentManager : this . attachmentManager ,
409417 reportSubmission : this . _reportSubmission ,
0 commit comments