fix(analytics): make persons searchable by username in PostHog#2221
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughPostHog's ChangesPostHog Analytics Enrichment
🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Comment |
PostHog's Persons-page free-text search is hardcoded server-side to properties.email / properties.name / person id / distinct_id — it never reads username, so no Peanut user was findable by username (0 of 2,658 persons have email or name set). Duplicate username into name on identify so the search box works. Existing persons were backfilled via ops/scripts/posthog/backfill-person-name.mjs (mono).
87e2cf0 to
a320071
Compare
Code-analysis diffPainscore total: 5808.95 → 5809.11 (+0.16) 🆕 New findings (6)
✅ Resolved (6)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
Why
Konrad couldn't find any user by username in PostHog's Persons page. Root cause: PostHog's persons free-text search is hardcoded (
PersonStrategy.filter_conditions) to match onlyproperties.email,properties.name, person UUID, anddistinct_id. We only setusernameon identify — and 0 of 2,658 persons haveemail/name— so search-by-username never worked for anyone. (Usernames display in the list because the display-name config includesusername; display and search are separate code paths, which is the trap.)What
Duplicate
usernameintonamein theposthog.identify$set payload.nameranks beforeusernamein PostHog's display-name defaults and carries the same value, so nothing visibly changes — but the search box now matches.Backfill
Existing persons were backfilled (1,830 $set events via
mono/ops/scripts/posthog/backfill-person-name.mjs), so this isn't waiting on user logins. Re-running the script is a no-op for already-backfilled persons; worth one re-run after this reaches prod to catch persons created in between.Testing
npm test: 72/72 suites greennpm run typecheck: no hits on changed file