You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was some discussion about this previously with #80 (comment) and with #941 - though in both cases that's requiring a lot of work on the implementer's part.
Just to add, this is also about capturing user feedback - not just consent. We already have a clear path for capturing feedback in a web app (via the browser SDK, as in our MVC sample app), but we don't have anything similar that would work for a desktop app.
Updated priority of this. Though it's generally ok if such things are not synchronized, as priority is rather flexible and is relative to other items on each repo.
Is there any progress on this? This is something we require to allow users to read our EULA in our MAUI app before any events / sessions are uploaded.
Currently, most workarounds are unsatisfactory (i.e. having BeforeSend always return null until the user accepts, but this still seems to send crashes / ANRs).
What we have found is that initialising the SDK with string.Empry as the DSN will prevent events from being uploaded, and then when the user accepts we Initialise() the SDK with the DSN to allow events to be uploaded. This seems to work but feels.... hacky... and we loose any telemetry that was captured while the SDK was disabled.
What we have found is that initialising the SDK with string.Empry as the DSN will prevent events from being uploaded, and then when the user accepts we Initialise() the SDK with the DSN to allow events to be uploaded.
The only alternative I can think of is adding something to the options like SentryOptions.RequireUserConsent... and until SentrySdk.GrantUserConsent() is called, the SDK just discards any events or telemetry it would otherwise have sent.
The end result would be the same behaviour that you have now though.
we loose any telemetry that was captured while the SDK was disabled
That may be the safest thing to do even for a deliberate design. It means you don't capture any data before users give their explicit consent and also avoids a data spike in traffic to Sentry.
@jamescrosswell thanks for that. I do disagree on one thing though:
That may be the safest thing to do even for a deliberate design.
This means you'd lose any telemetry from before the user granted consent. We've actually had an issue in the past where the screen where the user could accept our EULA could cause a crash if the user interacted with it in a certain way. With this suggestion, you'd never receive telemetry for that.
What we are explicitly looking for is a way to keep the Sentry SDK initialised, but disable the uploading of the telemetry to the Sentry server. Once the user has accepted the EULA, the cached telemetry (capturing any issues before the EULA was accepted) would then be uploaded without issue. This falls inline with our EULA, since they must agree to it before we receive any telemetry, and also helps us capture any startup issues.
I think the best scenario would be keeping the current method of disable the Sentry SDK, and having an additional method or SentryOption to enable / disable the transport(?) without stopping the Sentry SDK from caching telemetry. That way if developers want to collect no telemetry, they can disable the SDK, and if others want to record telemetry and not upload it they can.
@NathanielJS1541 while not trivial, you could probably do what you want using the existing SDK. When initialising Sentry, it's possible to configure a custom Transport to be used to send data to Sentry. This uses a wrapper pattern (forwarding messages to the internal Transport). We have one such implementation, which is the CachingTransport:
Hypothetically then, you could create a transport which sent messages if the EULA had been accepted, queued them up if the EULA hadn't been accepted, and provided some thread safe mechanism for indicating whether the EULA had been accepted or not.
All of that should be done with caution... if too many events are queued up and all released at once, it will trigger the spike protection and as bunch of these will be discarded by Sentry/Relay.
Activity
mattjohnsonpint commentedon Apr 27, 2022
There was some discussion about this previously with #80 (comment) and with #941 - though in both cases that's requiring a lot of work on the implementer's part.
bruno-garcia commentedon Apr 27, 2022
https://www.notion.so/sentry/User-Consent-Requirements-ba63b834cfe24501866ba2957a9e7184
mattjohnsonpint commentedon May 26, 2022
Just to add, this is also about capturing user feedback - not just consent. We already have a clear path for capturing feedback in a web app (via the browser SDK, as in our MVC sample app), but we don't have anything similar that would work for a desktop app.
vaind commentedon Oct 25, 2022
FYI this is a P1 in https://github.com/getsentry/team-mobile/issues/24 while being a P2 here
mattjohnsonpint commentedon Mar 30, 2023
Updated priority of this. Though it's generally ok if such things are not synchronized, as priority is rather flexible and is relative to other items on each repo.
mattjohnsonpint commentedon Jun 5, 2023
Need to investigate and validate approach before we can continue.
3 remaining items
NathanielJS1541 commentedon May 12, 2025
Is there any progress on this? This is something we require to allow users to read our EULA in our MAUI app before any events / sessions are uploaded.
Currently, most workarounds are unsatisfactory (i.e. having
BeforeSendalways returnnulluntil the user accepts, but this still seems to send crashes / ANRs).What we have found is that initialising the SDK with
string.Empryas the DSN will prevent events from being uploaded, and then when the user accepts weInitialise()the SDK with the DSN to allow events to be uploaded. This seems to work but feels.... hacky... and we loose any telemetry that was captured while the SDK was disabled.jamescrosswell commentedon May 12, 2025
@NathanielJS1541 that seems like a good solution.
The only alternative I can think of is adding something to the options like
SentryOptions.RequireUserConsent... and untilSentrySdk.GrantUserConsent()is called, the SDK just discards any events or telemetry it would otherwise have sent.The end result would be the same behaviour that you have now though.
That may be the safest thing to do even for a deliberate design. It means you don't capture any data before users give their explicit consent and also avoids a data spike in traffic to Sentry.
NathanielJS1541 commentedon May 17, 2025
@jamescrosswell thanks for that. I do disagree on one thing though:
This means you'd lose any telemetry from before the user granted consent. We've actually had an issue in the past where the screen where the user could accept our EULA could cause a crash if the user interacted with it in a certain way. With this suggestion, you'd never receive telemetry for that.
What we are explicitly looking for is a way to keep the Sentry SDK initialised, but disable the uploading of the telemetry to the Sentry server. Once the user has accepted the EULA, the cached telemetry (capturing any issues before the EULA was accepted) would then be uploaded without issue. This falls inline with our EULA, since they must agree to it before we receive any telemetry, and also helps us capture any startup issues.
I think the best scenario would be keeping the current method of disable the Sentry SDK, and having an additional method or
SentryOptionto enable / disable the transport(?) without stopping the Sentry SDK from caching telemetry. That way if developers want to collect no telemetry, they can disable the SDK, and if others want to record telemetry and not upload it they can.jamescrosswell commentedon May 19, 2025
@NathanielJS1541 while not trivial, you could probably do what you want using the existing SDK. When initialising Sentry, it's possible to configure a custom Transport to be used to send data to Sentry. This uses a wrapper pattern (forwarding messages to the internal Transport). We have one such implementation, which is the CachingTransport:
sentry-dotnet/src/Sentry/Internal/SdkComposer.cs
Lines 25 to 42 in f020492
Hypothetically then, you could create a transport which sent messages if the EULA had been accepted, queued them up if the EULA hadn't been accepted, and provided some thread safe mechanism for indicating whether the EULA had been accepted or not.
All of that should be done with caution... if too many events are queued up and all released at once, it will trigger the spike protection and as bunch of these will be discarded by Sentry/Relay.