getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.99k stars 1.57k forks source link

Allow postponing event captures until User Consent is collected #6758

Open bruno-garcia opened 1 year ago

bruno-garcia commented 1 year ago

Have the SDK operate ‘properly’, with it's configured features such as Replay. But ‘hold off’ on sending events until consent is given. If revoked stop events from being sent again.

Sentry Native already supports user consent (not for all backends though), we can borrow the idea and do something similar getsentry/sentry-native@a51ccbb/src/sentry_options.c#L276-L286

Relates to:

Specifically:

There's an internal doc that should be moved to GitHub.

bruno-garcia commented 1 year ago

@AbhiPrasad any notes on why we decided not to go ahead with this?

AbhiPrasad commented 1 year ago

Nope, I think it just fell through the cracks. I moved it to Archived since it was a stale-bot closed issue. We can re-open and backlog!

zemlanin commented 4 months ago

Hi. What is expected way of handling user consent until this issue is resolved?

Add <script>/call Sentry.init only after user has agreed to gathering analytics? Something else?

lforst commented 4 months ago

@zemlanin Calling Sentry.init() only when consent was given is one way to do it. Another would be to delay events in the transport, that way you would not lose events that happened before the user gave consent. But that is a bit more involved.

timfish commented 1 week ago

The offline transports have hooks that can allow you to queue events until user consent.