Skip to content

Analytics privacy: keep PII and financials off PostHog#8

Merged
saikumarbt merged 2 commits into
mainfrom
analytics-privacy
Jul 13, 2026
Merged

Analytics privacy: keep PII and financials off PostHog#8
saikumarbt merged 2 commits into
mainfrom
analytics-privacy

Conversation

@saikumarbt

Copy link
Copy Markdown
Owner
  • identify() sends the opaque Clerk id only (no email/name)
  • subscription_* events drop name/price/currency; add a coarse price_bucket (under_5/5_15/15_50/50_plus) for non-sensitive spend signal
  • add a "Share anonymous analytics" opt-out in Settings, persisted and applied on launch (posthog.optIn/optOut)
  • tests for priceBucket

Subscription data and PII stay on-device / in Clerk; PostHog holds only behavior keyed to the anonymous id.

- identify() sends the opaque Clerk id only (no email/name)
- subscription_* events drop name/price/currency; add a coarse
  price_bucket (under_5/5_15/15_50/50_plus) for non-sensitive spend signal
- add a "Share anonymous analytics" opt-out in Settings, persisted and
  applied on launch (posthog.optIn/optOut)
- tests for priceBucket

Subscription data and PII stay on-device / in Clerk; PostHog holds only
behavior keyed to the anonymous id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@saikumarbt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ce2c215a-3a38-40e3-a14e-941e1b89173f

📥 Commits

Reviewing files that changed from the base of the PR and between 4b40082 and 2eb1cbe.

📒 Files selected for processing (2)
  • PRODUCTION_PLAN.md
  • app/_layout.tsx

Walkthrough

Analytics tracking now supports persisted opt-out preferences, opaque user identification, and coarse price buckets. Subscription event payloads no longer include names or exact pricing, and settings expose a control for anonymous analytics sharing.

Changes

Analytics privacy and event tracking

Layer / File(s) Summary
Analytics bucketing contract
lib/analytics.ts, __tests__/analytics.test.ts
Adds priceBucket and the persisted opt-out key, with coverage for normal, boundary, and invalid inputs.
Persisted analytics preference
app/_layout.tsx, app/(tabs)/settings.tsx
Applies stored opt-out state at launch and adds a settings switch that persists the preference and updates PostHog.
Non-identifying event payloads
app/(tabs)/index.tsx, app/subscriptions/[id].tsx, app/_layout.tsx
Replaces identifying subscription fields with a coarse price bucket or subscription ID, and identifies users only by opaque IDs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Settings
  participant KeyValueStorage
  participant PostHog
  User->>Settings: toggle anonymous analytics
  Settings->>KeyValueStorage: persist analytics_optout
  Settings->>PostHog: call optIn or optOut
  PostHog->>PostHog: apply collection preference
Loading

Possibly related PRs

Poem

A bunny trims the names away,
And buckets prices soft and gray.
A switch says “share” or “please opt out,”
While opaque IDs hop about.
Clean events dance through the night! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: reducing PII and financial detail sent to PostHog.
Description check ✅ Passed The description clearly matches the implemented analytics privacy updates and new price bucket tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch analytics-privacy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/_layout.tsx`:
- Around line 22-26: Update the launch effect around getKv and posthog.optOut()
to add an else branch that calls posthog.optIn() whenever ANALYTICS_OPTOUT_KEY
is not "1", keeping PostHog’s persisted state synchronized with the KV
preference.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8fd7449a-d80d-4e1c-b119-040fd361e66c

📥 Commits

Reviewing files that changed from the base of the PR and between f08adec and 4b40082.

📒 Files selected for processing (6)
  • __tests__/analytics.test.ts
  • app/(tabs)/index.tsx
  • app/(tabs)/settings.tsx
  • app/_layout.tsx
  • app/subscriptions/[id].tsx
  • lib/analytics.ts

Comment thread app/_layout.tsx
@saikumarbt
saikumarbt merged commit e47e5fc into main Jul 13, 2026
1 check passed
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