Skip to content

Commit

Permalink
fix: never send when not sampled
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Jan 30, 2025
1 parent 65da573 commit 2897634
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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('ANDS with Sampling', 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

0 comments on commit 2897634

Please sign in to comment.