Skip to content

User Consent support #1603

Open
Open

Description

@mattjohnsonpint

Problem Statement

It should be easier to create a "User Consent" workflow, where events are only sent to Sentry after a user approves the specific events.

Solution Brainstorm

This would be similar to getsentry/sentry-java#1988 and getsentry/sentry-cocoa#1780

Activity

  1. mattjohnsonpint commented on Apr 27, 2022

    @mattjohnsonpint
    ContributorAuthor

    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.

  2. mattjohnsonpint commented on May 26, 2022

    @mattjohnsonpint
    ContributorAuthor

    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.

  3. vaind commented on Oct 25, 2022

    @vaind
    Contributor
  4. mattjohnsonpint commented on Mar 30, 2023

    @mattjohnsonpint
    ContributorAuthor

    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.

  5. mattjohnsonpint commented on Jun 5, 2023

    @mattjohnsonpint
    ContributorAuthor

    Need to investigate and validate approach before we can continue.

  6. removed their assignment
    on Jun 20, 2023
  7. 3 remaining items

  8. NathanielJS1541 commented on May 12, 2025

    @NathanielJS1541

    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.

  9. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on May 12, 2025
  10. jamescrosswell commented on May 12, 2025

    @jamescrosswell
    Collaborator

    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.

    @NathanielJS1541 that seems like a good solution.

    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.

  11. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 12, 2025
  12. NathanielJS1541 commented on May 17, 2025

    @NathanielJS1541

    @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.

  13. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on May 17, 2025
  14. jamescrosswell commented on May 19, 2025

    @jamescrosswell
    Collaborator

    @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:

    // Start from either the transport given on options, or create a new HTTP transport.
    var transport = _options.Transport ?? new LazyHttpTransport(_options);
    // When a cache directory path is given, wrap the transport in a caching transport.
    if (!string.IsNullOrWhiteSpace(_options.CacheDirectoryPath))
    {
    _options.LogDebug("Cache directory path is specified.");
    if (_options.DisableFileWrite)
    {
    _options.LogInfo("File write has been disabled via the options. Skipping caching transport creation.");
    }
    else
    {
    _options.LogDebug("File writing is enabled, wrapping transport in caching transport.");
    transport = CachingTransport.Create(transport, _options);
    }
    }

    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.

  15. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 19, 2025
  16. removed theissue type on Aug 6, 2025
  17. added
    .NET
    on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETFeature

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions