Skip to content

Route PostHog feature flags through managed proxy - #7232

Merged
lawrencecchen merged 2 commits into
mainfrom
fix-adblock-posthog-flags
Jul 3, 2026
Merged

lawrencecchen merged 2 commits into
mainfrom
fix-adblock-posthog-flags

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep PostHog analytics on https://r.cmux.com
  • route PostHog feature flag evaluation through https://r.cmux.dev with flags_api_host
  • keep feature flags enabled for future pricing-page work while avoiding Vercel proxy bandwidth and request usage

Testing

  • cd web && bun run typecheck
  • cd web && bun run lint (existing warnings only)
  • cd web && source scripts/load-dev-env.sh && bun run build
  • warmed local dev routes at http://127.0.0.1:4538/, /handler/sign-in, and /handler/after-sign-in
  • verified DNS for r.cmux.com and r.cmux.dev resolves to PostHog managed proxy CNAMEs
  • verified built client bundle contains api_host: "https://r.cmux.com" and flags_api_host: "https://r.cmux.dev", with no advanced_disable_flags

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Updated analytics initialization to point feature-flag fetching to the correct flags API host, improving consistency in feature flag behavior across the app.

Note

Low Risk
Single-line PostHog config change; no auth or data-model impact, though misconfigured DNS/proxy for the flags host could break flag loading in the client.

Overview
PostHog client init now sends feature flag requests to https://r.cmux.dev via flags_api_host, while analytics traffic stays on https://r.cmux.com (api_host unchanged).

This splits flag evaluation onto a dedicated managed proxy so flags can stay on for upcoming pricing work without pushing that traffic through the Vercel proxy path.

Reviewed by Cursor Bugbot for commit ba094de. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Jul 3, 2026 8:16am
cmux-staging Building Building Preview, Comment Jul 3, 2026 8:16am

@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A single configuration option, flags_api_host, was added to the posthog.init call in web/app/[locale]/posthog.tsx, changing PostHog client initialization without altering other runtime logic.

Changes

PostHog Init Config

