Repository navigation
feat(telemetry): close mobile lifecycle and device gaps - #11539
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
All reported issues were addressed across 21 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
kodjima33
left a comment
There was a problem hiding this comment.
Re-approving on the new head; telemetry instrumentation, conflicts need resolving before merge.
kodjima33
left a comment
There was a problem hiding this comment.
Re-approved on the new head: telemetry coverage for mobile lifecycle/device gaps. Feature scope, so approve-only.
kodjima33
left a comment
There was a problem hiding this comment.
Mobile telemetry additions (account/firmware/subscription events), bounded properties, CI green. Feature not bug fix, so approve-only per confidence gate; also DIRTY so not merge-eligible regardless.
kodjima33
left a comment
There was a problem hiding this comment.
Feature (mobile telemetry) — approve-only per policy, not a bug fix. CI green at this sha.
Package metadata enrichment now shares the analytics initialization timeout so a missing or unresponsive platform plugin cannot block event delivery. Adds a regression test for the hanging method-channel path and initializes package metadata in the permissions analytics widget test.\n\nVerification:\n- flutter test test/unit/analytics_manager_package_info_timeout_test.dart test/widgets/permissions_interstitial_analytics_test.dart test/unit/analytics_manager_fail_open_test.dart --reporter expanded\n\nFailure-Class: none
Focused Flutter tests pass for capture telemetry, device analytics, device families, and DAT DFU guards. Failure-Class: none
Failure-Class: none
Main removed docs/analytics/events.md from docs.omi.me. Preserve 11539's mobile telemetry dictionary in web/admin/docs/posthog-events.md, and update test overrides for main's geolocation and clientConversationId signatures. Co-authored-by: Cursor <[email protected]>
ec3628a to
721624b
Compare
…io NSException (#12656) ## What changed and why Two independent production reliability fixes. **Mobile — false `Recording Start Failed` telemetry.** The `Recording Start Failed` / `Recording Started` events shipped 2026-08-31 in #11539. On 2026-09-02 PostHog showed 247 `Recording Start Failed` events (93 users, all `failure_class=capture_unavailable`) against 157 `Recording Started` (58 users). Failures outnumbering starts is impossible for a real failure rate. Cause: `streamDeviceRecording` called `_recordingTelemetry.prepare(...)` unconditionally, then emitted `capture_unavailable` whenever the start did not reach `deviceRecord`. HomePage calls this with `device == null` on every entry as a check-only path, so every home-page entry with no pendant connected was counted as a failed start. A no-device / check-only call now skips `prepare()` and does not emit start-failed. A real device start (a device was passed, or a recording device is already set) that does not reach `deviceRecord` still emits `capture_unavailable`. **macOS — onboarding sound engine crash.** Sentry `OMI-DESKTOP-4EK`, title `com.apple.coreaudio.avfaudio: player did not see an IO cycle.`, level fatal, `mechanism=nsexception`, `handled=no`. 25 distinct users since 2026-08-24; 8 of them on 2026-09-02 while the flag-driven onboarding rerun (#12597) pushed ~218 dormant users back through onboarding. This is the only `AVAudioPlayerNode` usage in the onboarding path. `AVAudioPlayerNode.play()` raises that NSException when the engine is not running or has not completed an IO cycle. Every `scheduleBuffer`/`play()` now re-checks `engine.isRunning` on the audio queue, is wrapped in the existing `ObjCExceptionCatcher`, and a caught exception logs once then sets `isSilenced` so onboarding continues without retrying in a loop. `rebuildAfterConfigurationChange` does not play until the rebuilt engine is running. ## Product invariants affected none ## How it was verified ### Mobile ``` cd app flutter analyze lib/services/capture/capture_controller.dart lib/providers/capture_provider.dart ``` No issues found! (ran in 32.2s) ``` cd app flutter analyze lib/services/capture/capture_controller.dart lib/providers/capture_provider.dart test/unit/recording_lifecycle_telemetry_test.dart test/providers/capture_provider_test.dart ``` 3 pre-existing infos in `capture_provider_test.dart` (`depend_on_referenced_packages`, two `no_leading_underscores_for_local_identifiers`); 0 issues in the production files. ``` cd app flutter test test/unit/recording_lifecycle_telemetry_test.dart test/providers/capture_provider_test.dart ``` All 93 tests passed. ### macOS ``` cd desktop/macos python3 scripts/dev-feedback.py --once swift 'OmiOnboardingSoundTests' ``` `OmiOnboardingSoundTests`: 17 tests, 0 failures. Iteration 1: PASS. ``` cd desktop/macos python3 scripts/check_desktop_test_quality.py ./scripts/swiftlint-wrapper.sh lint ``` `check_desktop_test_quality.py`: OK (debt at or below baseline). SwiftLint: 0 violations, 0 serious in 3052 files. Did not exercise the onboarding cinematic in a named bundle: the crash is an ObjC exception from `AVAudioPlayerNode.play()` when the engine has no IO cycle, which the unit tests cannot drive. The decision guard is covered by `OmiAVSoundPlayback.mayPlay`. ## Tests - `app/test/unit/recording_lifecycle_telemetry_test.dart`: `failStart` without `prepare` emits nothing; a prepared device start still emits `capture_unavailable`. - `app/test/providers/capture_provider_test.dart`: homepage no-device `streamDeviceRecording` emits no events; a requested device that cannot reach `deviceRecord` emits `capture_unavailable`. - `desktop/macos/Desktop/Tests/OmiOnboardingSoundTests.swift`: `mayPlay` is false when the engine is not running or the output is silenced. ## Failure class (fixes) Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12656?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…n onLocalDevSignIn Since BasedHardware#11539 landed, _signIn requires `credential` (UserCredential) and `authProvider` (String) as named required parameters. The onLocalDevSignIn call site was left with the old zero-extra-args form, causing MISSING_REQUIRED_ARGUMENT compile errors. The credential is already in scope — it is the UserCredential? returned by AuthService.instance.signInWithLocalDevToken() and is already null-checked before the call. Pass it directly with authProvider: 'local_dev'. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5TqoWB9unzNKthnD1pJUP
…n onLocalDevSignIn Since BasedHardware#11539 landed, _signIn requires `credential` (UserCredential) and `authProvider` (String) as named required parameters. The onLocalDevSignIn call site was left with the old zero-extra-args form, causing MISSING_REQUIRED_ARGUMENT compile errors. The credential is already in scope — it is the UserCredential? returned by AuthService.instance.signInWithLocalDevToken() and is already null-checked before the call. Pass it directly with authProvider: 'local_dev'. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5TqoWB9unzNKthnD1pJUP
…alytics events Cross-platform churn analysis (mobile churn baseline, 2026-09-25) could not segment mobile events: desktop sets a per-event 'platform' property (macos/windows) while mobile sent only 'app_platform', so every mobile event showed platform=(missing) in PostHog. Mobile now sends both 'platform' and 'app_platform' (ios/android) as global event properties, and every event carries a 'trigger' classification (user | background | system): default user, a name-based map tags the known background/telemetry emitters (background resource sessions, telemetry health, startup timing, update checks, notification system events, auth/fallback telemetry), and an explicit 'trigger' in the event properties wins as an emit-site escape hatch. Retention analysis must exclude non-user-initiated events when measuring return - background refresh keeps telemetry warm exactly like launch-at-login keeps App Launched warm on desktop (churn decision log 2026-08-30). Tests updated/added in analytics_manager_fail_open_test including a pin that Account Created carries platform and trigger=user (mobile Account Created exists only since 2026-08-31, commit fdb45db BasedHardware#11539 - instrumentation timing, not a volume change). Verification note: dart-format hook skipped via OMI_SKIP_DART_FORMAT (no Flutter/Dart SDK on this machine); edits mirror existing style at 120 cols. Flutter unit tests must be confirmed by CI.
…alytics events Cross-platform churn analysis (mobile churn baseline, 2026-09-25) could not segment mobile events: desktop sets a per-event 'platform' property (macos/windows) while mobile sent only 'app_platform', so every mobile event showed platform=(missing) in PostHog. Mobile now sends both 'platform' and 'app_platform' (ios/android) as global event properties, and every event carries a 'trigger' classification (user | background | system): default user, a name-based map tags the known background/telemetry emitters (background resource sessions, telemetry health, startup timing, update checks, notification system events, auth/fallback telemetry), and an explicit 'trigger' in the event properties wins as an emit-site escape hatch. Retention analysis must exclude non-user-initiated events when measuring return - background refresh keeps telemetry warm exactly like launch-at-login keeps App Launched warm on desktop (churn decision log 2026-08-30). Tests updated/added in analytics_manager_fail_open_test including a pin that Account Created carries platform and trigger=user (mobile Account Created exists only since 2026-08-31, commit fdb45db BasedHardware#11539 - instrumentation timing, not a volume change). Verification note: dart-format hook skipped via OMI_SKIP_DART_FORMAT (no Flutter/Dart SDK on this machine); edits mirror existing style at 120 cols. Flutter unit tests must be confirmed by CI.
…operties and Push Token Status events (#18883) * feat(analytics): add platform and trigger properties to all mobile analytics events Cross-platform churn analysis (mobile churn baseline, 2026-09-25) could not segment mobile events: desktop sets a per-event 'platform' property (macos/windows) while mobile sent only 'app_platform', so every mobile event showed platform=(missing) in PostHog. Mobile now sends both 'platform' and 'app_platform' (ios/android) as global event properties, and every event carries a 'trigger' classification (user | background | system): default user, a name-based map tags the known background/telemetry emitters (background resource sessions, telemetry health, startup timing, update checks, notification system events, auth/fallback telemetry), and an explicit 'trigger' in the event properties wins as an emit-site escape hatch. Retention analysis must exclude non-user-initiated events when measuring return - background refresh keeps telemetry warm exactly like launch-at-login keeps App Launched warm on desktop (churn decision log 2026-08-30). Tests updated/added in analytics_manager_fail_open_test including a pin that Account Created carries platform and trigger=user (mobile Account Created exists only since 2026-08-31, commit fdb45db #11539 - instrumentation timing, not a volume change). Verification note: dart-format hook skipped via OMI_SKIP_DART_FORMAT (no Flutter/Dart SDK on this machine); edits mirror existing style at 120 cols. Flutter unit tests must be confirmed by CI. * feat(analytics): emit Push Token Status PostHog events on token register and invalidate EXP-002 (day-3 re-engagement push) eligibility needs 'user has a deliverable push token as of a date'. Firestore stays the eligibility source of truth; PostHog now gets the analytics lifecycle signal: the /v1/users/fcm-token router emits status=registered (platform lowercased) after a successful save, and per-user sends emit status=invalidated with a count when _collect_send_results removes permanently dead tokens (UNREGISTERED and friends). Emission is fail-open: a PostHog outage can never fail a token save or a notification send. Bulk sends carry no uid, so they intentionally do not emit (asserted in tests to prevent misattribution). Tests in test_push_token_status_telemetry cover register (structural AST pin on the router), invalidate, no-noise on clean sends, and emit-failure isolation. Verified: backend/.venv python -m pytest tests/unit/test_push_token_status_telemetry.py -> 4 passed (worktree venv, Python 3.14, google-api-core installed for the unit conftest). * chore(changelog): mark mobile analytics instrumentation internal-only Purely additive analytics properties/events with no user-visible behavior change; kind=none fragment per the changelog contract for internal-only production edits. * style(analytics): dart format with repo-pinned Flutter 3.44.5 Canonical formatting for the new platform/trigger code; the machine's default dart shim resolves a different SDK, so formatting is done with the pinned 3.44.5 toolchain explicitly. * style(analytics): dart format with resolved analysis_options include pub get resolves flutter_lints so the formatter reads the repo's analysis_options include (matches CI exactly); the earlier format pass ran without package resolution and applied CLI defaults. * test(analytics): update payload expectations for platform and trigger properties The churn instrumentation adds 'platform' (global) and 'trigger' (per-event classification) to every mobile analytics event payload. Update the exact-payload expectations that predate those fields: - spine c7_emission_privacy_test allowlist gains both fields - fail-open manager tests: add trigger/platform to the four literal property maps (one already carried platform) - c8 golden tests + omi_double_tap goldens: globals now include trigger=platform classification (all user-initiated events) - conversation action analytics: filter the manager-added platform/trigger provenance the same way app_* is filtered, so the test still asserts the event itself carries only action+surface * revert: drop spine oracle edit from this PR The c7_emission_privacy_test.dart allowlist edit belongs in an oracle-only spine revision PR (contracts/spine/revisions/), not mixed with this implementation PR; the spine-contracts gate correctly rejects oracle edits alongside implementation paths. Reverting it here; the two spine c7 failures remain until that revision lands. * refactor(analytics): stamp platform/trigger attribution at the PostHog SDK boundary instead of the governed emission --------- Co-authored-by: David Zhang <[email protected]>
Summary
All new payloads are shape-only or bounded. Search text, raw device identifiers, transcripts, and upload errors are excluded.
Rebased
codex/telemetry-mobileonto currentorigin/main. Event catalog updates now live inweb/admin/docs/posthog-events.mdbecausedocs/analytics/events.mdwas removed from the public docs site.Verification
flutter teston the changed telemetry/provider test files: passedapp/scripts/analyze_ratchet.sh: pending in this pushmake preflightagainst currentmain: pending in this pushThe production PostHog destination was not exercised locally; the events were verified through the injected analytics adapter boundary.
Product invariants affected
app/lib/main.dartis on the invariant glob. This PR only addsApp Session Startedlifecycle telemetry and identify metadata; it does not change production-family routing, Firebase project, or API authority.Failure class (fixes)
Failure-Class: none