docs+consent: disclose activation analytics honestly across consent modal, privacy policy, and store docs (#81)

The app ships PostHog activation-funnel analytics gated behind the same
consent flag as Sentry, but the consent modal, Settings toggle, privacy
policy, and Play Data safety draft only mentioned crash reporting. Fix
the disclosure everywhere:

- TelemetryConsentModal: body + bullets + a11y labels now cover anonymous
  usage analytics (PostHog EU) alongside crash reports
- Settings: toggle renamed 'Crash Reports & Usage Analytics', description
  names both Sentry and PostHog
- Privacy policy (md + html + live gh-pages mirror): new section 3a with
  the full event/property table, PostHog EU destination, anonymous-ID
  statement, decline/revoke (drop-on-revoke) semantics; sections 4-7, 9
  and the Apple nutrition-label addendum updated for analytics
- play-listing.md: Data safety draft declares App interactions + Device
  or other IDs (opt-in, default OFF, shared with PostHog/Sentry)
- docs/playstore.md: Data safety row flipped to re-verify with pointer
  to the new design record
- docs/analytics.md: new design record — event schema, consent gating
  incl. buffered-event drop on revoke, disclosure surfaces to keep in
  sync, verification checklist (all TODO)
- website privacy page metadata mentions analytics opt-in

Closes #63


Claude-Session: https://claude.ai/code/session_01NJKAQ6HAikWGQK7PGZ5Y4E

Co-authored-by: engineer <engineer@gray-knight-m1.local>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Den
2026-07-17 03:28:00 -07:00
committed by GitHub
parent b52fa52a4c
commit 63f3ec3c7e
10 changed files with 569 additions and 75 deletions

100
docs/analytics.md Normal file
View File

@@ -0,0 +1,100 @@
# Activation Analytics — Design Record
Design record for the PostHog-based activation-funnel analytics added to OpenCode Mobile,
and how it is disclosed and consent-gated. Companion to `docs/playstore.md` (Data safety)
and `distribution/privacy-policy.md` (user-facing policy). GitHub issue: #63.
> **Note:** the same consent flag also gates a third, separate data flow not covered by this
> doc: delivery of user-shared diagnostic reports to our self-hosted Chatwoot support inbox
> (`src/lib/chatwoot.ts`, `src/lib/diagnostics.ts`, issue #85/#88). That flow is triggered
> manually ("Share Report"), not automatic like Sentry/PostHog. It is disclosed alongside
> Sentry and PostHog in every surface in the table below; see `distribution/privacy-policy.md`
> §3b for the full description.
---
## Goal
Answer one product question: **do new users successfully connect to their opencode server
and reach first value (message sent → response received)?** Nothing else is tracked.
## SDK and destination
| Item | Value |
|---|---|
| SDK | `posthog-react-native`, self-instantiated (no `PostHogProvider`, no autocapture) |
| Destination | PostHog **EU region** — `https://eu.i.posthog.com` (override: `EXPO_PUBLIC_POSTHOG_HOST`) |
| API key | `EXPO_PUBLIC_POSTHOG_KEY` (CI secret; unset ⇒ analytics is a strict no-op) |
| Identity | PostHog's random app-generated anonymous ID only; no `identify()` calls, no user IDs |
| Code | `src/lib/analytics.ts` (wrapper), `src/lib/analytics-classify.ts` (error bucketing), `src/lib/telemetry.ts` (consent gate) |
## Event schema
Keep this table in 1:1 sync with `AnalyticsEvent` in `src/lib/analytics.ts` and with
section 3a of `distribution/privacy-policy.md`.
| Event | Fired when | Properties | Call site |
|---|---|---|---|
| `app_opened` | Once per JS session, as soon as analytics is enabled (cold start with prior consent, or immediately after consent grant) | `is_first_open: boolean` | `app/_layout.tsx`, `src/lib/telemetry.ts` |
| `connection_form_submitted` | User taps Connect/Save with a non-empty server URL | `mode: "quick" \| "advanced"` | `app/connection/add.tsx` |
| `connection_attempted` | A real connection test starts (advanced mode: fired on save, no pre-flight check) | `source: "onboarding" \| "edit_test"` | `src/stores/connections.ts`, `app/connection/add.tsx` |
| `connection_succeeded` | Health check responds OK | `source` | `src/stores/connections.ts` |
| `connection_failed` | Health check fails | `source`, `error_class` | `src/stores/connections.ts` |
| `message_sent` | User sends a prompt to an agent session (excludes slash commands) | — | `src/stores/sessions.ts` |
| `response_received` | Agent response finishes streaming (busy → idle), excluding user-aborted runs | — | `src/stores/events.ts` |
`error_class` is one of a fixed enum — `malformed-url`, `no-internet`, `server-unreachable`,
`unauthorized`, `tls-error`, `timeout`, `unknown` (`src/lib/analytics-classify.ts`). The raw
error string is never sent (it can embed hostnames/IPs/tokens).
**PII rule:** properties are flat primitives only (`AnalyticsProps`). Never add server URLs,
hostnames, ports, prompts, message/file content, tokens, or raw error text. Adding any new
event or property requires updating the privacy policy (section 3a) and the consent modal
copy in the same PR.
## Consent gating
Single consent flag (`opencode_telemetry_consent` in expo-secure-store) gates **both**
Sentry and PostHog — there is no separate analytics toggle. Managed by `src/lib/telemetry.ts`.
- **Off by default.** First launch shows `TelemetryConsentModal` (discloses crash reports
AND usage analytics). No SDK is initialised before a "granted" decision.
- **Grant:** `initSentry()` + `initAnalytics()`; `app_opened` fires (once-per-session guard).
- **Decline / never asked:** `track()` is a strict no-op; the PostHog client is never created;
nothing is written locally (the first-open flag is only touched post-consent).
- **Revoke (Settings → Privacy → Crash Reports & Usage Analytics):**
- Sentry client closed.
- PostHog: **buffered-but-unsent events are DROPPED, not flushed.** `ConsentGatedPostHog`
overrides the SDK `fetch()` transport; after revocation every request short-circuits to a
synthetic 200, so `shutdown()` drains the queue with zero bytes leaving the device. SDK
`optOut()` is persisted first so a re-created client can't capture either.
- **Re-grant mid-session:** `optIn()` clears the persisted opt-out; the `app_opened`
session guard prevents double-counting.
## Disclosure surfaces (must stay in sync)
| Surface | File |
|---|---|
| First-launch consent modal | `src/components/TelemetryConsentModal.tsx` |
| Settings toggle label/description | `app/(tabs)/settings.tsx` |
| Privacy policy (canonical md) | `distribution/privacy-policy.md` §3a, §3b, §4, §5 |
| Privacy policy (store/site html) | `distribution/privacy-policy.html`, `docs/privacy/index.html` (live gh-pages) |
| Play Data safety draft | `distribution/play-listing.md` |
| Play ops checklist | `docs/playstore.md` item 7 |
| Apple nutrition label | Apple addendum in `distribution/privacy-policy.md` (Usage Data → Product Interaction: Yes) |
## Verification checklist — TODO
Not yet verified end-to-end. Each item needs a real device/emulator run with a network
sniffer or PostHog live-events view:
- [ ] TODO: Fresh install → decline consent → exercise full app flow → confirm zero requests to `eu.i.posthog.com` and `sentry.io`.
- [ ] TODO: Fresh install → allow consent → confirm `app_opened` arrives with `is_first_open=true`; second launch sends `is_first_open=false`.
- [ ] TODO: Onboarding quick-connect success path emits `connection_form_submitted(mode=quick)` → `connection_attempted(source=onboarding)` → `connection_succeeded`.
- [ ] TODO: Failure path emits `connection_failed` with a coarse `error_class` and no raw error text/hostname in the payload.
- [ ] TODO: Send message + receive response emits `message_sent` and `response_received`; aborted run emits no `response_received`.
- [ ] TODO: Revoke mid-session while offline (events buffered) → go online → confirm buffered events are dropped (no PostHog traffic after revoke).
- [ ] TODO: Revoke → re-grant in same session → `app_opened` not double-counted.
- [ ] TODO: Build without `EXPO_PUBLIC_POSTHOG_KEY` → analytics is a complete no-op (no init log, no network).
- [ ] TODO: Inspect one real payload of every event type in PostHog and confirm property allowlist matches the schema table above.
- [ ] TODO: Play Console Data safety form re-submitted to match `distribution/play-listing.md` draft before next release.

View File

@@ -65,7 +65,7 @@ For full company facts (D-U-N-S, address, governor, etc.) see `~/.agents/skills/
| 4 | Feature graphic — 1024×500 PNG | Agent | ✅ done — `distribution/play-graphics/feature-graphic.png` |
| 5 | At least 2 phone screenshots (1080×1920 or similar) | Agent | ✅ done — `distribution/play-graphics/phone-{01,02,03}.png` (1080×2400 each; 3 screens: connection, chat, diff viewer) |
| 6 | Privacy policy — live at https://dzianisv.github.io/opencode-mobile/privacy/ | Agent | ✅ done — live & verified (HTTP 200) on gh-pages; `distribution/privacy-policy.html` (source), `distribution/privacy-policy.md` (markdown mirror) |
| 7 | Data safety form answers (drafted in `distribution/play-listing.md`) | User (in Console after app created) | ✅ verified — no analytics/ad SDKs found; crash logs updated to "Optional (opt-in, default OFF)" per new consent gate |
| 7 | Data safety form answers (drafted in `distribution/play-listing.md`) | User (in Console after app created) | ⚠️ re-verify — app now ships PostHog usage analytics (posthog-react-native) alongside Sentry, plus Chatwoot delivery of user-shared diagnostic reports (#88), all behind the same opt-in consent gate. Data safety draft updated: declare "App interactions" + "Device or other IDs" as collected, optional, shared with PostHog/Sentry; declare "User-submitted diagnostic reports" as collected, optional, shared with our self-hosted Chatwoot inbox. See `docs/analytics.md` |
| 8 | Content rating questionnaire (IARC, drafted) | User (in Console after app created) | ✅ verified — no violence/sexual/gambling/UGC; "interact with other users" = No (user talks to own AI agent) |
| 9 | App access — reviewer instructions for self-hosted opencode (drafted) | User | ✅ verified — instructions accurate; `npm install -g opencode-ai && opencode serve` flow confirmed in `play-listing.md` |
| 10 | Sentry opt-in consent gate (for F-Droid parity + GDPR friendly) | Agent | ✅ done — `src/lib/telemetry.ts` (consent store), `src/components/TelemetryConsentModal.tsx` (first-launch modal), `app/_layout.tsx` (gated init), `app/(tabs)/settings.tsx` (Privacy section toggle) |

View File

@@ -104,8 +104,9 @@
<div class="highlight-box">
<strong>Summary:</strong> OpenCode Mobile does not collect your code, prompts, AI responses,
server URLs, or any chat content. All AI traffic goes directly from the app to your own
opencode server. We use Sentry only for anonymous crash diagnostics, and only with your
consent.
opencode server. With your consent, we use Sentry for anonymous crash diagnostics, PostHog
for anonymous usage analytics, and — only when you tap &quot;Share Report&quot; — deliver a
scrubbed copy of that diagnostic report to our support inbox.
</div>
<h2>1. Who We Are</h2>
@@ -185,20 +186,153 @@
No server hostname or port number ever leaves your device via Sentry.
</p>
<h2>3a. Data We Do Collect (Usage Analytics)</h2>
<p>
With the same explicit consent (a single opt-in covers both crash reporting and analytics),
we collect a small set of anonymous usage events via <strong>PostHog</strong> to understand
whether new users successfully connect to their server and start using the app
(an "activation funnel").
</p>
<table>
<thead>
<tr>
<th>Event</th>
<th>When it fires</th>
<th>Properties</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>app_opened</code></td>
<td>Once per app session, after consent</td>
<td><code>is_first_open</code> (true/false)</td>
</tr>
<tr>
<td><code>connection_form_submitted</code></td>
<td>You tap Connect/Save with a server URL entered</td>
<td><code>mode</code> ("quick" or "advanced")</td>
</tr>
<tr>
<td><code>connection_attempted</code></td>
<td>A connection test starts</td>
<td><code>source</code> ("onboarding" or "edit_test")</td>
</tr>
<tr>
<td><code>connection_succeeded</code></td>
<td>The connection test succeeds</td>
<td><code>source</code></td>
</tr>
<tr>
<td><code>connection_failed</code></td>
<td>The connection test fails</td>
<td><code>source</code>, <code>error_class</code> (a coarse category such as "timeout" or
"unauthorized" — never the raw error text)</td>
</tr>
<tr>
<td><code>message_sent</code></td>
<td>You send a message to an agent session</td>
<td>—</td>
</tr>
<tr>
<td><code>response_received</code></td>
<td>An agent response finishes</td>
<td>—</td>
</tr>
</tbody>
</table>
<p>
What analytics events <strong>never</strong> contain: your server URL, hostname, IP address,
or port; prompts, messages, or AI responses; code or file contents; tokens or credentials;
raw error messages. Connection failures are reduced to a fixed list of coarse categories
before being sent.
</p>
<p>
Analytics data is sent to PostHog's <strong>EU region</strong> (<code>eu.i.posthog.com</code>)
and is identified only by a random, app-generated anonymous ID — not linked to your name,
email, or any account.
</p>
<p>
If you decline consent, no analytics is initialised and nothing is sent. If you revoke
consent later, analytics stops immediately and any events still buffered on the device are
discarded, not uploaded.
</p>
<h2>3b. Data We Do Collect (Shared Support Reports)</h2>
<p>
When a connection fails or the app crashes, you can tap <strong>Share Report</strong> to open
your device's normal share sheet with a diagnostic report. If you have granted the same
consent that covers crash reporting and analytics, a copy of that report is <em>also</em>
delivered directly to our support inbox, hosted on our own <strong>Chatwoot</strong> instance
(<code>support.agentlabs.cc</code>) — this is infrastructure we operate ourselves, not a
third-party SaaS vendor.
</p>
<table>
<thead>
<tr>
<th>Data type</th>
<th>What is included</th>
<th>What is NOT included</th>
</tr>
</thead>
<tbody>
<tr>
<td>Diagnostic summary</td>
<td>Connection classification (e.g. "server unreachable"), probe results, timing</td>
<td>—</td>
</tr>
<tr>
<td>Device info</td>
<td>Device model, OS version, app version</td>
<td>Serial number, IMEI, advertising ID</td>
</tr>
<tr>
<td>Recent app logs</td>
<td>Recent internal log lines (screen names, function-level breadcrumbs)</td>
<td>Message bodies, prompts, AI responses</td>
</tr>
<tr>
<td>Your server address</td>
<td>—</td>
<td>Never included — every URL and every hostname/IP the app probed this session is redacted before the report leaves your device</td>
</tr>
</tbody>
</table>
<p>
A random, per-install identifier (stored locally via secure device storage) links follow-up
reports from the same install into the same support conversation so we can reply to an
ongoing issue. This identifier is not linked to your name, email, or account — we only learn
contact details if you volunteer them in your own reply.
</p>
<p>
Sharing a report is always a manual, explicit action — it is never sent automatically or in
the background. It is only delivered to the support inbox if you have granted consent; if you
decline or revoke consent, tapping <strong>Share Report</strong> still opens your device's
normal share sheet, but nothing reaches our support inbox.
</p>
<h2>4. Consent and Control</h2>
<p>
Crash reporting is <strong>opt-in and off by default</strong>. The first time you launch
the app you will see a consent prompt. You can change this at any time:
Crash reporting, usage analytics, and support-inbox delivery of shared reports are all
<strong>opt-in and off by default</strong>, controlled by a single consent decision. The
first time you launch the app you will see a consent prompt. You can change this at any time:
</p>
<ul>
<li>Open the app → <strong>Settings</strong> → <strong>Privacy</strong> →
<strong>Crash reporting</strong> toggle.</li>
<li>When the toggle is off, Sentry is never initialised and no data leaves your device.</li>
<strong>Crash Reports &amp; Usage Analytics</strong> toggle.</li>
<li>When the toggle is off, neither Sentry nor PostHog is ever initialised and no data
leaves your device, and shared reports are never delivered to our support inbox (only
your device's normal share sheet is used). If you turn the toggle off later, both SDKs
are shut down, analytics events still buffered on the device are dropped without being
sent, and future shared reports stop reaching the support inbox.</li>
</ul>
<h2>5. Third-Party Services</h2>
<p>
We use one third-party service for diagnostics:
We use two third-party services, both consent-gated:
</p>
<ul>
<li>
@@ -207,20 +341,37 @@
Data is sent to Sentry's US-based servers and retained for approximately 90 days
per Sentry's default data-retention policy.
</li>
<li>
<strong>PostHog</strong> — anonymous usage analytics (the activation-funnel events listed
in section 3a).<br>
Privacy policy: <a href="https://posthog.com/privacy" target="_blank" rel="noopener">posthog.com/privacy</a><br>
Data is sent to PostHog's EU-region servers (<code>eu.i.posthog.com</code>).
</li>
</ul>
<p>
We use no advertising networks, analytics platforms, social SDKs, or any other
We use no advertising networks, social SDKs, or any other
third-party data collection services. The app contains no ads and no ad SDKs.
</p>
<p>
We also operate our own <strong>Chatwoot</strong> support-inbox instance
(<code>support.agentlabs.cc</code>, described in section 3b) to receive diagnostic reports
you explicitly choose to share. Unlike Sentry and PostHog, this is infrastructure we run
ourselves rather than a third-party vendor, but data sent to it still leaves your device and
is retained by us as described below.
</p>
<h2>6. Data Retention</h2>
<p>
Crash reports sent to Sentry are retained for approximately 90 days, after which they are
automatically deleted per Sentry's retention defaults.
automatically deleted per Sentry's retention defaults. Usage analytics events sent to
PostHog are retained per PostHog's standard retention policy. Shared support reports
delivered to our Chatwoot inbox are retained until the associated support conversation is
resolved and periodically purged thereafter; email support@agentlabs.cc to request earlier
deletion of a specific report.
</p>
<p>
We do not operate our own servers that store your data; there is no VIBE TECHNOLOGIES
back end involved in normal app usage.
Beyond that support inbox, we do not operate our own servers that store your data; there is
no other VIBE TECHNOLOGIES back end involved in normal app usage.
</p>
<h2>7. Your Rights</h2>
@@ -228,11 +379,13 @@
You have the right to:
</p>
<ul>
<li><strong>Opt out</strong> — disable crash reporting at any time in Settings → Privacy.</li>
<li><strong>Opt out</strong> — disable crash reporting, usage analytics, and support-inbox
delivery of shared reports at any time in Settings → Privacy.</li>
<li><strong>Request deletion</strong> — email <a href="mailto:support@agentlabs.cc">support@agentlabs.cc</a>
with subject "Data deletion request" and we will request deletion of any crash events
associated with your device from Sentry. Include your device model and approximate date
range to help us identify your records.</li>
(Sentry), analytics events (PostHog), and shared support-report conversations (Chatwoot)
associated with your device. Include your device model and approximate date range to
help us identify your records.</li>
<li><strong>Access</strong> — request a summary of what diagnostic data (if any) we hold
about your device by emailing the same address.</li>
</ul>
@@ -250,7 +403,8 @@
<h2>9. Security</h2>
<p>
All diagnostic data is transmitted over HTTPS (TLS 1.2+) to Sentry. We do not transmit
All diagnostic and analytics data — including shared support reports — is transmitted over
HTTPS (TLS 1.2+) to Sentry, PostHog, and our Chatwoot support inbox. We do not transmit
any data over unencrypted connections. Your opencode server traffic uses whatever transport
security your server provides — we recommend HTTPS for all self-hosted deployments.
</p>
@@ -303,13 +457,15 @@
<tbody>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Contact Info</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">N/A</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Location</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">N/A</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Identifiers (Device ID)</td><td style="border:1px solid #e2e8f0;padding:8px;">Yes (Sentry anonymous ID, with consent)</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Identifiers (Device ID)</td><td style="border:1px solid #e2e8f0;padding:8px;">Yes (Sentry / PostHog anonymous IDs, with consent)</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Usage Data — Product Interaction</td><td style="border:1px solid #e2e8f0;padding:8px;">Yes (PostHog activation events, with consent)</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Diagnostics — Crash Data</td><td style="border:1px solid #e2e8f0;padding:8px;">Yes (Sentry, with consent)</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Diagnostics — Performance Data</td><td style="border:1px solid #e2e8f0;padding:8px;">Yes (Sentry, with consent)</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">Diagnostics — Other Diagnostic Data</td><td style="border:1px solid #e2e8f0;padding:8px;">Yes (shared support reports delivered to our Chatwoot inbox, only when the user taps "Share Report" with consent)</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
<tr><td style="border:1px solid #e2e8f0;padding:8px;">All other categories</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td><td style="border:1px solid #e2e8f0;padding:8px;">N/A</td><td style="border:1px solid #e2e8f0;padding:8px;">No</td></tr>
</tbody>
</table>
<p><strong>App Store Connect summary:</strong> Data Linked to You: <em>None</em>. Data Not Linked to You: <em>Crash Data, Performance Data</em> (when user consents). Tracking: <em>No</em>.</p>
<p><strong>App Store Connect summary:</strong> Data Linked to You: <em>None</em>. Data Not Linked to You: <em>Crash Data, Performance Data, Product Interaction, Other Diagnostic Data</em> (when user consents). Tracking: <em>No</em>.</p>
<footer>
&copy; 2026 VIBE TECHNOLOGIES, LLC. OpenCode Mobile is MIT-licensed open-source software.