Layer / File(s) Summary
Set flags API host on init
web/app/[locale]/posthog.tsx
Added flags_api_host to the posthog.init configuration.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 25
✅ Passed checks (25 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Cmux Swift Actor Isolation ✅ Passed PR changes only web/app/[locale]/posthog.tsx; no Swift code or actor-isolation-sensitive Swift paths were modified.
Cmux Swift Blocking Runtime ✅ Passed PR only changes web/app/[locale]/posthog.tsx; no Swift files or blocking/timing primitives are introduced, so the Swift rule is not applicable.
Cmux Browser Automation Off-Main ✅ Passed Diff only adds a PostHog flags_api_host in web/app/[locale]/posthog.tsx; no browser.* socket automation, routing, or WebKit/AppKit main-thread code changed.
Cmux Expensive Synchronous Load ✅ Passed Only web/app/[locale]/posthog.tsx changed; no Swift files or agent-history load paths were touched, so the Swift sync-load rule isn’t applicable.
Cmux Cache Substitution Correctness ✅ Passed The diff only changes PostHog init config in a client analytics file; it does not replace any fresh authoritative read in persistence, history, undo, or snapshot code.
Cmux No Hacky Sleeps ✅ Passed The diff only adds a PostHog flags_api_host config; it introduces no sleeps, timers, polling loops, or delay-based synchronization.
Cmux Algorithmic Complexity ✅ Passed web/app/[locale]/posthog.tsx only adds a PostHog init option; it introduces no new scans, loops, or hot-path collection work.
Cmux Swift Concurrency ✅ Passed The PR only changes web/app/[locale]/posthog.tsx; no Swift files or Swift concurrency patterns are introduced.
Cmux Swift @Concurrent ✅ Passed No Swift files changed; the PR only updates web/app/[locale]/posthog.tsx, so the Swift concurrency rule is not applicable.
Cmux Swift File And Package Boundaries ✅ Passed The PR only adds one line to web/app/[locale]/posthog.tsx; no Swift files or app-target package-boundary changes are present.
Cmux Swiftpm Lockfiles ✅ Passed PR only changes web/app/[locale]/posthog.tsx; no SwiftPM, Xcode, .gitignore, workflow, or dependency files were touched.
Cmux Swift Logging ✅ Passed No Swift files changed; the diff only updates web/app/[locale]/posthog.tsx, so the Swift logging rule is not implicated.
Cmux User-Facing Error Privacy ✅ Passed Only PostHog client config changed; no user-facing errors, alerts, or recovery copy were added or exposed.
Cmux Full Internationalization ✅ Passed Config-only PostHog init change; no user-facing text, locale keys, or message-catalog updates were introduced.
Cmux Swiftui State Layout ✅ Passed Diff only changes web/app/[locale]/posthog.tsx; no SwiftUI state/layout patterns are present, so the rule is not applicable.
Cmux Architecture Rethink ✅ Passed PASS: The PR only changes web/app/[locale]/posthog.tsx; no Swift code or lifecycle/state-ownership patterns covered by the rule are introduced.
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed No Swift files changed; the PR only touches web/app/[locale]/posthog.tsx, so the auxiliary-window-close-shortcuts rule is not applicable.
Cmux Source Artifacts ✅ Passed Only a hand-edited source file changed; no logs, build output, caches, or scratch/artifact paths were added.
Cmux No Test Or Debug Seam In Production Source ✅ Passed PR only changes a TypeScript React file; no Swift production Sources code or test/debug seam is involved.
Cmux No Ambient Global State ✅ Passed Not applicable: the patch only changes web/app/[locale]/posthog.tsx and touches no Swift files or ambient global-state surfaces.
Title check ✅ Passed The title clearly and concisely describes the main change: routing PostHog feature flags through a managed proxy.
Description check ✅ Passed Summary and testing are thorough, but the template’s Demo Video, Review Trigger, and Checklist sections are missing.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-adblock-posthog-flags

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.

@greptile-apps

greptile-apps Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds flags_api_host: "https://r.cmux.dev" to the PostHog initialization config so that feature-flag evaluation calls are routed through a dedicated managed proxy instead of the main analytics proxy at r.cmux.com.

  • Routes feature-flag API traffic to https://r.cmux.dev (a separate PostHog managed-proxy CNAME) while keeping event capture on https://r.cmux.com, splitting the two traffic types across distinct proxies as the PR intends.
  • The flags_api_host option is the correct PostHog JS SDK config key for this use case; the managed-proxy setup follows the documented pattern of setting api_host + flags_api_host + ui_host together.

Confidence Score: 5/5

Safe to merge — one-line config addition routing feature-flag requests to a dedicated managed proxy, with no logic changes.

The change adds a single flags_api_host entry to the PostHog init config. Both proxy domains are verified by the author, the option is the correct PostHog SDK key for splitting flag and event traffic, and all three proxy config fields (api_host, flags_api_host, ui_host) are correctly set together.

No files require special attention.

Important Files Changed

Filename Overview
web/app/[locale]/posthog.tsx Adds flags_api_host pointing to the r.cmux.dev managed proxy — minimal, correct one-line change with no logic issues.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Browser
    participant r.cmux.com as r.cmux.com<br/>(analytics proxy)
    participant r.cmux.dev as r.cmux.dev<br/>(flags proxy)
    participant PostHog as PostHog US Cloud

    Browser->>r.cmux.com: POST /e/ (events, pageviews)
    r.cmux.com->>PostHog: forward events
    PostHog-->>r.cmux.com: 200 OK
    r.cmux.com-->>Browser: 200 OK

    Browser->>r.cmux.dev: GET /decide/ (feature flag eval)
    r.cmux.dev->>PostHog: forward flag request
    PostHog-->>r.cmux.dev: flag values
    r.cmux.dev-->>Browser: flag values
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Browser
    participant r.cmux.com as r.cmux.com<br/>(analytics proxy)
    participant r.cmux.dev as r.cmux.dev<br/>(flags proxy)
    participant PostHog as PostHog US Cloud

    Browser->>r.cmux.com: POST /e/ (events, pageviews)
    r.cmux.com->>PostHog: forward events
    PostHog-->>r.cmux.com: 200 OK
    r.cmux.com-->>Browser: 200 OK

    Browser->>r.cmux.dev: GET /decide/ (feature flag eval)
    r.cmux.dev->>PostHog: forward flag request
    PostHog-->>r.cmux.dev: flag values
    r.cmux.dev-->>Browser: flag values
Loading

Reviews (4): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

Comment thread web/app/[locale]/posthog.tsx Outdated
person_profiles: "identified_only",
capture_pageview: false,
capture_pageleave: true,
advanced_disable_feature_flags: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 partner According to PostHog's JS configuration docs, advanced_disable_feature_flags is a legacy option marked for deprecation. The recommended replacement is advanced_disable_flags, which behaves identically but is the forward-compatible name. Switching now avoids a future breaking change when the deprecated key is eventually removed from the SDK.

Suggested change
advanced_disable_feature_flags: true,
advanced_disable_flags: true,

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7e3899c9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/app/[locale]/posthog.tsx Outdated
person_profiles: "identified_only",
capture_pageview: false,
capture_pageleave: true,
advanced_disable_feature_flags: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the endpoint-level disable flag

PostHog documents advanced_disable_feature_flags as keeping the /flags endpoint running while skipping feature-flag evaluation, whereas advanced_disable_flags is the option that completely disables /flags. If the goal is the verified “no network requests matching flags” behavior on cmux.com, this line can still leave /flags traffic (or periodic refresh traffic); use advanced_disable_flags: true to remove the endpoint entirely, or remote_config_refresh_interval_ms: 0 if only background polling should stop.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 1 file

Re-trigger cubic

@lawrencecchen
lawrencecchen force-pushed the fix-adblock-posthog-flags branch from c700c80 to ae6c62b Compare July 3, 2026 06:14
@lawrencecchen lawrencecchen changed the title Disable PostHog feature flag polling on web Route PostHog feature flags through managed proxy Jul 3, 2026
@lawrencecchen
lawrencecchen merged commit 6d708d0 into main Jul 3, 2026
28 checks passed
@lawrencecchen
lawrencecchen deleted the fix-adblock-posthog-flags branch July 3, 2026 08:16
@lawrencecchen
lawrencecchen restored the fix-adblock-posthog-flags branch July 18, 2026 10:24

This branch was successfully deployed

1 active deployment
Preview – cmux — ba094de0 Deployed Jul 3, 2026 by vercel[bot]
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