From a32007137e6684664f67958eca4e90c8cd073605 Mon Sep 17 00:00:00 2001 From: Hugo Montenegro Date: Fri, 12 Jun 2026 16:12:45 +0100 Subject: [PATCH] fix(analytics): make persons searchable by username in PostHog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- src/context/authContext.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/context/authContext.tsx b/src/context/authContext.tsx index 9d95cd6fe..6a3761e39 100644 --- a/src/context/authContext.tsx +++ b/src/context/authContext.tsx @@ -86,9 +86,12 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { if (typeof window !== 'undefined' && window.gtag) { window.gtag('set', { user_id: user.user.userId }) } - // PostHog: identify user (stitches anonymous pre-login events to this user) + // PostHog: identify user (stitches anonymous pre-login events to this user). + // `name` duplicates username because PostHog's Persons-page search is + // hardcoded to email/name/distinct_id — username alone is not searchable. posthog.identify(user.user.userId, { username: user.user.username, + name: user.user.username, }) // Sentry: every error captured from here on inherits user context // as searchable Sentry tags. Closes the historical gap where FE