-
-
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
Session Replay start() method do not work after stop() in some cases #7192
Comments
Hello, the way With your code, it would never actually start recording, because the sample rate of What you need to do to achieve what you want is something like this: const replay = new Replay();
Sentry.init({
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0,
integrations: [replay]
});
// No need to call `stop`, as it will never be started do to sample rate being 0
// later, when you want to start, do:
const options = client.getOptions();
options.replaysSessionSampleRate = 1.0; // <-- ensure any `start` will _always_ result in a sampled session
replay.start();
// now you can stop/start it again as you see fit. We may look into making this easier in the future - I opened an issue to track this here: #7193 |
in my case I set |
Hey @expcapitaldev, we currently do not really optimize/explicitly support this use case. Really, the only thing we properly support are the following three cases:
Stopping/starting the replay repeatedly may not work perfectly. Could you rewrite your app this way: Sentry.init({
dns: myDNS,
// set to 1 so once we add the integration, it will def. be sampled
replaysSessionSampleRate: 1,
replaysOnErrorSampleRate: 1,
integrations: []; // not added here
});
// enableReplay for example from variable from server
function toggleReplay(enableReplay){
const client: Client | undefined = Sentry.getCurrentHub().getClient();
if (!client) {
return;
}
if (enableReplay) {
const existingReplay = client.getIntegration(Replay);
if (existingReplay) {
return;
}
const replay = new Replay();
client.addIntegration(replay);
} else {
const replay = client.getIntegration(Replay);
replay?.stop();
}
} This would allow to start the replay later, and potentially stop it if needed. It would not allow re-starting the replay, but maybe that's good enough? |
going to move this to |
Hi @mydea, I'm setting up Replay integration for a project and found this issue because I'm confused why start is not working. The Session Replay documentation explicitly mentions "Manually calling the replay.start() method" as a method to start a recording. Based on the comments above this seems to not be correct? And to be clear, would following combination be possible currently or not?:
|
@jakub300 Yeah we will have to update the docs here, thanks. Can you explain your use-case for starting the recording manually? |
Hi, we're still exploring but possible use cases:
|
In your example, can' Client' be import { BrowserClient, Replay } from "@sentry/browser";
const client: BrowserClient | undefined = Sentry.getCurrentHub().getClient(); Additionally, the above example is working well. |
I had a similar setup to track a set of specific users. but my problem is that once the user become inactive(According to the doc it's 5mins of inactivity right?). Then even the user becomes active again. It won't restart the replay session. I'm curious if this is the expected behavior? if so how to reconfigure it such that the session restart? I'm happy with either it continues the original session or creating a new session. Thanks!! |
Yes, that should be correct,
The session should not be stopped when it becomes inactive, but paused. When activity resumes, the replay should also resume. Are you saying that for you a session is stopped when it becomes inactive for 5 minutes, and never restarted when it becomes active again? if so, could you open a new issue for this, as this would be unrelated to the start/stop topic here - this should not happen! |
This should now be possible by configuring the |
We made some fixes in 7.50.0 that should handle Closed by #7768 and released in |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g.
bundle.tracing.min.js
) in your SDK setup.@sentry/angular
SDK Version
7.37.1
Framework Version
"@sentry/angular": "7.37.1",
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
see above
Expected Result
after ReplayIntergation.stop() I can call .start() and new session should be started and send to the server
Actual Result
looks like after stop() new session can not started but I see new Worker created with new ID but POST requests do not send to the server in all
The text was updated successfully, but these errors were encountered: