Skip to content

Anonymous crash reports and one export count with Sentry - #34

Merged
JarlLyng merged 3 commits into
mainfrom
sentry-anonymous
Nov 15, 2026
Merged

JarlLyng merged 3 commits into
mainfrom
sentry-anonymous

Conversation

@JarlLyng

@JarlLyng JarlLyng commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

What & why

Anonymous crash reports, app hangs, crash-free sessions, MetricKit diagnostics and one feature count go to Sentry, under the portfolio's anonymous recipe. Refs #33. That issue closes once a release build has been checked in Sentry.

This needs your explicit OK before merge. It touches:

  • the entitlements (network access),
  • the build scripts (ci_scripts/),
  • a package pin.

For 1.2.0. The site and policy copy is in a separate PR, #33's site half, which merges on the day this ships.

What changed

  • sentry-cocoa 9.32.0, pinned exactly in App/project.yml, and verified against the tag's commit. It is the newest release that is more than two weeks old, and the one WODrounds' envelope check used. It is pinned because the anonymous sessions depend on how this version stores its installation ID.
  • App/Patternaut/Telemetry.swift:
    • Shared user: anonymous, set right after SentrySDK.start and again on every event in beforeSend.
    • beforeSend drops: contexts.app.device_app_hash, contexts.device.id and server_name.
    • Paths: stack frames and debug images lose the account name (/Users/~/…). Paths in exception and event messages become <path>.
    • No breadcrumbs at all. On the Mac they can carry window titles, which name documents. Network breadcrumbs and failed-request capture are off too.
    • Sessions on, without an ID: the INSTALLATION file is pinned to anonymous before the SDK starts, the same technique as WODrounds #227.
    • Off: sendDefaultPii, performance tracing and file I/O tracing. The Mac SDK has no screenshots or view hierarchy.
    • On: MetricKit.
  • One count, project.exported:
    • fired after a successful export;
    • one attribute, device (tracker_plus / tracker_mini);
    • beforeSendMetric keeps an allowlist and drops the rest, user.id included.
    • The issue proposed the export format as the attribute. Patternaut writes one format only, so the Tracker model says more.
  • What may be sent is unit-tested. It lives in PatternautCore/.../TelemetryRules.swift: the allowlist, the fixed device values and both path rules.
  • Environment:
    • debug for builds from Xcode.
    • In release builds StoreKit's AppTransaction decides: production for the App Store, testflight for TestFlight. On the Mac a receipt can't tell the two apart.
    • Until StoreKit answers, events say release, and sessions from release builds say release too. That is noted in App/SENTRY.md.
  • Network: com.apple.security.network.client added to the entitlements, used by Sentry only.
  • DSN, kept out of git:
    • It lives in App/Sentry.xcconfig (gitignored), included optionally from the new App/Config.xcconfig, and reaches the app through Info.plist SentryDSN.
    • ci_scripts/ci_pre_xcodebuild.sh writes it from SENTRY_DSN, escaped as https:/$()/…. In an xcconfig, // starts a comment, so a plain https://… leaves only https:. I checked this with xcodebuild -showBuildSettings.
    • An archive without a DSN that looks like one fails with an error that names the fix. Plain builds and tests still run.
    • The app also refuses a truncated https: DSN.
    • A build phase checks the value the build actually resolved. "Check the Sentry DSN for archives" stops any archive (ACTION=install) whose resolved SENTRY_DSN isn't http(s)://…@…/…, which covers hand-written xcconfigs and local archives too. Tested with xcodebuild install:
      • no xcconfig fails;
      • a plain https:// fails (it resolves to https:);
      • the escaped form passes, and Info.plist gets https://….
  • dSYMs: the new ci_scripts/ci_post_xcodebuild.sh uploads the archive's dSYMs with sentry-cli 3.8.2. The download is checked against the SHA-256 GitHub publishes, which I verified. It needs SENTRY_AUTH_TOKEN; without it, it warns and the build goes on.
  • App/Patternaut/PrivacyInfo.xcprivacy:
    • Crash Data, Performance Data and Other Diagnostic Data (App Functionality), and Product Interaction (Analytics), all not linked and not tracking. Other Diagnostic Data follows the portfolio standard, which matches sentry-cocoa's own manifest;
    • plus the UserDefaults reason CA92.1 the app already needed.
  • Docs: README (a Privacy section), AGENTS, SECURITY, CONTRIBUTING, CHANGELOG, and App/SENTRY.md (what's sent, the DSN, dSYMs, and the envelope check).

Envelope test (Debug build, local stand-in for Sentry)

I ran a Debug build against a local HTTP server that saved every envelope, with the probe on (PATTERNAUT_SENTRY_PROBE=1). The probe sends one event and two counts, and one count carries an extra project attribute. I ran it in the existing sandbox, and in a fresh one through a copy with another bundle ID, to see a first run.

16 envelopes came back: 7 events, 6 sessions and 3 metric batches. Results:

  • Every session did was anonymous, including the closing abnormal update after a restart.
  • Every event user was {"id": "anonymous"}.
  • device_app_hash, server_name and user.id appeared nowhere.
  • Breadcrumbs: 0.
  • The probe's project attribute was dropped.
  • No path under /Users/ appeared.

Two things I could not do:

  • Seeding a fake old installation ID. macOS's app-data protection stops a shell from writing into the app's sandbox. It matters less here, since no earlier version had Sentry, so every update starts without the file.
  • Excluding stray envelopes at the server. Another session's app briefly sent to the same port. Its envelopes, release com.iamjarl.its404yo, are excluded from the count above.

Also seen: a launch hang of about 2 seconds in Debug builds, in SwiftUI's first layout. That is the app itself, not Sentry, and exactly what these reports should surface.

The Debug and Release builds compile. swift test passes: 166 tests, with the new TelemetryRulesTests.

Your steps

  1. Xcode Cloud, before the 1.2.0 build: add two secrets to the workflow's environment:
    • SENTRY_DSN, from Sentry → Settings → Projects → patternaut → Client Keys;
    • SENTRY_AUTH_TOKEN, an organisation token that can upload debug files.
  2. Sentry: confirm the organisation's server-side scrubbing and that IP addresses aren't stored. The hub says both were set on 2026-11-15.
  3. On release day, the App Store label: change it from Data Not Collected to Data Not Linked to You:
    • Diagnostics: Crash Data, Performance Data, Other Diagnostic Data;
    • Usage Data: Product Interaction;
    • none of it used for tracking.
  4. On release day, merge the site PR, so the policy and the FAQ say the same.
  5. After the release: look at a new event, session and count in Sentry. Check that the user is anonymous, there is no device_app_hash and no path, and the environment is testflight or production.

Checklist

  • Builds and runs; existing tests pass (cd PatternautCore && swift test)
  • App project regenerated with xcodegen
  • New off-device data, anonymous and declared: entitlements, manifest, README, and the policy in the site PR
  • Docs / CHANGELOG updated

🤖 Generated with Claude Code

sentry-cocoa 9.32.0, pinned, under the portfolio's anonymous recipe:
one shared user, no device IDs, the installation ID pinned so sessions
carry none, no breadcrumbs, paths scrubbed, and one count, project.exported
with a device attribute. MetricKit on, tracing off. The environment is
debug, testflight or production, from StoreKit in release builds.

Network access (com.apple.security.network.client) is for Sentry only.
The DSN lives in a gitignored xcconfig that ci_pre_xcodebuild.sh writes,
and an archive without a usable one fails. ci_post_xcodebuild.sh uploads
dSYMs with a pinned, checksum-checked sentry-cli. PrivacyInfo.xcprivacy
declares crash, performance and product-interaction data, not linked.

Refs #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JarlLyng and others added 2 commits November 15, 2026 01:25
The CI script checks the environment variable; this checks the value the
build actually resolved after the xcconfig, so a hand-written xcconfig or
a local archive can't ship a truncated "https:" either. Tested with
xcodebuild install: no DSN and a plain https:// both fail, the escaped
form passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The portfolio standard now declares Other Diagnostic Data next to Crash
Data and Performance Data, as sentry-cocoa's own manifest does: not
linked, not tracking, App Functionality.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JarlLyng
JarlLyng merged commit ea537a3 into main Nov 15, 2026
2 checks passed
@JarlLyng
JarlLyng deleted the sentry-anonymous branch November 15, 2026 10:33
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