-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Provide a way to programmatically filter replays #8462
Comments
this would help us reduce the barrier to enable session replay across the company |
Could you please share some of the use cases where you'd be filtering? This can help us design the hooks you'll need |
would be very helpful: filter by length of replay (don't save replays shorter than X, longer than X), |
Related to getsentry/sentry#53257 |
Sample Replays by duration
We recently added an option called
It's available on 7.60: https://github.com/getsentry/sentry-javascript/releases/tag/7.60.0
Sample Replays by other conditions
If you want to conditionally sample based on the user, you can set a different value depending on the user in question. Another alternative, is to not use these sample rates, and use the start and stop functions programatically. We document how to programatically start/stop recording, here: docs.sentry.io/platforms/javascript/session-replay/understanding-sessions/#manually-starting-replay We understand these are less convenient than having more options built-in to the SDK to control which sessions to sample. We'll keep this ticket open to collect my demand and use cases from folks. |
I'd like to present a use case that we have: We only want to enable session replays for certain pages in our app (we have a small team, and we're gradually upgrading an internal app to a SaaS). I'm having trouble working out how to do it even using the What I'd like to set up is to have it set to buffering in the event that it's a page we're not actively tracking, and start a full recording if it's a page we are. But I've run into a couple of walls with this approach:
|
Hey, thanks for your input! I'll try to help with your questions:
IMHO you can realise something like you want like this: function onPageEnter(url) {
const shouldFullyTrack = shouldTrackWithReplay(url); // check for which pages we care about
// just guard that replay is enabled - else, it was stopped from somewhere else and we just do nothing
if (shouldFullyTrack && replay.getReplayId()) {
replay.flush({ continueRecording: true });
// if already in session mode, this will simply flush and continue
}
} And generally just initialize replay as This way, replay will always be initialized in buffer mode, but you can manually force it to fully capture it when a user enters a given page. |
This adds a new option to `new Replay()` which allows to ignore certain errors for error-based sampling: ```js new Replay({ beforeErrorSampling: (event) => !event.message.includes('ignore me') }); ``` When returning `false` from this callback, the event will not trigger an error-based sampling. Note that returning `true` there does not mean this will 100% be sampled, but just that it will check the `replaysOnErrorSampleRate`. The purpose of this callback is to be able to ignore certain groups of errors from triggering an error-based replay at all. Closes #9413 Related to #8462 (not 100% but partially)
Hey! In 7.78.0, you can now configure a callback to replay to solve some further use cases. With new Replay({
beforeErrorSampling(event) {
return !event.message?.includes('no replay')';
}
}) This callback receives the fully processed error event. Returning false from this function means that error sampling will not happen for this error, returning true means that we will sample for this error to decide if a replay should be sent. |
Since this is resolved I'll close it. Feel free to reopen if somehow this doesn't resolve ur problem |
@bruno-garcia the latest update only covered errors, the OP (and my question too) was about regular replays too (like tracking only core pages in your app, etc). Given that, i think this is not quite resolved yet |
I see. To be fair I believe that use case is covered with the API we offer for starting/stopping the replay: You could have onError sample rate (and use the callback to filter depending on error). And additionally depending on a page you load or other condition, programatically starting a reply. We're probably not adding another callback I imagine correct @mydea @billyvg ? If so, should we close with the solution mentioned above? |
Any other callback would be tricky, because we can't really have e.g. |
Agreed.
Closing with this ^ It's unblocked since it can be achieved with the API but we won't add another hook given the clarifications/complexities @mydea mentioned |
Problem Statement
We'd like to have the ability to drop session replays based on dynamic characteristics like:
Solution Brainstorm
Something like a beforeSend for errors and a beforeTransactionSend for performance would be ideal.
┆Issue is synchronized with this Jira Improvement by Unito
The text was updated successfully, but these errors were encountered: