Skip to content

Commit 75e0900

Browse files
committed
ref(replay): Rename mode to recordingMode
1 parent 1fdeda7 commit 75e0900

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

packages/replay/src/coreHandlers/handleGlobalEvent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even
2222

2323
// Only tag transactions with replayId if not waiting for an error
2424
// @ts-ignore private
25-
if (event.type !== 'transaction' || replay.mode === 'session') {
25+
if (event.type !== 'transaction' || replay.recordingMode === 'session') {
2626
event.tags = { ...event.tags, replayId: replay.session?.id };
2727
}
2828

29-
// Collect traceIds in _context regardless of `mode` - if it's true,
29+
// Collect traceIds in _context regardless of `recordingMode` - if it's true,
3030
// _context gets cleared on every checkout
3131
if (event.type === 'transaction' && event.contexts && event.contexts.trace && event.contexts.trace.trace_id) {
3232
replay.getContext().traceIds.add(event.contexts.trace.trace_id as string);
@@ -47,7 +47,7 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even
4747

4848
// Need to be very careful that this does not cause an infinite loop
4949
if (
50-
replay.mode === 'error' &&
50+
replay.recordingMode === 'error' &&
5151
event.exception &&
5252
event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because otherwise we could loop indefinitely with trying to capture replay and failing
5353
) {
@@ -61,7 +61,7 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even
6161
if (replay.stopRecording()) {
6262
// Reset all "capture on error" configuration before
6363
// starting a new recording
64-
replay.mode = 'session';
64+
replay.recordingMode = 'session';
6565
replay.startRecording();
6666
}
6767
});

packages/replay/src/replay.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ReplayContainer implements ReplayContainerInterface {
7070
* * session: Record the whole session, sending it continuously
7171
* * error: Always keep the last 60s of recording, and when an error occurs, send it immediately
7272
*/
73-
public mode: ReplayRecordingMode = 'session';
73+
public recordingMode: ReplayRecordingMode = 'session';
7474

7575
/**
7676
* Options to pass to `rrweb.record()`
@@ -175,7 +175,7 @@ export class ReplayContainer implements ReplayContainerInterface {
175175
// when an error will occur, so we need to keep a buffer of
176176
// replay events.
177177
if (this.session.sampled === 'error') {
178-
this.mode = 'error';
178+
this.recordingMode = 'error';
179179
}
180180

181181
// setup() is generally called on page load or manually - in both cases we
@@ -205,7 +205,7 @@ export class ReplayContainer implements ReplayContainerInterface {
205205
// When running in error sampling mode, we need to overwrite `checkoutEveryNth`
206206
// Without this, it would record forever, until an error happens, which we don't want
207207
// instead, we'll always keep the last 60 seconds of replay before an error happened
208-
...(this.mode === 'error' && { checkoutEveryNth: 60000 }),
208+
...(this.recordingMode === 'error' && { checkoutEveryNth: 60000 }),
209209
emit: this.handleRecordingEmit,
210210
});
211211
} catch (err) {
@@ -405,12 +405,12 @@ export class ReplayContainer implements ReplayContainerInterface {
405405
* processing and hand back control to caller.
406406
*/
407407
addUpdate(cb: AddUpdateCallback): void {
408-
// We need to always run `cb` (e.g. in the case of `this.mode == 'error'`)
408+
// We need to always run `cb` (e.g. in the case of `this.recordingMode == 'error'`)
409409
const cbResult = cb?.();
410410

411411
// If this option is turned on then we will only want to call `flush`
412412
// explicitly
413-
if (this.mode === 'error') {
413+
if (this.recordingMode === 'error') {
414414
return;
415415
}
416416

@@ -447,7 +447,7 @@ export class ReplayContainer implements ReplayContainerInterface {
447447
// when an error occurs. Clear any state that happens before this current
448448
// checkout. This needs to happen before `addEvent()` which updates state
449449
// dependent on this reset.
450-
if (this.mode === 'error' && event.type === 2) {
450+
if (this.recordingMode === 'error' && event.type === 2) {
451451
this.setInitialState();
452452
}
453453

@@ -473,7 +473,7 @@ export class ReplayContainer implements ReplayContainerInterface {
473473

474474
// See note above re: session start needs to reflect the most recent
475475
// checkout.
476-
if (this.mode === 'error' && this.session && this._context.earliestEvent) {
476+
if (this.recordingMode === 'error' && this.session && this._context.earliestEvent) {
477477
this.session.started = this._context.earliestEvent;
478478
this._maybeSaveSession();
479479
}
@@ -746,10 +746,10 @@ export class ReplayContainer implements ReplayContainerInterface {
746746
}
747747

748748
/**
749-
* Only flush if `this.mode === 'session'`
749+
* Only flush if `this.recordingMode === 'session'`
750750
*/
751751
conditionalFlush(): void {
752-
if (this.mode === 'error') {
752+
if (this.recordingMode === 'error') {
753753
return;
754754
}
755755

packages/replay/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export interface ReplayContainer {
217217
eventBuffer: EventBuffer | null;
218218
performanceEvents: AllPerformanceEntry[];
219219
session: Session | undefined;
220-
mode: ReplayRecordingMode;
220+
recordingMode: ReplayRecordingMode;
221221
isEnabled(): boolean;
222222
isPaused(): boolean;
223223
getContext(): InternalEventContext;

packages/replay/test/unit/index-handleGlobalEvent.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ it('only tags errors with replay id, adds trace and error id to context for erro
8383
jest.runAllTimers();
8484
await new Promise(process.nextTick); // wait for flush
8585

86-
// Rerverts `mode` to session
87-
expect(replay.mode).toBe('session');
86+
// Rerverts `recordingMode` to session
87+
expect(replay.recordingMode).toBe('session');
8888
});
8989

9090
it('strips out dropped events from errorIds', async () => {

0 commit comments

Comments
 (0)