Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: never send when not sampled #1706

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/__tests__/extensions/replay/sessionrecording.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2437,5 +2437,19 @@ describe('SessionRecording', () => {
// even though still waiting for URL to trigger
expect(sessionRecording['status']).toBe('active')
})

it('disables recording when sampling rate is 0 regardless of event triggers', async () => {
sessionRecording.onRemoteConfig(
makeDecideResponse({
sessionRecording: {
endpoint: '/s/',
eventTriggers: ['$exception'],
sampleRate: '0.00', // i.e. never send recording
},
})
)

expect(sessionRecording['status']).toBe('disabled')
})
})
})
6 changes: 6 additions & 0 deletions src/extensions/replay/sessionrecording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,12 @@ export class SessionRecording {
return 'disabled'
}

// if sampling is set and the session is already decided to not be sampled
// then we should never be active
if (this.isSampled === false) {
return 'disabled'
}

if (this._urlBlocked) {
return 'paused'
}
Expand Down
Loading