|
2 | 2 | // TODO: figure out member access types and remove the line above |
3 | 3 |
|
4 | 4 | import { captureException } from '@sentry/core'; |
5 | | -import { ReplayRecordingData } from '@sentry/types'; |
6 | 5 | import { logger } from '@sentry/utils'; |
7 | 6 |
|
8 | | -import type { EventBuffer, RecordingEvent, WorkerRequest, WorkerResponse } from './types'; |
| 7 | +import type { EventBuffer, RecordingEvent, WorkerAddEventResponse,WorkerRequest, WorkerResponse } from './types'; |
9 | 8 | import workerString from './worker/worker.js'; |
10 | 9 |
|
11 | 10 | interface CreateEventBufferParams { |
@@ -54,13 +53,14 @@ class EventBufferArray implements EventBuffer { |
54 | 53 | this._events = []; |
55 | 54 | } |
56 | 55 |
|
57 | | - public addEvent(event: RecordingEvent, isCheckout?: boolean): void { |
| 56 | + public async addEvent(event: RecordingEvent, isCheckout?: boolean): Promise<boolean> { |
58 | 57 | if (isCheckout) { |
59 | 58 | this._events = [event]; |
60 | | - return; |
| 59 | + return true; |
61 | 60 | } |
62 | 61 |
|
63 | 62 | this._events.push(event); |
| 63 | + return true |
64 | 64 | } |
65 | 65 |
|
66 | 66 | public finish(): Promise<string> { |
@@ -107,8 +107,10 @@ export class EventBufferCompressionWorker implements EventBuffer { |
107 | 107 |
|
108 | 108 | /** |
109 | 109 | * Add an event to the event buffer. |
| 110 | + * |
| 111 | + * Returns true if event was successfuly received and processed by worker. |
110 | 112 | */ |
111 | | - public async addEvent(event: RecordingEvent, isCheckout?: boolean): Promise<ReplayRecordingData> { |
| 113 | + public async addEvent(event: RecordingEvent, isCheckout?: boolean): Promise<WorkerAddEventResponse> { |
112 | 114 | if (isCheckout) { |
113 | 115 | // This event is a checkout, make sure worker buffer is cleared before |
114 | 116 | // proceeding. |
@@ -178,17 +180,17 @@ export class EventBufferCompressionWorker implements EventBuffer { |
178 | 180 | /** |
179 | 181 | * Send the event to the worker. |
180 | 182 | */ |
181 | | - private _sendEventToWorker(event: RecordingEvent): Promise<ReplayRecordingData> { |
| 183 | + private async _sendEventToWorker(event: RecordingEvent): Promise<WorkerAddEventResponse> { |
182 | 184 | const promise = this._postMessage({ |
183 | | - id: this._getAndIncrementId(), |
| 185 | + id: this._getAndIncrementId(), |
184 | 186 | method: 'addEvent', |
185 | 187 | args: [event], |
186 | 188 | }); |
187 | 189 |
|
188 | 190 | // XXX: See note in `get length()` |
189 | 191 | this._eventBufferItemLength++; |
190 | 192 |
|
191 | | - return promise; |
| 193 | + return promise as Promise<WorkerAddEventResponse>; |
192 | 194 | } |
193 | 195 |
|
194 | 196 | /** |
|
0 commit comments