Skip to content

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

Open
jpnurmi wants to merge 7 commits intomasterfrom
jpnurmi/feat/cache-consent
Open

feat(cache): consent-aware offline caching#1542
jpnurmi wants to merge 7 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 3 times, most recently from 7cd8780 to df20646 Compare April 8, 2026 19:04
@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 233e06d

jpnurmi and others added 2 commits April 10, 2026 11:27
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>
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 force-pushed the jpnurmi/feat/cache-consent branch from 7398628 to 7118dbc Compare April 10, 2026 09:45
@jpnurmi jpnurmi marked this pull request as ready for review April 10, 2026 11:01
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8c7ca45. Configure here.

jpnurmi and others added 3 commits April 10, 2026 14:31
Return non-zero from sentry__retry_send() while consent is revoked so
the poll task keeps rescheduling and picks up cached envelopes once
consent is later given.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Trigger sentry_transport_retry() in set_user_consent() so envelopes
cached while consent was revoked are flushed immediately instead of
waiting for the next retry poll. Document the cache-consent
interaction in the public API headers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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