Skip to content

fix(app): stop copying the device model dump into analytics payloads - #14388

Merged
Git-on-my-level merged 2 commits into
mainfrom
task/msd-product-device-identity-pii
Sep 17, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
task/msd-product-device-identity-pii

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

What changed and why

This is a live production exposure being closed. Mobile Device Connected and Device Paired were spreading BtDevice.toJson() onto PostHog, so raw wearable device id, name, and serial number (plus rssi, locator, modelNumber, firmwareRevision, hardwareRevision, manufacturerName) were reaching analytics on those two events, sitting next to hashed identity fields that already existed. Both emit sites now send only named fields.

Product invariants affected

none

How it was verified

  • Before the fix, flutter test test/utils/analytics/device_identity_analytics_test.dart failed on Device Connected and Device Paired: payload keys included name, id, rssi, locator, modelNumber, firmwareRevision, hardwareRevision, manufacturerName, serialNumber.
  • After the fix, the same file plus test/providers/device_provider_test.dart passed (22 tests).
  • TZ=UTC bash app/test.sh → +2096 All tests passed! on the payload change; re-run after adding the failure-class JSON.
  • dart format --line-length 120 on the Dart we touched.
  • scripts/failure-class prepare after adding the JSON, then make preflight.
  • Did not query PostHog or any production host; the emit site is the evidence.
  • Sibling search: those two Dart spreads were the only wholesale ...model.toJson() analytics emits in app/backend/desktop. macOS Device Connected already names device_vendor / device_type. Backend emit_product_event call sites use named maps. Memory Created still reads getTranscript() for length/word/speaker counts; that is a separate follow-up, not this PR.

Named fields kept, so a dashboard does not silently lose a column the dictionary already specified:

  • type — closed enum name; the one toJson key the event dictionary already lists.
  • device_vendor, hardware_family — closed analysis fields; also person properties used for vendor/family segmentation.
  • transport_device_id, transport_id_kind, transport_id_stability — hashed BLE (or vendor) identity; the join key that already replaced raw id.
  • hardware_id, hardware_id_kind, hardware_id_stable — hashed manufacturer serial when present; the join key that already replaced raw serialNumber.

Dropped with the spread: id, name, serialNumber, rssi, locator, modelNumber, firmwareRevision, hardwareRevision, manufacturerName. Firmware and model remain on Device Session Ended as firmware_revision / model. Did not add F1 events.

Tests

app/test/utils/analytics/device_identity_analytics_test.dart asserts emitted payload keys against BtDevice.toJson().keys, allowing only type as a shared spelling. A synthetic spread still fails that guard, so reintroducing ...device.toJson() fails without pinning today's event key list.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative (only when needed)

New class FC-analytics-payload-copies-model-dump. The violated contract is the spread of a model's serialized form into an analytics payload, not today's leaked field list. Closest existing misses, not reused: FC-public-projection-is-denylist-shaped (public HTTP share-link projection), FC-secret-printed-to-plugin-logs (plugin stdout), FC-identity-fallback-used-as-authorization-gate (suite admitted as the release). evidence_prs is [] because this PR is the first instance. Guard artifact is the payload-key test; scope hint is app/lib/utils/analytics/** (fnmatch glob).

New guards (only when adding a check or ratchet)

The Dart payload-key test is the regression that would have caught this leak (Device Connected / Device Paired spreading BtDevice.toJson() in production). It is not a shared static primitive because the class is "don't copy the model dump onto an event", which a source-text grep misses the moment the spread is aliased or built through a helper.

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 2 commits September 18, 2026 02:11
Device Connected and Device Paired were spreading BtDevice.toJson()
onto PostHog beside the hashed fields. Name the payload explicitly.

Failure-Class: new
Co-authored-by: Cursor <[email protected]>
Register the analytics model-dump class for the Device Connected/Paired
spread. The defect is copying a serialized model onto an event payload.

Failure-Class: new
Co-authored-by: Cursor <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 9615c43 into main Sep 17, 2026
42 checks passed
@Git-on-my-level
Git-on-my-level deleted the task/msd-product-device-identity-pii branch September 17, 2026 21:03
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
Bring in #14408 (AGENTS.md budget), #14388 (device identity), and
#14392 (Memory Created). Spine conflicts take main; analytics_manager
keeps both the C7 emit seam and main's newer payload contracts.

Co-authored-by: Cursor <[email protected]>
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