Repository navigation
Connect Hexclave and Stripe billing analytics to PostHog - #9702
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds Stack identity synchronization, Stripe billing event capture through PostHog, deferred webhook integration, tests, and updated PostHog disclosures across localized privacy policies. ChangesAnalytics tracking
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PageviewTracker
participant AnalyticsIdentityRoute
participant Stack
participant StackAnalytics
PageviewTracker->>AnalyticsIdentityRoute: Request current identity
AnalyticsIdentityRoute->>Stack: Read authenticated user
Stack-->>AnalyticsIdentityRoute: User ID and plan
AnalyticsIdentityRoute-->>PageviewTracker: Return private identity response
PageviewTracker->>StackAnalytics: Synchronize identity and capture pageview
sequenceDiagram
participant Stripe
participant StripeWebhookRoute
participant StripeBillingAnalytics
participant PostHog
Stripe->>StripeWebhookRoute: Send billing webhook
StripeWebhookRoute->>StripeBillingAnalytics: Defer mapped event capture
StripeBillingAnalytics->>PostHog: Capture billing event
Possibly related PRs
🚥 Pre-merge checks | ✅ 23 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (23 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@web/app/`[locale]/(legal)/privacy-policy/content/en.json:
- Line 67: Update the PostHog disclosure entry at line 67 in
web/app/[locale]/(legal)/privacy-policy/content/en.json to explicitly list
billing plan, subscription status, amount/currency, and Stripe identifiers,
alongside the existing checkout, subscription, invoice, and account-identity
data. Add equivalent localized wording at line 67 in ar.json, bs.json, da.json,
de.json, es.json, fr.json, and it.json, preserving each translation’s existing
content while making all specified billing categories explicit.
In `@web/app/`[locale]/posthog.tsx:
- Around line 9-31: The StackIdentityTracker only synchronizes identity on
mount, so sign-out leaves the previous Stack user ID in localStorage. Update
StackIdentityTracker to subscribe to the client authentication sign-out event
and re-fetch /api/analytics/identity or reset via syncStackAnalyticsIdentity
with an anonymous identity when sign-out occurs; preserve the existing abort and
cleanup behavior, and cover the transition from an authenticated user ID to
anonymous.
In `@web/app/api/analytics/identity/route.ts`:
- Around line 32-35: Update the identity route around dependencies.getUser so
lookup rejections are caught and treated as an anonymous identity by returning
identityResponse(null) rather than propagating a 500. Preserve the existing
handling for authenticated and anonymous users, and add coverage for a rejecting
getUser dependency.
In `@web/app/api/stripe/webhook/route.ts`:
- Around line 166-173: In the Stripe webhook handler, change each final
captureStripeBillingEvent call at web/app/api/stripe/webhook/route.ts lines
166-173, 183-188, and 202-207 to run after the response path rather than being
awaited inline. Keep analytics errors isolated from the webhook result so
PostHog delays or failures cannot delay or fail the Stripe response, while
preserving the existing event and analyticsSubject arguments.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 41a0f2c9-4bfb-4667-894b-313af8f41763
📒 Files selected for processing (29)
web/app/[locale]/(legal)/privacy-policy/content/ar.jsonweb/app/[locale]/(legal)/privacy-policy/content/bs.jsonweb/app/[locale]/(legal)/privacy-policy/content/da.jsonweb/app/[locale]/(legal)/privacy-policy/content/de.jsonweb/app/[locale]/(legal)/privacy-policy/content/en.jsonweb/app/[locale]/(legal)/privacy-policy/content/es.jsonweb/app/[locale]/(legal)/privacy-policy/content/fr.jsonweb/app/[locale]/(legal)/privacy-policy/content/it.jsonweb/app/[locale]/(legal)/privacy-policy/content/ja.jsonweb/app/[locale]/(legal)/privacy-policy/content/km.jsonweb/app/[locale]/(legal)/privacy-policy/content/ko.jsonweb/app/[locale]/(legal)/privacy-policy/content/no.jsonweb/app/[locale]/(legal)/privacy-policy/content/pl.jsonweb/app/[locale]/(legal)/privacy-policy/content/pt-BR.jsonweb/app/[locale]/(legal)/privacy-policy/content/ru.jsonweb/app/[locale]/(legal)/privacy-policy/content/th.jsonweb/app/[locale]/(legal)/privacy-policy/content/tr.jsonweb/app/[locale]/(legal)/privacy-policy/content/uk.jsonweb/app/[locale]/(legal)/privacy-policy/content/zh-CN.jsonweb/app/[locale]/(legal)/privacy-policy/content/zh-TW.jsonweb/app/[locale]/posthog.tsxweb/app/api/analytics/identity/route.tsweb/app/api/stripe/webhook/route.tsweb/services/analytics/stackIdentity.tsweb/services/analytics/stripeBilling.tsweb/tests/analytics-identity-route.test.tsweb/tests/stack-analytics-identity.test.tsweb/tests/stripe-billing-analytics.test.tsweb/tests/stripe-webhook-route.test.ts
| const user = await dependencies.getUser(request); | ||
| // Stack anonymous checkout users must not replace PostHog's browser-level | ||
| // anonymous identity. They become canonical only after account conversion. | ||
| return identityResponse(user && !user.isAnonymous ? { id: user.id } : null); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Handle Stack lookup failures as anonymous identity.
Line 32 rejects the route when dependencies.getUser() fails. This returns a 500 response for an analytics-only lookup.
Catch this failure and return { user: null }. Add a test where getUser rejects.
Proposed fix
- const user = await dependencies.getUser(request);
+ let user: { readonly id: string; readonly isAnonymous: boolean } | null;
+ try {
+ user = await dependencies.getUser(request);
+ } catch {
+ return identityResponse(null);
+ }Based on PR objectives, analytics failures must be non-authoritative.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const user = await dependencies.getUser(request); | |
| // Stack anonymous checkout users must not replace PostHog's browser-level | |
| // anonymous identity. They become canonical only after account conversion. | |
| return identityResponse(user && !user.isAnonymous ? { id: user.id } : null); | |
| let user: { readonly id: string; readonly isAnonymous: boolean } | null; | |
| try { | |
| user = await dependencies.getUser(request); | |
| } catch { | |
| return identityResponse(null); | |
| } | |
| // Stack anonymous checkout users must not replace PostHog's browser-level | |
| // anonymous identity. They become canonical only after account conversion. | |
| return identityResponse(user && !user.isAnonymous ? { id: user.id } : null); |
🤖 Prompt for 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.
In `@web/app/api/analytics/identity/route.ts` around lines 32 - 35, Update the
identity route around dependencies.getUser so lookup rejections are caught and
treated as an anonymous identity by returning identityResponse(null) rather than
propagating a 500. Preserve the existing handling for authenticated and
anonymous users, and add coverage for a rejecting getUser dependency.
There was a problem hiding this comment.
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 `@web/app/`[locale]/(legal)/privacy-policy/content/ar.json:
- Line 67: Update the privacy-policy retention section corresponding to the
PostHog disclosure in
web/app/[locale]/(legal)/privacy-policy/content/ar.json:67-67, bs.json:67-67,
da.json:67-67, de.json:67-67, ru.json:67-67, th.json:67-67, tr.json:67-67,
uk.json:67-67, zh-CN.json:67-67, and zh-TW.json:67-67. Add consistent
retention/deletion wording covering web analytics, post-sign-in account-linked
analytics, billing lifecycle data, and Stripe identifiers, or reference the
applicable external policy, using the same wording across all locale files.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: bde5abb2-006b-489e-875d-d36d8c763637
📒 Files selected for processing (23)
web/app/[locale]/(legal)/privacy-policy/content/ar.jsonweb/app/[locale]/(legal)/privacy-policy/content/bs.jsonweb/app/[locale]/(legal)/privacy-policy/content/da.jsonweb/app/[locale]/(legal)/privacy-policy/content/de.jsonweb/app/[locale]/(legal)/privacy-policy/content/en.jsonweb/app/[locale]/(legal)/privacy-policy/content/es.jsonweb/app/[locale]/(legal)/privacy-policy/content/fr.jsonweb/app/[locale]/(legal)/privacy-policy/content/it.jsonweb/app/[locale]/(legal)/privacy-policy/content/ja.jsonweb/app/[locale]/(legal)/privacy-policy/content/km.jsonweb/app/[locale]/(legal)/privacy-policy/content/ko.jsonweb/app/[locale]/(legal)/privacy-policy/content/no.jsonweb/app/[locale]/(legal)/privacy-policy/content/pl.jsonweb/app/[locale]/(legal)/privacy-policy/content/pt-BR.jsonweb/app/[locale]/(legal)/privacy-policy/content/ru.jsonweb/app/[locale]/(legal)/privacy-policy/content/th.jsonweb/app/[locale]/(legal)/privacy-policy/content/tr.jsonweb/app/[locale]/(legal)/privacy-policy/content/uk.jsonweb/app/[locale]/(legal)/privacy-policy/content/zh-CN.jsonweb/app/[locale]/(legal)/privacy-policy/content/zh-TW.jsonweb/app/[locale]/posthog.tsxweb/app/api/stripe/webhook/route.tsweb/tests/stripe-webhook-route.test.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/app/[locale]/posthog.tsx (1)
35-53: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winCommit only successful, current identity lookups before capturing pageviews.
When
/api/analytics/identityfails or returns401/404,capturePageview()still runs with the previous PostHog identity. A sign-out or account change can therefore attribute the pageview to the old Stack user. Capture only after the current request resolves an explicit identity, including an explicit anonymous/null response, and reject newer navigation requests before syncing identity.🤖 Prompt for 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. In `@web/app/`[locale]/posthog.tsx around lines 35 - 53, Update the promise flow around the identity lookup and capturePageview so pageviews occur only after a successful current response with an explicit StackAnalyticsIdentity or anonymous null identity. Do not call capturePageview for fetch errors, non-OK responses such as 401/404, malformed or incomplete payloads, or an aborted/stale request; ensure newer navigation requests are rejected before syncStackAnalyticsIdentity and retain the existing identity otherwise.Source: Path instructions
🤖 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.
Outside diff comments:
In `@web/app/`[locale]/posthog.tsx:
- Around line 35-53: Update the promise flow around the identity lookup and
capturePageview so pageviews occur only after a successful current response with
an explicit StackAnalyticsIdentity or anonymous null identity. Do not call
capturePageview for fetch errors, non-OK responses such as 401/404, malformed or
incomplete payloads, or an aborted/stale request; ensure newer navigation
requests are rejected before syncStackAnalyticsIdentity and retain the existing
identity otherwise.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6dcabecc-a860-4552-98be-64c3d69c8ea9
📒 Files selected for processing (5)
web/app/[locale]/posthog.tsxweb/app/api/analytics/identity/route.tsweb/services/analytics/stackIdentity.tsweb/tests/analytics-identity-route.test.tsweb/tests/stack-analytics-identity.test.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@web/app/`[locale]/(legal)/privacy-policy/content/de.json:
- Line 124: Align the retention and deletion wording in the matching locale
entries: update de.json, zh-CN.json, and zh-TW.json at line 124 to use
account-wide settings rather than mobile-account settings; update ru.json and
uk.json at line 124 likewise and remove the duplicated analytics wording next to
“account”.
In `@web/app/`[locale]/(legal)/privacy-policy/content/tr.json:
- Line 124: In the Turkish privacy-policy text, update the locative reference
from “PostHog'teki” to “PostHog'daki” while preserving the surrounding retention
statement unchanged.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6740a1e6-ee47-4980-bc27-719c776a51c0
📒 Files selected for processing (20)
web/app/[locale]/(legal)/privacy-policy/content/ar.jsonweb/app/[locale]/(legal)/privacy-policy/content/bs.jsonweb/app/[locale]/(legal)/privacy-policy/content/da.jsonweb/app/[locale]/(legal)/privacy-policy/content/de.jsonweb/app/[locale]/(legal)/privacy-policy/content/en.jsonweb/app/[locale]/(legal)/privacy-policy/content/es.jsonweb/app/[locale]/(legal)/privacy-policy/content/fr.jsonweb/app/[locale]/(legal)/privacy-policy/content/it.jsonweb/app/[locale]/(legal)/privacy-policy/content/ja.jsonweb/app/[locale]/(legal)/privacy-policy/content/km.jsonweb/app/[locale]/(legal)/privacy-policy/content/ko.jsonweb/app/[locale]/(legal)/privacy-policy/content/no.jsonweb/app/[locale]/(legal)/privacy-policy/content/pl.jsonweb/app/[locale]/(legal)/privacy-policy/content/pt-BR.jsonweb/app/[locale]/(legal)/privacy-policy/content/ru.jsonweb/app/[locale]/(legal)/privacy-policy/content/th.jsonweb/app/[locale]/(legal)/privacy-policy/content/tr.jsonweb/app/[locale]/(legal)/privacy-policy/content/uk.jsonweb/app/[locale]/(legal)/privacy-policy/content/zh-CN.jsonweb/app/[locale]/(legal)/privacy-policy/content/zh-TW.json
| "heading": "IX. Datenaufbewahrung", | ||
| "paragraphs": [ | ||
| "Absturzberichte und Diagnosen werden nur so lange aufbewahrt, wie es zur Diagnose und Behebung von Problemen erforderlich ist. Identifikatoren und Authentifizierungsdaten für mobile Konten werden aufbewahrt, solange Ihr Konto aktiv ist, und nach Abschluss der Kontolöschung gelöscht oder anonymisiert, es sei denn, die Aufbewahrung ist aus Sicherheits-, Rechts-, Abrechnungs- oder Betrugspräventionsgründen erforderlich. Geräte- und Kopplungsmetadaten bleiben erhalten, bis Sie die Kopplung aufheben, sich abmelden und lokale Daten löschen, Ihr Konto löschen oder veraltete Kopplungsdaten bereinigt werden. Apple-Push-Benachrichtigungsdienst-Tokens werden nur aufbewahrt, solange Benachrichtigungen aktiviert sind, und werden entfernt, wenn Sie Benachrichtigungen deaktivieren, sich abmelden, Ihr Konto löschen oder Apple das Token als ungültig meldet. Mobile Produktanalysen in PostHog werden bis zu 24 Monate lang aufbewahrt, es sei denn, Sie beantragen eine frühere Löschung. Mobile Kontoeinstellungen löschen oder anonymisieren cmux-eigene Konto-, Geräte-, Kopplungs-, Benachrichtigungs-, Abrechnungs- und Cloud-Daten, löschen die mit dem Konto verknüpfte PostHog-Person und fordern die Löschung ihrer mobilen Analyseereignisse und Aufzeichnungen an. Einige Löscharbeiten für Anbieter werden möglicherweise asynchron abgeschlossen. Fordern Sie die Löschung in den Einstellungen des mobilen Kontos an oder wenden Sie sich an [founders@manaflow.com](mailto:founders@manaflow.com)." | ||
| "Absturzberichte und Diagnosen werden nur so lange aufbewahrt, wie es zur Diagnose und Behebung von Problemen erforderlich ist. Identifikatoren und Authentifizierungsdaten für mobile Konten werden aufbewahrt, solange Ihr Konto aktiv ist, und nach Abschluss der Kontolöschung gelöscht oder anonymisiert, es sei denn, Sicherheits-, Rechts-, Abrechnungs- oder Betrugspräventionspflichten erfordern eine Aufbewahrung. Geräte- und Kopplungsmetadaten bleiben bis zur Entkopplung, Abmeldung und Löschung lokaler Daten, Kontolöschung oder Bereinigung veralteter Daten erhalten. Apple-Push-Tokens werden nur bei aktivierten Benachrichtigungen gespeichert. Website- und mobile Produktanalysen, kontoverknüpfte Analysen, Abrechnungsereignisse und Stripe-Kennungen in PostHog werden bis zu 24 Monate aufbewahrt, sofern Sie keine frühere Löschung beantragen. Mobile Kontoeinstellungen löschen oder anonymisieren cmux-eigene Daten, löschen die kontoverknüpfte PostHog-Person und beantragen die Löschung ihrer Website- und mobilen Analyseereignisse und Aufzeichnungen. Einige Abrechnungsdaten und Stripe-Kennungen können aus Sicherheits-, Rechts-, Steuer-, Abrechnungs- oder Betrugspräventionsgründen aufbewahrt werden. Anbieter-Löschungen können asynchron erfolgen. Beantragen Sie die Löschung in den mobilen Kontoeinstellungen oder über [founders@manaflow.com](mailto:founders@manaflow.com)." |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -i -C 3 \
'delete.?account|account.?delet|request.?delet|mobile.?account|account.?settings|PostHog|posthog' \
web/app web/services web/tests || trueRepository: manaflow-ai/cmux
Length of output: 50373
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== privacy policy JSON files around retention/deletion lines =="
for f in \
'web/app/[locale]/(legal)/privacy-policy/content/de.json' \
'web/app/[locale]/(legal)/privacy-policy/content/ru.json' \
'web/app/[locale]/(legal)/privacy-policy/content/uk.json' \
'web/app/[locale]/(legal)/privacy-policy/content/zh-CN.json' \
'web/app/[locale]/(legal)/privacy-policy/content/zh-TW.json' \
'web/app/[locale]/(legal)/privacy-policy/content/en.json' \
'web/app/[locale]/(legal)/privacy-policy/content/tr.json'
do
if [ -f "$f" ]; then
echo "--- $f ---"
sed -n '60,75p;118,130p' "$f" | cat -n
fi
done
echo
echo "== privacy policy source files in app and services =="
git ls-files 'web/app/**' 'web/services/**' | rg 'privacy|account|posthog|billing|stripe' | sed -n '1,200p'
echo
echo "== focused searches for account deletion terms =="
rg -n -i --glob 'web/**/*' \
'delete.?account|account.?delet|request.?delet|mobile.?account|account.?settings|PostHog|posthog|billing.?account|Stripe|stripe' \
web/app web/services web/routes web/tests 2>/dev/null | sed -n '1,280p'Repository: manaflow-ai/cmux
Length of output: 50372
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import json, subprocess, collections
files = collections.OrderedDict([
("web/app/[locale]/(legal)/privacy-policy/content/ar.json", "ar"),
("web/app/[locale]/(legal)/privacy-policy/content/bs.json", "bs"),
("web/app/[locale]/(legal)/privacy-policy/content/da.json", "da"),
("web/app/[locale]/(legal)/privacy-policy/content/de.json", "de"),
("web/app/[locale]/(legal)/privacy-policy/content/en.json", "en"),
("web/app/[locale]/(legal)/privacy-policy/content/es.json", "es"),
("web/app/[locale]/(legal)/privacy-policy/content/fr.json", "fr"),
("web/app/[locale]/(legal)/privacy-policy/content/it.json", "it"),
("web/app/[locale]/(legal)/privacy-policy/content/ja.json", "ja"),
("web/app/[locale]/(legal)/privacy-policy/content/km.json", "km"),
("web/app/[locale]/(legal)/privacy-policy/content/ko.json", "ko"),
("web/app/[locale]/(legal)/privacy-policy/content/no.json", "no"),
("web/app/[locale]/(legal)/privacy-policy/content/pl.json", "pl"),
("web/app/[locale]/(legal)/privacy-policy/content/pt-BR.json", "pt-BR"),
("web/app/[locale]/(legal)/privacy-policy/content/ru.json", "ru"),
("web/app/[locale]/(legal)/privacy-policy/content/th.json", "th"),
("web/app/[locale]/(legal)/privacy-policy/content/tr.json", "tr"),
("web/app/[locale]/(legal)/privacy-policy/content/uk.json", "uk"),
("web/app/[locale]/(legal)/privacy-policy/content/zh-CN.json", "zh-CN"),
("web/app/[locale]/(legal)/privacy-policy/content/zh-TW.json", "zh-TW"),
])
terms = {
"mobile accounts": ["account identifiers", "Authentication records"],
"mobile account settings": ["settings"],
"account settings": ["account settings"],
}
for path, locale in files.items():
try:
data=json.load(open(path, encoding="utf-8"))
except Exception as e:
print(f"ERROR {path}: {e}")
continue
# Find IX Data Retention paragraph and first "afterBullets" question paragraph candidates.
retention = None
for item in data.get("sections", []):
heading = item.get("heading","")
if heading and ("Data Retention" in heading or "Sammensæt" in heading or " хранение" in heading.lower() or "保留" in heading):
retention = item
break
print(f"-- {path} --")
if retention and "paragraphs" in retention:
print("found retention section:", retention["heading"])
text = " ".join(retention["paragraphs"])
issues = []
for term, variants in terms.items():
if term in text:
for v in variants:
if v in text:
issues.append(f"{v} in mobile-account context")
if not issues and term not in text:
issues.append("missing mobile account phrasing")
print("issues:", "; ".join(issues) if issues else "none from quick marker scan")
print("first mobile/account wording:",
" ".join([p for p in retention["paragraphs"] if ("Account" in p or "account" in p or "settings" in p or "mobile" in p or "設定" in p or "設定" in p)]))
else:
print("NO_RETE NTION_FOUND")
PY
echo
echo "== line 124 retention terms by locale =="
python3 - <<'PY'
import json, pathlib, re
terms = [
"Account identifiers and authentication records",
"Mobile account identifiers",
"account deletion finishes",
"account settings",
"Mobile account settings",
"account-linked analytics",
"Website and mobile product analytics",
"PostHog",
]
for rel in pathlib.Path("web/app/[locale]/(legal)/privacy-policy/content").glob("*.json"):
data=json.loads(rel.read_text(encoding="utf-8"))
# Use key for compact output
print("\n---", rel.relative_to("web/app/[locale]/(legal)/privacy-policy/content"))
print("--- content IX afterBullets section index")
print(data[100])
PYRepository: manaflow-ai/cmux
Length of output: 4167
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== JSON structure for one retention file =="
python3 - <<'PY'
import json
from pathlib import Path
p=Path('web/app/[locale]/(legal)/privacy-policy/content/en.json')
data=json.loads(p.read_text())
print("top_level_keys:", list(data.keys())[:20])
print("data_type:", type(data).__name__)
if isinstance(data, dict):
print("IX section key candidates:", [k for k in data if isinstance(data[k], dict) and data[k].get("heading") == "IX. Data Retention"])
if isinstance(data, list):
for i, item in enumerate(data):
if isinstance(item, dict):
h=item.get("heading","")
if "Data Retention" in h or "Sammensæt" in h or " хранение" in h.lower() or "保留" in h:
print("index", i, "heading", h)
print(json.dumps(item[:3], ensure_ascii=False, indent=2)[:500])
print(json.dumps(item[-2:], ensure_ascii=False, indent=2)[:1000])
break
PY
echo
echo "== retention data key for listed files =="
python3 - <<'PY'
import json, subprocess
for path in [
'web/app/[locale]/(legal)/privacy-policy/content/de.json',
'web/app/[locale]/(legal)/privacy-policy/content/ru.json',
'web/app/[locale]/(legal)/privacy-policy/content/uk.json',
'web/app/[locale]/(legal)/privacy-policy/content/zh-CN.json',
'web/app/[locale]/(legal)/privacy-policy/content/zh-TW.json',
'web/app/[locale]/(legal)/privacy-policy/content/en.json',
'web/app/[locale]/(legal)/privacy-policy/content/tr.json',
]:
data=json.load(open(path, encoding="utf-8"))
ret = None
if isinstance(data, dict):
for k,v in data.items():
if isinstance(v, dict) and v.get("heading") and "IX" in str(v.get("heading","")):
ret=v["heading"]
elif isinstance(data, list):
for item in data:
if isinstance(item, dict) and item.get("heading") and "IX" in str(item.get("heading","")):
ret=item["heading"]
print(path, "IX heading:", ret)
PY
echo
echo "== exact source snippets for data retention sections =="
for f in \
'web/app/[locale]/(legal)/privacy-policy/content/de.json' \
'web/app/[locale]/(legal)/privacy-policy/content/ru.json' \
'web/app/[locale]/(legal)/privacy-policy/content/uk.json' \
'web/app/[locale]/(legal)/privacy-policy/content/zh-CN.json' \
'web/app/[locale]/(legal)/privacy-policy/content/zh-TW.json' \
'web/app/[locale]/(legal)/privacy-policy/content/en.json' \
'web/app/[locale]/(legal)/privacy-policy/content/tr.json'
do
echo "--- $f ---"
python3 - <<'PY' "$f"
import json, sys
path=sys.argv[1]
data=json.load(open(path, encoding="utf-8"))
if isinstance(data, dict):
collection=data
elif isinstance(data, list):
collection=data
else:
raise SystemExit("unknown structure")
for item in collection:
heading=item.get("heading","")
if heading and "IX" in str(heading):
print("SECTION", repr(heading))
print("paragraphs:")
for part in item.get("paragraphs",[]):
print(part)
print("afterBullets:")
for part in item.get("afterBullets",[]):
print(part)
PY
doneRepository: manaflow-ai/cmux
Length of output: 1144
Align the account-wide retention and deletion wording across locale catalogs.
Line 67 discloses account-linked web and mobile analytics, so line 124 must not scope the deletion mechanism to mobile accounts.
de,zh-CN, andzh-TWstill read “mobile account settings”; use account-wide wording.ruandukstill mention mobile-account settings and should remove the duplicated analytics word next to “account”.- Update the matching locale entries so retention and deletion information does not differ by locale.
📍 Affects 5 files
web/app/[locale]/(legal)/privacy-policy/content/de.json#L124-L124(this comment)web/app/[locale]/(legal)/privacy-policy/content/ru.json#L124-L124web/app/[locale]/(legal)/privacy-policy/content/uk.json#L124-L124web/app/[locale]/(legal)/privacy-policy/content/zh-CN.json#L124-L124web/app/[locale]/(legal)/privacy-policy/content/zh-TW.json#L124-L124
🤖 Prompt for 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.
In `@web/app/`[locale]/(legal)/privacy-policy/content/de.json at line 124, Align
the retention and deletion wording in the matching locale entries: update
de.json, zh-CN.json, and zh-TW.json at line 124 to use account-wide settings
rather than mobile-account settings; update ru.json and uk.json at line 124
likewise and remove the duplicated analytics wording next to “account”.
Source: Coding guidelines
| "heading": "IX. Veri Saklama", | ||
| "paragraphs": [ | ||
| "Kilitlenme raporları ve tanılamalar yalnızca sorunları tanılamak ve düzeltmek için gerekli olduğu sürece saklanır. Mobil hesap tanımlayıcıları ve kimlik doğrulama kayıtları, hesabınız etkinken tutulur, güvenlik, yasal, faturalandırma veya dolandırıcılığı önleme görevlerinin saklamayı gerektirdiği durumlar hariç, hesap silme işlemi tamamlandığında silinir veya anonimleştirilir. Cihaz ve eşleştirme meta verileri, siz eşleştirmeyi kaldırıncaya, oturumunuzu kapatıp yerel verileri silinceye, hesabınızı silinceye veya eski eşleştirme verileri budanıncaya kadar tutulur. Apple Anında Bildirim hizmeti belirteçleri yalnızca bildirimler etkinleştirildiğinde tutulur ve bildirimleri devre dışı bıraktığınızda, oturumu kapattığınızda, hesabınızı sildiğinizde veya Apple belirtecin geçersiz olduğunu bildirdiğinizde kaldırılır. PostHog'teki mobil ürün analitiği, daha önce silinmesini talep etmediğiniz sürece 24 aya kadar saklanır. Mobil hesap ayarları, cmux'e ait hesabı, cihazı, eşleştirmeyi, bildirimi, faturalandırmayı ve bulut verilerini siler veya anonimleştirir, hesaba bağlı PostHog kişisini siler ve mobil analiz etkinliklerinin ve kayıtlarının silinmesini talep eder. Bazı sağlayıcı silme çalışmaları eşzamansız olarak tamamlanabilir. Mobil hesap ayarlarından veya [founders@manaflow.com](mailto:founders@manaflow.com) ile iletişime geçerek silme işlemini talep edin." | ||
| "Kilitlenme raporları ve tanılamalar yalnızca gerektiği sürece saklanır. Hesap tanımlayıcıları ve kimlik doğrulama verileri hesap etkinken tutulur, ardından güvenlik, yasal, vergi, faturalandırma veya dolandırıcılığı önleme yükümlülükleri dışında silinir ya da anonimleştirilir. Cihaz ve eşleştirme verileri bağlantı kesilene veya silinene, Apple belirteçleri ise yalnızca bildirimler etkin olduğu sürece tutulur. PostHog'teki web ve mobil analizler, hesaba bağlı analizler, faturalandırma yaşam döngüsü etkinlikleri ve Stripe tanımlayıcıları, daha erken silme istemediğiniz sürece 24 aya kadar saklanır. Hesap ayarları cmux verilerini siler veya anonimleştirir, bağlı PostHog kişisini siler ve web ve mobil analiz etkinlikleri ile kayıtlarının silinmesini ister. Bazı faturalandırma kayıtları ve Stripe tanımlayıcıları güvenlik, yasal, vergi, faturalandırma veya dolandırıcılığı önleme yükümlülükleri nedeniyle saklanabilir. Sağlayıcı silmeleri eşzamansız tamamlanabilir. Ayarlardan veya [founders@manaflow.com](mailto:founders@manaflow.com) üzerinden silme isteyin." |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Turkish suffix vowel harmony locative PostHog'daki PostHog'teki grammar
💡 Result:
To determine the correct locative suffix for "PostHog", you must apply Turkish vowel harmony and consonant harmony rules. The locative suffix in Turkish is either -da, -de, -ta, or -te [1][2][3]. The correct form is chosen as follows: 1. Vowel Harmony: The last vowel in the word "PostHog" is "o" (a back vowel). Therefore, the suffix must contain a back vowel ("a"). This narrows the choice to -da or -ta [1][3]. 2. Consonant Harmony: If the word ends in a voiceless consonant (f, s, t, k, ç, ş, h, p), the initial consonant of the suffix changes from 'd' to 't' [1][2][3]. The word "PostHog" ends in the letter 'g', which is a voiced consonant. Therefore, the suffix remains -da [1][4]. Following these rules, the correct form is PostHog'da. Note on the -ki suffix: If you are using the "-ki" suffix (the relative suffix used to turn a locative phrase into an adjective, meaning "the one at/in/on"), it is attached after the locative suffix [5]. Because "ki" is invariant regarding vowel harmony, it does not change its form [5]. Therefore, the correct form for "the one in/at PostHog" is PostHog'daki [5]. The form PostHog'teki would be incorrect because "e" is a front vowel and does not harmonize with the back vowel "o" in PostHog [6][3].
Citations:
- 1: https://elon.io/learn-turkish/lesson/the-locative-case-suffix
- 2: https://www.easyturkishgrammar.com/post/turkish-locative-case
- 3: https://turkishfluent.com/blog/locative-case-in-turkish/
- 4: https://www.turkishtextbook.com/at-in-and-on-da-de/
- 5: https://dergipark.org.tr/en/download/article-file/273986
- 6: https://en.wikibooks.org/wiki/Turkish/Pronunciation_and_Alphabet/Vowel_Classifications_and_Harmony
Correct the Turkish locative form.
Use PostHog'daki instead of PostHog'teki, since vowel harmony requires the back vowel form.
Proposed correction
-PostHog'teki
+PostHog'daki📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "Kilitlenme raporları ve tanılamalar yalnızca gerektiği sürece saklanır. Hesap tanımlayıcıları ve kimlik doğrulama verileri hesap etkinken tutulur, ardından güvenlik, yasal, vergi, faturalandırma veya dolandırıcılığı önleme yükümlülükleri dışında silinir ya da anonimleştirilir. Cihaz ve eşleştirme verileri bağlantı kesilene veya silinene, Apple belirteçleri ise yalnızca bildirimler etkin olduğu sürece tutulur. PostHog'teki web ve mobil analizler, hesaba bağlı analizler, faturalandırma yaşam döngüsü etkinlikleri ve Stripe tanımlayıcıları, daha erken silme istemediğiniz sürece 24 aya kadar saklanır. Hesap ayarları cmux verilerini siler veya anonimleştirir, bağlı PostHog kişisini siler ve web ve mobil analiz etkinlikleri ile kayıtlarının silinmesini ister. Bazı faturalandırma kayıtları ve Stripe tanımlayıcıları güvenlik, yasal, vergi, faturalandırma veya dolandırıcılığı önleme yükümlülükleri nedeniyle saklanabilir. Sağlayıcı silmeleri eşzamansız tamamlanabilir. Ayarlardan veya [founders@manaflow.com](mailto:founders@manaflow.com) üzerinden silme isteyin." | |
| "Kilitlenme raporları ve tanılamalar yalnızca gerektiği sürece saklanır. Hesap tanımlayıcıları ve kimlik doğrulama verileri hesap etkinken tutulur, ardından güvenlik, yasal, vergi, faturalandırma veya dolandırıcılığı önleme yükümlülükleri dışında silinir ya da anonimleştirilir. Cihaz ve eşleştirme verileri bağlantı kesilene veya silinene, Apple belirteçleri ise yalnızca bildirimler etkin olduğu sürece tutulur. PostHog'daki web ve mobil analizler, hesaba bağlı analizler, faturalandırma yaşam döngüsü etkinlikleri ve Stripe tanımlayıcıları, daha erken silme istemediğiniz sürece 24 aya kadar saklanır. Hesap ayarları cmux verilerini siler veya anonimleştirir, bağlı PostHog kişisini siler ve web ve mobil analiz etkinlikleri ile kayıtlarının silinmesini ister. Bazı faturalandırma kayıtları ve Stripe tanımlayıcıları güvenlik, yasal, vergi, faturalandırma veya dolandırıcılığı önleme yükümlülükleri nedeniyle saklanabilir. Sağlayıcı silmeleri eşzamansız tamamlanabilir. Ayarlardan veya [founders@manaflow.com](mailto:founders@manaflow.com) üzerinden silme isteyin." |
🤖 Prompt for 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.
In `@web/app/`[locale]/(legal)/privacy-policy/content/tr.json at line 124, In the
Turkish privacy-policy text, update the locative reference from “PostHog'teki”
to “PostHog'daki” while preserving the surrounding retention statement
unchanged.
Source: Coding guidelines
There was a problem hiding this comment.
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 `@web/app/`[locale]/posthog.tsx:
- Around line 39-66: Update the identity-fetch callback in the posthog
initialization flow to return immediately when controller.signal.aborted, both
before handling a non-OK response and after await response.json() before any
identity mutation. Preserve the existing validation and synchronization behavior
for active requests, and add a controlled-promise regression test that resolves
two identity requests out of order to verify the older response cannot overwrite
the newer identity.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4dece2ff-8cc1-4d3e-9747-c94b3418386e
📒 Files selected for processing (5)
web/app/[locale]/posthog.tsxweb/app/api/stripe/webhook/route.tsweb/services/analytics/stackIdentity.tsweb/tests/stack-analytics-identity.test.tsweb/tests/stripe-webhook-route.test.ts
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
… git-config step, and pass over an unreadable main verdict (manaflow-ai#53486) Every leo-workspace PR's land stopped red_not_excused on 2026-11-24 for three reasons, none of them the PR's: - tools/ws-check discount_base_reds (lw#9404) counts only a run's own failed units in its status, "N of M steps failed: UNIT (+K base red discounted, main SHA8)" (or, since lw#9754, the marker before the unit), while WS_CHECK_RESULT lists every failed step: refused "does not match run's WS_CHECK_RESULT" (lw#9704, manaflow-ai#9760, manaflow-ai#9702, manaflow-ai#9753). ws_check_described now checks the count, K and main against the run's own base-pass lines. - ws_check_run.py's "global git config changed by a step" has no step line, only "ws-check: a step changed the global git config ...": refused "has no 'ws-check step FAILED: ...' line" (lw#9703). It is read from that line. - main 106d10145c's run kept only the last 200 lines of a red suite (16 of 17 FAIL lines), and every head was refused "its failing tests cannot be listed" on main's run. An unreadable base verdict in the compared window is now passed over for the next one (the merge-base read stays strict); with none left the refusal names it. Agent-Session: https://cmux.com/deeplink/agent?id=aid-974d4bf42986393391ee&model=claude-opus-5-5 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Testing
cd web && bun run typecheckcd web && bun test tests/stack-analytics-identity.test.ts tests/analytics-identity-route.test.ts tests/stripe-billing-analytics.test.ts tests/stripe-webhook-route.test.ts(21 passed)cd web && bunx eslint ...(changed files)cd web && bun run buildclient-config-envfailures reproduced onorigin/mainResearch
$insert_idfor retry deduplication and$setfor current subscription properties.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Connect Hexclave/Stack identity to
posthog-jsand joinStripebilling analytics on the same distinct id. Gate analytics until a server-authenticated identity resolves or times out; buffer during revalidation; drop buffered events on account change; replay only when the identity is stable; billing analytics send async so payments never block./api/analytics/identityusing Stack cookie tokens; observe auth with@stackframe/stack(StackProvider); backfill plan; reset on sign-in/out; anonymous checkout stays anonymous; passive refreshes fail-closed.posthog-jswithbefore_senduntil identity resolves; add timeout and abortable gating; buffer pageviews/autocapture during revalidation; persiststack_user_idin PostHog/local storage; coalesce refresh; drop buffered events across account changes; replay only when identity matches.Stripecheckout/subscription/invoice events to PostHog; join to user/team$groups; set$insert_idand$set; defer withnext/serverafter(2s cap); emit only for active subscriptions; failures never affect entitlements.Written for commit 115cf74. Summary will update on new commits.
Summary by CodeRabbit