Skip to content

Commit 7e27a75

Browse files
committed
ref: Make handleException private
1 parent e9f0629 commit 7e27a75

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

packages/replay/src/replay.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class ReplayContainer implements ReplayContainerInterface {
175175

176176
// If there is no session, then something bad has happened - can't continue
177177
if (!this.session) {
178-
this.handleException(new Error('No session found'));
178+
this._handleException(new Error('No session found'));
179179
return;
180180
}
181181

@@ -222,7 +222,7 @@ export class ReplayContainer implements ReplayContainerInterface {
222222
emit: this._handleRecordingEmit,
223223
});
224224
} catch (err) {
225-
this.handleException(err);
225+
this._handleException(err);
226226
}
227227
}
228228

@@ -252,7 +252,7 @@ export class ReplayContainer implements ReplayContainerInterface {
252252
this.eventBuffer?.destroy();
253253
this.eventBuffer = null;
254254
} catch (err) {
255-
this.handleException(err);
255+
this._handleException(err);
256256
}
257257
}
258258

@@ -269,7 +269,7 @@ export class ReplayContainer implements ReplayContainerInterface {
269269
this._stopRecording = undefined;
270270
}
271271
} catch (err) {
272-
this.handleException(err);
272+
this._handleException(err);
273273
}
274274
}
275275

@@ -284,15 +284,6 @@ export class ReplayContainer implements ReplayContainerInterface {
284284
this.startRecording();
285285
}
286286

287-
/** A wrapper to conditionally capture exceptions. */
288-
public handleException(error: unknown): void {
289-
__DEBUG_BUILD__ && logger.error('[Replay]', error);
290-
291-
if (__DEBUG_BUILD__ && this._options._experiments && this._options._experiments.captureExceptions) {
292-
captureException(error);
293-
}
294-
}
295-
296287
/**
297288
* We want to batch uploads of replay events. Save events only if
298289
* `<flushMinDelay>` milliseconds have elapsed since the last event
@@ -360,6 +351,15 @@ export class ReplayContainer implements ReplayContainerInterface {
360351
return this._debouncedFlush.flush() as Promise<void>;
361352
}
362353

354+
/** A wrapper to conditionally capture exceptions. */
355+
private _handleException(error: unknown): void {
356+
__DEBUG_BUILD__ && logger.error('[Replay]', error);
357+
358+
if (__DEBUG_BUILD__ && this._options._experiments && this._options._experiments.captureExceptions) {
359+
captureException(error);
360+
}
361+
}
362+
363363
/**
364364
* Loads a session from storage, or creates a new one if it does not exist or
365365
* is expired.
@@ -434,7 +434,7 @@ export class ReplayContainer implements ReplayContainerInterface {
434434
this._hasInitializedCoreListeners = true;
435435
}
436436
} catch (err) {
437-
this.handleException(err);
437+
this._handleException(err);
438438
}
439439

440440
// _performanceObserver //
@@ -462,7 +462,7 @@ export class ReplayContainer implements ReplayContainerInterface {
462462
this._performanceObserver = null;
463463
}
464464
} catch (err) {
465-
this.handleException(err);
465+
this._handleException(err);
466466
}
467467
}
468468

@@ -838,7 +838,7 @@ export class ReplayContainer implements ReplayContainerInterface {
838838
eventContext,
839839
});
840840
} catch (err) {
841-
this.handleException(err);
841+
this._handleException(err);
842842
}
843843
}
844844

@@ -1031,7 +1031,7 @@ export class ReplayContainer implements ReplayContainerInterface {
10311031
setContext('Replays', {
10321032
_retryCount: this._retryCount,
10331033
});
1034-
this.handleException(err);
1034+
this._handleException(err);
10351035

10361036
// If an error happened here, it's likely that uploading the attachment
10371037
// failed, we'll can retry with the same events payload

packages/replay/test/integration/sendReplayEvent.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ describe('Integration | sendReplayEvent', () => {
389389
// Suppress console.errors
390390
const mockConsole = jest.spyOn(console, 'error').mockImplementation(jest.fn());
391391

392-
// Check errors
393-
const spyHandleException = jest.spyOn(replay, 'handleException');
392+
// @ts-ignore privaye api - Check errors
393+
const spyHandleException = jest.spyOn(replay, '_handleException');
394394

395395
expect(replay.session?.segmentId).toBe(0);
396396

0 commit comments

Comments
 (0)