Skip to content

feat(cache): consent-aware offline caching#1542

Draft
jpnurmi wants to merge 2 commits intomasterfrom
jpnurmi/feat/cache-consent
Draft

feat(cache): consent-aware offline caching#1542
jpnurmi wants to merge 2 commits intomasterfrom
jpnurmi/feat/cache-consent

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented Feb 25, 2026

When a) user consent is revoked, and b) cache_keep is enabled, cache envelopes to <db>/cache/ instead of discarding them. The retry module picks them up when consent is later given, or they can be sent manually via sentry_transport_retry().

Also, moves user_consent to sentry_run_t to avoid passing raw long * pointers to worker threads. This PR would've added yet another instance. 😅 Later on, we could consider splitting the database-level state (consent, cache, external reports...) out of sentry_run that is supposed to manage the .run directory.

Close: #1521

@jpnurmi jpnurmi force-pushed the jpnurmi/feat/cache-consent branch 2 times, most recently from 680a83e to 24dc128 Compare February 26, 2026 09:42
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/http-retry branch from b133fd6 to 93db900 Compare March 17, 2026 16:15
Base automatically changed from jpnurmi/feat/http-retry to master March 31, 2026 19:23
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/cache-consent branch 2 times, most recently from 5781945 to 18d314f Compare April 8, 2026 18:58
When user consent is revoked, write envelopes to <database>/cache/
instead of discarding them, so they are picked up by the retry module
when consent is later given. Caching is conditional on the cache_keep
option being enabled.

- Modify sentry__capture_envelope() to cache instead of discard
- Guard sentry__capture_envelope() against NULL session_envelope
  in process_old_runs
- Add consent check to sentry__retry_send() via stored
  require_user_consent bool and db->user_consent atomic read

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/cache-consent branch from 7cd8780 to df20646 Compare April 8, 2026 19:04
Move require_user_consent and user_consent from sentry_options_t to
sentry_run_t as atomic longs. Add sentry__run_should_skip_upload()
helper that batcher and retry call directly through their refcounted
run pointer, replacing the fragile raw long* into options.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jpnurmi jpnurmi changed the title WIP: feat(cache): consent-aware event caching feat(cache): consent-aware offline caching Apr 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 7398628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for consent-aware event caching

1 participant