Allow Logs to be disabled during runtime
Problem Statement
This is simple, at least from the developer POV: I want to add an option in my app's Settings screen that allow the user to enable/disable full logging behavior. This would require a way to toggle enableLogs on/off, but right now that's not possible.
Solution Brainstorm
The Docs AI even told me to try to write to that property, in the React SDK, via getOptions().enableLogs, but that just caused erratic behavior 🤷♂️
Right now, I solved this with a global variable checked in beforeSendLog, but running a function over and over again to check a simple boolean seems quite suboptimal, when there are other runtime functions in the SDK — such as changing user details, etc.
I'm not submitting this to the React SDK, even though it's my current target, as I can see this being useful in most platforms.
Also, it looks like there's not yet a
Product Area: Logs? 😅
Product Area
Other
Assigning to @getsentry/support for routing ⏲️
Do you want to also skip capturing errors, spans, user feedback (and other stuff the sdk collects?)
If so, you can conditionally init the SDK based on user permission, and then call Sentry.close() to disable the SDK. Once you've disabled the SDK though, you can't re-enable it.
The Docs AI even told me to try to write to that property, in the React SDK, via getOptions().enableLogs, but that just caused erratic behavior
This should work as long as you only have a single client. What was the erratic behaviour you were seeing?
Routing to @getsentry/product-owners-explore for triage ⏲️
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 Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
This should work as long as you only have a single client. What was the erratic behaviour you were seeing?
It didn't seem to work properly, although the logs page isn't as instant as it seems, so I may have gotten confused.
Nonetheless, considering it's not documented explicitly, and... using an object created on the fly via a get method + setting a property on it doesn't seem the most common API around. I get that JS nowadays have magic setters which can implement more logic than simply flipping a property, but it's confusing, at the very least.
If that's really the way, this could be documented as such, at least.