Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(activity-log): fall back to email when actor has no name (#73536)

posthog[bot]1c29f20d174c
diff --git a/frontend/src/lib/components/ActivityLog/humanizeActivity.test.tsx b/frontend/src/lib/components/ActivityLog/humanizeActivity.test.tsx
new file mode 100644
index 000000000000..5bf8e4677363
--- /dev/null
+++ b/frontend/src/lib/components/ActivityLog/humanizeActivity.test.tsx
@@ -0,0 +1,40 @@
+import { ActivityLogItem, userNameForLogItem } from 'lib/components/ActivityLog/humanizeActivity'
+
+import { ActivityScope } from '~/types'
+
+describe('userNameForLogItem', () => {
+ const makeLogItem = (overrides: Partial<ActivityLogItem>): ActivityLogItem => ({
+ activity: 'updated',
+ created_at: '2026-06-04T00:00:00Z',
+ scope: ActivityScope.FEATURE_FLAG,
+ detail: { merge: null, trigger: null, changes: null, name: 'my-flag' },
+ ...overrides,
+ })
+
+ it.each([
+ [
+ 'uses the full name when set',
+ { user: { first_name: 'Ada', last_name: 'Lovelace', email: '[email protected]' } },
+ 'Ada Lovelace',
+ ],
+ [
+ 'falls back to email when the name is blank',
+ { user: { first_name: '', last_name: '', email: '[email protected]' } },
+ ],
+ [
+ 'falls back to the placeholder when name and email are both blank',
+ { user: { first_name: '', last_name: '', email: '' } },
+ 'A user',
+ ],
+ ['falls back to the placeholder when there is no user', {}, 'A user'],
+ ['renders system activity as PostHog', { is_system: true }, 'PostHog'],
+ [
+ 'falls back to email for impersonated actors with a blank name',
+ { was_impersonated: true, user: { first_name: '', last_name: '', email: '[email protected]' } },
+ 'PostHog Support (as [email protected])',
+ ],
+ ])('%s', (_name, overrides: Partial<ActivityLogItem>, expected: string) => {
+ expect(userNameForLogItem(makeLogItem(overrides))).toEqual(expected)
+ })
+})
diff --git a/frontend/src/lib/components/ActivityLog/humanizeActivity.tsx b/frontend/src/lib/components/ActivityLog/humanizeActivity.tsx
index d9f47764276c..e05496fc856e 100644
--- a/frontend/src/lib/components/ActivityLog/humanizeActivity.tsx
+++ b/frontend/src/lib/components/ActivityLog/humanizeActivity.tsx
@@ -142,10 +142,21 @@ export function userNameForLogItem(logItem: ActivityLogItem): string {
return 'PostHog'
}
if (logItem.was_impersonated) {
- const impersonatedUserName = logItem.user ? fullName(logItem.user) : 'a user'
- return `PostHog Support (as ${impersonatedUserName})`
+ return `PostHog Support (as ${nameOrEmailForUser(logItem.user, 'a user')})`
}
- return logItem.user ? fullName(logItem.user) : 'A user'
+ return nameOrEmailForUser(logItem.user, 'A user')
+}
+
+// The user's name can be blank (e.g. SCIM-provisioned members whose IdP omits a name), so fall
+// back to their email — which is always in the payload — before the generic placeholder.
+function nameOrEmailForUser(
+ user: Pick<UserBasicType, 'email' | 'first_name' | 'last_name'> | undefined,
+ fallback: string
+): string {
+ if (!user) {
+ return fallback
+ }
+ return fullName(user) || user.email || fallback
}
const NO_PLURAL_SCOPES: ActivityScope[] = [ActivityScope.DATA_MANAGEMENT]