Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow postponing event captures until User Consent is collected #6758

Open
bruno-garcia opened this issue Jan 12, 2023 · 9 comments · May be fixed by #15937
Open

Allow postponing event captures until User Consent is collected #6758

bruno-garcia opened this issue Jan 12, 2023 · 9 comments · May be fixed by #15937
Assignees
Labels
Package: core Issues related to the Sentry Core SDK Type: Improvement

Comments

@bruno-garcia
Copy link
Member

bruno-garcia commented Jan 12, 2023

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 bruno-garcia changed the title Allow postponing event captures until _User Consent_ is collected Allow postponing event captures until User Consent is collected Jan 12, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2023
@bruno-garcia
Copy link
Member Author

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

@AbhiPrasad
Copy link
Member

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!

@AbhiPrasad AbhiPrasad reopened this Mar 31, 2023
@getsentry getsentry deleted a comment from github-actions bot Mar 31, 2023
@AbhiPrasad AbhiPrasad added Package: core Issues related to the Sentry Core SDK Status: Backlog and removed Status: Stale labels Mar 31, 2023
@zemlanin
Copy link

zemlanin commented Jul 8, 2024

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?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jul 8, 2024
@lforst
Copy link
Member

lforst commented Jul 8, 2024

@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
Copy link
Collaborator

timfish commented Oct 31, 2024

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

@linear linear bot added the Migrated label Jan 9, 2025
@dervondenbergen
Copy link

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

@timfish What kind of offline transport hooks do you mean? I tried to find them in the docs but wasn't able to.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 30, 2025
@timfish
Copy link
Collaborator

timfish commented Jan 30, 2025

Sorry, I was mistaken. I just checked the docs and it looks like the browser offline transport doesn't support the hooks required to delay sending events. It only has a shouldStore callback.

The Electron offline transport has an additional shouldSend callback which can be used to delay/stop sending. We need to look into adding that to the base makeOfflineTransport code.

@dervondenbergen
Copy link

@timfish No problem, I tried to read through the Electron offline transport code but can't figure out, wether/where the stored envelopes get flushed.

Or does a falsy shouldSend simply store the envelopes away and they get never send to Sentry as soon as shouldSend ist truthy again 🤔

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 1, 2025
@timfish
Copy link
Collaborator

timfish commented Feb 3, 2025

They get stored until another envelope is sent and shouldSend returns true. Once one envelope is sent successfully the rest are attempted.

There is also an option to attempt flushing shortly after startup.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Package: core Issues related to the Sentry Core SDK Type: Improvement
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

9 participants