-
-
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
Support config change after Sentry.init #10929
Comments
Hello! The things you mentioned, can be updated by mutating the options on the client: getClient().getOptions().tracesSampleRate = 0.5; This is not super clean and there are some options where this may not work perfectly (e.g. when an integration needs the options at setup time), but for We may want to think about a more ergonomic way to do this, though 🤔 |
@mydea Thank you for your suggestions. This looks like it actually worked. I've assigned the following configs post init: |
@mydea I can confirm that for some reason setting the replay error sample rate as part of the replay integration config (post init), didn't work as expected. Way more replays are being recorded. Same for |
As @mydea already indicated, mutating the options after initialization can easily lead to unexpected behavior and is not suggested. You can also use a dynamic sample rate by adding a Maybe the @getsentry/replay team has a suggestion for this. Maybe also adding a sampling callback like the |
It (replays) should work if don't immediately include the replay integration and instead call |
@billyvg Thanks for the suggestion. We're not including the replay integration on init. I'm guessing its being triggered by default on init since the CDN link includes replays as well. Can I change that default behaviour? Or maybe I can opt out from replays on the CDN link and add Replays through the NPM one (feels messy...) |
@dcarabott Ah sorry, I missed that you're using CDN -- unfortunately I can't think of a clean way of doing this without accessing the internals of the integration We currently do have some unrelated work to be able to lazy load from the CDN, which may be helpful here. What kind of logic are you trying to do in your init in regards to the replay sample rate? |
@billyvg We're not doing much during the init process.
But post init we're setting some options and initialising the |
@dcarabott what are you doing post init (in regards to replay sampling rate), that you can't do in the init? |
@billyvg here's the integration part:
Some of the details are not available when triggering the INIT on the index.html file. Hence why integrations are triggered later on. |
@dcarabott If you're using the CDN, replay integration should not be loaded until you call
|
To add on to this, if you are using the Loader script with Replay enabled, there is no real way to do this right now. The Loader Script will automatically add the Replay integration for you if Replay is enabled, which will take the options at the time of If this is what you need, you'll probably need to switch to using the CDN manually and do - see https://docs.sentry.io/platforms/javascript/install/loader/#cdn. Then you can load the bundle including replay at the start of the page, manually call |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
I have similar issue in our nuxt app, which initializes sentry in plugins, but errors that happen before the hydration are missing. One idea was to initialize sentry in index.html head, but we need to pass some arguments like mentioned above, and they are not available when initializing in the head. For example |
We are currently working on a fully integrated nuxt SDK - see #9095. That may handle these things better out of the box! |
Problem Statement
Since
Sentry.init
is triggered on themain.ts
file for Angular, errors popping up before this file is initialised are lost. Say, a script failed for some reason and we never made it till themain.ts
, that error is never reported.One of the solutions would be to init Sentry on the index.html. This way every script error can be captured. BUT it might be the case that at the
index.html
stage, some configs are not yet available (Angular Environment variables for example).Example of configs that will be applied later:
tracesSampleRate
,denyUrls
,beforeSend
etcSolution Brainstorm
Supporting config change after init would be of great help.
main.ts
stageAnother solution is to allow re-init of Sentry.
The text was updated successfully, but these errors were encountered: