# ניטור מובייל — P4

> תיעוד היסטורי. מקור: docs/mobile-p4-observability.md · 6a466bf.

P1–P3 approved UI, maps, assets, tenant isolation, authorization, payments, and business workflows are **locked**. This PR changes mobile telemetry, its dependencies, tests, and documentation only.

## Implemented (disabled until external integration is certified)

- Anonymous PostHog API-health events for failures/slow requests with coarse latency/status buckets.
- Expo Router render-error reporting and fatal JavaScript error forwarding, preserving existing error handling.
- Grafana Faro React Native SDK 1.5.0 with native crash reporting enabled **only inside its explicit runtime opt-in**; runtime initialization fails closed if collector configuration is missing.
- Native dependency versions pinned and monorepo `pnpm-lock.yaml` updated for frozen install.
- Application release metadata (platform, app version, build version, environment).
- HTTP/console/user-action capture disabled for Faro; no GPS coordinates, secrets, tokens, API URLs, request/response bodies, or tenant/user identifiers are intentionally attached by our application instrumentation.

### Feature flags

- `EXPO_PUBLIC_TELEMETRY_ENABLED=false` — PostHog mobile API-health analytics off by default.
- `EXPO_PUBLIC_GRAFANA_MOBILE_ENABLED=false` — Grafana native crash reporter off by default.
- `EXPO_PUBLIC_GRAFANA_MOBILE_COLLECTOR_URL` — must be the verified **mobile** collector URL from Grafana Cloud, never a guessed URL or the web collector.
- `EXPO_PUBLIC_APP_ENV` — must identify the app build environment.

## Confirmed QA on P4 head (11 November 2026)

- Frozen-lockfile pnpm workspace installation: **PASS**.
- Mobile TypeScript `tsc --noEmit`: **PASS**.
- Expo Doctor: **20/20 PASS**.
- Expo export, iOS and Android: **PASS**.
- Expo prebuild, iOS and Android: **PASS** (isolated QA runner only; QA root postinstall was stubbed because the test checkout intentionally excluded the Next.js website asset-generation script; no production/repository files were altered by this workaround).
- Product Vercel Preview built from P4 head: **READY**.
- Native signed compilation on actual physical devices / Apple and Google signing: **NOT VERIFIED**.
- Static telemetry privacy regression test file: **WRITTEN, NOT YET VERIFIED BY VITEST**.

## External release gates — must pass before activation

1. Enable Grafana Mobile Observability private preview for this Grafana Cloud account; create a dedicated LinkNodes mobile application and obtain its generated collector endpoint.
2. Configure separate preview and production mobile build profiles with the approved collector URL. Rebuild the native app; an OTA update alone cannot install native SDK modules.
3. Produce signed iOS/Android development/store builds with approved Apple Team ID and Android Maps SDK key/signing certificate.
4. Trigger a controlled non-production **native process crash on each platform**, relaunch, and confirm the recovered crash appears in Grafana with the correct mobile app/release. Verify no sensitive data is present.
5. Configure actual Grafana alert rules and **notification routes**, trigger a test alert and verify delivery/acknowledgement; having a contact point alone does not prove alerting. The Grafana default notification receiver currently reads `empty`.
6. Set up backend OpenTelemetry correlation and validate request tracing end to end without capturing the exact user location or tokens.
7. Validate PostHog mobile ingestion, opt-in state, privacy, retention, and staging/production separation, then approve telemetry enablement.

**Do not mark P4 end-to-end observability as active until all seven external gates are verified.** Code can be safely merged behind flags after code QA, but no claim of signed mobile release or operational crash alerting is authorized.

## Acceptance

- With flags disabled, mobile behavior, UI, tenant access, and data flows remain unchanged.
- Missing/invalid collector configuration fails closed and does not break app startup.
- No credential, precise GPS, or customer personal data is deliberately sent by new application instrumentation.
- Native crash delivery and alert notifications are confirmed by real-device and delivery evidence before enablement.
