Skip to content

feat(native): consent-aware offline caching#1649

Open
jpnurmi wants to merge 4 commits intojpnurmi/feat/cache-consentfrom
jpnurmi/feat/native-cache-consent
Open

feat(native): consent-aware offline caching#1649
jpnurmi wants to merge 4 commits intojpnurmi/feat/cache-consentfrom
jpnurmi/feat/native-cache-consent

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented Apr 15, 2026

This PR implements consent-aware offline caching for the Native backend.

Pipe require_user_consent through the crash IPC shmem, load fresh persisted consent in the daemon at crash time, and route the crash envelope and run-folder envelopes through sentry__capture_envelope so the send/cache/discard policy is unified with the rest of the SDK.

sentry__capture_envelope takes the options explicitly so it can be called from the daemon, which has its own local options (no global). All in-process callers are updated.

Note: cache_max_size was bumped from 4 to 16 MB in the example because the native-backend's crash envelopes carry the full minidump and can exceed 4 MB (especially under ASAN). sentry__cleanup_cache then prunes the only entry on next startup, which was making test_native_cache_consent flaky.

See also:

#skip-changelog (in #1542)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

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

Generated by 🚫 dangerJS against 87f28e1

@jpnurmi jpnurmi force-pushed the jpnurmi/feat/cache-consent branch from 4dcc514 to a1bd38b Compare April 15, 2026 12:58
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/native-cache-consent branch from 1153f08 to 288e92a Compare April 15, 2026 12:59
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/native-cache-consent branch 2 times, most recently from 018814e to 699926f Compare April 15, 2026 20:08
@jpnurmi jpnurmi marked this pull request as ready for review April 16, 2026 10:16
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 699926f. Configure here.

Comment thread src/backends/native/sentry_crash_daemon.c Outdated
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/cache-consent branch from a1bd38b to 9c2a6df Compare April 16, 2026 12:03
jpnurmi and others added 3 commits April 16, 2026 14:05
Pipe require_user_consent through the crash IPC shmem, load fresh
persisted consent in the daemon at crash time, and route the crash
envelope and run-folder envelopes through sentry__capture_envelope so
the send/cache/discard policy is unified with the rest of the SDK. The
external crash reporter branch is left untouched.

sentry__capture_envelope takes the options explicitly so it can be
called from the daemon, which has its own local options (no global).
All in-process callers are updated.

Also extends test_native_consent_revoke with a second-run consent-give
step that flushes the cached envelope.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 MB was set back when envelopes were breakpad/crashpad-only and small.
Native-backend envelopes carry a full minidump in-envelope and can
exceed 4 MB (especially under ASAN, which loads extra libraries that
balloon the module list), causing cleanup_cache to prune even a single
entry that's bigger than the limit.

test_cache_max_size still exercises size pruning, just with 5x4 MB
envelopes against the 16 MB limit (expects <=4 survive).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
If the crash envelope failed to load, the cleanup path still dispatched
run-folder envelopes via sentry__capture_envelope with the run's default
SENTRY_USER_CONSENT_UNKNOWN, causing them to be cached or discarded even
when consent had been given.
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/native-cache-consent branch from cea6540 to ee0676c Compare April 16, 2026 12:05
Comment thread src/sentry_core.c Outdated
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.

1 participant