-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(replay): Expose
recordingMode
in public API (#14085)
- Loading branch information
Showing
3 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
packages/replay-internal/test/integration/recordingMode.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
|
||
import { describe, expect, test } from 'vitest'; | ||
import { resetSdkMock } from '../mocks/resetSdkMock'; | ||
import { useFakeTimers } from '../utils/use-fake-timers'; | ||
|
||
useFakeTimers(); | ||
|
||
describe('Integration | getRecordingMode()', () => { | ||
test('returns "session" when session sampling is enabled', async () => { | ||
const { integration } = await resetSdkMock({ | ||
replayOptions: { | ||
stickySession: false, | ||
}, | ||
sentryOptions: { | ||
replaysSessionSampleRate: 1.0, | ||
}, | ||
}); | ||
expect(integration.getRecordingMode()).toBe('session'); | ||
}); | ||
|
||
test('returns "buffer" when buffering is enabled', async () => { | ||
const { integration, replay } = await resetSdkMock({ | ||
replayOptions: { | ||
stickySession: false, | ||
}, | ||
sentryOptions: { | ||
replaysSessionSampleRate: 1.0, | ||
}, | ||
}); | ||
replay.stop(); | ||
replay.startBuffering(); | ||
expect(integration.getRecordingMode()).toBe('buffer'); | ||
}); | ||
|
||
test('returns undefined when replay is stopped', async () => { | ||
const { integration, replay } = await resetSdkMock({ | ||
replayOptions: { | ||
stickySession: false, | ||
}, | ||
sentryOptions: { | ||
replaysSessionSampleRate: 1.0, | ||
}, | ||
}); | ||
replay.stop(); | ||
expect(integration.getRecordingMode()).toBeUndefined(); | ||
}); | ||
|
||
test('returns undefined when session sampling is disabled', async () => { | ||
const { integration } = await resetSdkMock({ | ||
replayOptions: { stickySession: false }, | ||
sentryOptions: { | ||
replaysSessionSampleRate: 0.0, | ||
replaysOnErrorSampleRate: 0.0, | ||
}, | ||
}); | ||
expect(integration.getRecordingMode()).toBeUndefined(); | ||
}); | ||
|
||
test('returns "buffer" when session rate is 0 and onError rate is 1', async () => { | ||
const { integration } = await resetSdkMock({ | ||
replayOptions: { stickySession: false }, | ||
sentryOptions: { | ||
replaysSessionSampleRate: 0.0, | ||
replaysOnErrorSampleRate: 1.0, | ||
}, | ||
}); | ||
expect(integration.getRecordingMode()).toBe('buffer'); | ||
}); | ||
|
||
test('returns "session" when both sampling rates are 1', async () => { | ||
const { integration } = await resetSdkMock({ | ||
replayOptions: { stickySession: false }, | ||
sentryOptions: { | ||
replaysSessionSampleRate: 1.0, | ||
replaysOnErrorSampleRate: 1.0, | ||
}, | ||
}); | ||
expect(integration.getRecordingMode()).toBe('session'); | ||
}); | ||
}); |