4
4
import { captureException } from '@sentry/core' ;
5
5
import { logger } from '@sentry/utils' ;
6
6
7
- import type { EventBuffer , RecordingEvent , WorkerAddEventResponse , WorkerRequest , WorkerResponse } from './types' ;
7
+ import type { EventBuffer , RecordingEvent , WorkerAddEventResponse , WorkerRequest } from './types' ;
8
8
import workerString from './worker/worker.js' ;
9
9
10
10
interface CreateEventBufferParams {
@@ -53,14 +53,14 @@ class EventBufferArray implements EventBuffer {
53
53
this . _events = [ ] ;
54
54
}
55
55
56
- public async addEvent ( event : RecordingEvent , isCheckout ?: boolean ) : Promise < boolean > {
56
+ public async addEvent ( event : RecordingEvent , isCheckout ?: boolean ) : Promise < void > {
57
57
if ( isCheckout ) {
58
58
this . _events = [ event ] ;
59
- return true ;
59
+ return ;
60
60
}
61
61
62
62
this . _events . push ( event ) ;
63
- return true ;
63
+ return ;
64
64
}
65
65
66
66
public finish ( ) : Promise < string > {
@@ -134,7 +134,7 @@ export class EventBufferCompressionWorker implements EventBuffer {
134
134
/**
135
135
* Post message to worker and wait for response before resolving promise.
136
136
*/
137
- private _postMessage ( { id, method, args } : WorkerRequest ) : Promise < WorkerResponse [ 'response' ] > {
137
+ private _postMessage < T > ( { id, method, args } : WorkerRequest ) : Promise < T > {
138
138
return new Promise ( ( resolve , reject ) => {
139
139
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
140
140
const listener = ( { data } : MessageEvent ) => {
@@ -181,7 +181,7 @@ export class EventBufferCompressionWorker implements EventBuffer {
181
181
* Send the event to the worker.
182
182
*/
183
183
private async _sendEventToWorker ( event : RecordingEvent ) : Promise < WorkerAddEventResponse > {
184
- const promise = this . _postMessage ( {
184
+ const promise = this . _postMessage < void > ( {
185
185
id : this . _getAndIncrementId ( ) ,
186
186
method : 'addEvent' ,
187
187
args : [ event ] ,
@@ -190,19 +190,19 @@ export class EventBufferCompressionWorker implements EventBuffer {
190
190
// XXX: See note in `get length()`
191
191
this . _eventBufferItemLength ++ ;
192
192
193
- return promise as Promise < WorkerAddEventResponse > ;
193
+ return promise ;
194
194
}
195
195
196
196
/**
197
197
* Finish the request and return the compressed data from the worker.
198
198
*/
199
199
private async _finishRequest ( id : number ) : Promise < Uint8Array > {
200
- const promise = this . _postMessage ( { id, method : 'finish' , args : [ ] } ) ;
200
+ const promise = this . _postMessage < Uint8Array > ( { id, method : 'finish' , args : [ ] } ) ;
201
201
202
202
// XXX: See note in `get length()`
203
203
this . _eventBufferItemLength = 0 ;
204
204
205
- return promise as Promise < Uint8Array > ;
205
+ return promise ;
206
206
}
207
207
208
208
/** Get the current ID and increment it for the next call. */
0 commit comments