Skip to content

feat: add PostHog name properties to identify call#2857

Open
GrueneKatze wants to merge 1 commit into
mainfrom
feat/posthog-identify-name-properties
Open

feat: add PostHog name properties to identify call#2857
GrueneKatze wants to merge 1 commit into
mainfrom
feat/posthog-identify-name-properties

Conversation

@GrueneKatze
Copy link
Copy Markdown

@GrueneKatze GrueneKatze commented May 12, 2026

Adds available user name fields to the session response and passes them as PostHog person properties during identify.

Changes:

  • Exposes firstName, lastName, and fullName from auth user info
  • Adds optional name fields to the frontend Session type
  • Passes email, first_name, last_name, and name to PostHog identify
  • Avoids sending empty name values

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Session responses now include expanded user profile information: first name, last name, and full name
    • User tracking and analytics systems updated to capture and process comprehensive user identity fields
    • Enhanced user identification capabilities available across the application with complete user profile data

Review Change Stack

Exposes firstName, lastName, and fullName from the Keycloak userinfo
response on /v1/auth/session and forwards them as PostHog person
properties (first_name, last_name, name) on identify, alongside email.
Empty/undefined values are skipped so no "undefined undefined" leaks
into PostHog.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Walkthrough

User name fields (firstName, lastName, fullName) from Keycloak are added to the /session response. The frontend Session type is extended to receive these fields, and PostHog and Sentry identification calls are updated to propagate and enrich them with trimming and computed full name fallbacks.

Changes

User Identity Enrichment in Analytics

Layer / File(s) Summary
Backend session response with name fields
controlplane/src/core/controllers/auth.ts
Auth controller /session endpoint adds firstName, lastName, and fullName from Keycloak user info to the response payload.
Frontend Session type and Sentry tracking
studio/src/components/app-provider.tsx
Session interface extended with optional name fields. Sentry identify call updated to include these fields when setting tracking user context.
PostHog identification with name enrichment
studio/src/lib/track.ts
identify() and setupPosthog() signatures extended to accept optional name fields. PostHog identify call now constructs rich person properties: trims names, computes fallback full name, and passes enriched metadata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • wundergraph/cosmo#2700: Both PRs modify the same identify logic in studio/src/lib/track.ts—this PR adds optional name fields forwarded into PostHog identification while the related PR changes how identify chooses distinct IDs and groups users.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check ✅ Passed The title accurately captures the primary change: adding name properties to PostHog's identify call across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.23%. Comparing base (893ff72) to head (a6cfa93).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
studio/src/lib/track.ts 0.00% 18 Missing ⚠️
controlplane/src/core/controllers/auth.ts 0.00% 3 Missing ⚠️
studio/src/components/app-provider.tsx 0.00% 3 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2857       +/-   ##
===========================================
- Coverage   65.01%   33.23%   -31.78%     
===========================================
  Files         573      632       +59     
  Lines       71938    89149    +17211     
  Branches     4862     5313      +451     
===========================================
- Hits        46767    29627    -17140     
- Misses      23724    59193    +35469     
+ Partials     1447      329     -1118     
Files with missing lines Coverage Δ
controlplane/src/core/controllers/auth.ts 16.25% <0.00%> (-0.32%) ⬇️
studio/src/components/app-provider.tsx 0.00% <0.00%> (ø)
studio/src/lib/track.ts 0.00% <0.00%> (ø)

... and 569 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
studio/src/lib/track.ts (1)

60-67: Consider existing user data consistency.

Users who were already identified with email as their distinct_id (before this PR) will hit this branch and won't receive the new name person properties until their session resets. This appears intentional to avoid redundant identify calls, but means existing users won't immediately benefit from the enhanced tracking data.

You may want to document this behavior or consider whether a one-time re-identification would be valuable for data completeness in PostHog.

🤖 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 `@studio/src/lib/track.ts` around lines 60 - 67, The branch that checks
distinctId === email only syncs the organization via
posthog.group('cosmo_organization', organizationId, {...}) and therefore leaves
person properties (like name) out of sync for already-identified sessions; to
fix, in that branch also update the PostHog person properties for the current
user (e.g., call posthog.identify(email, { name: <userName> }) or
posthog.people.set({ name: <userName> })) using the existing symbols
(distinctId, email, organizationId, organizationName, organizationSlug, plan) so
existing sessions immediately receive the new name/person properties, or
alternatively add a short code comment documenting that existing sessions won’t
be re-identified if you prefer to keep the current behavior.
🤖 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.

Nitpick comments:
In `@studio/src/lib/track.ts`:
- Around line 60-67: The branch that checks distinctId === email only syncs the
organization via posthog.group('cosmo_organization', organizationId, {...}) and
therefore leaves person properties (like name) out of sync for
already-identified sessions; to fix, in that branch also update the PostHog
person properties for the current user (e.g., call posthog.identify(email, {
name: <userName> }) or posthog.people.set({ name: <userName> })) using the
existing symbols (distinctId, email, organizationId, organizationName,
organizationSlug, plan) so existing sessions immediately receive the new
name/person properties, or alternatively add a short code comment documenting
that existing sessions won’t be re-identified if you prefer to keep the current
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57df11c0-25fe-4b6c-913d-f28ee031238f

📥 Commits

Reviewing files that changed from the base of the PR and between 1c7bc8c and a6cfa93.

📒 Files selected for processing (3)
  • controlplane/src/core/controllers/auth.ts
  • studio/src/components/app-provider.tsx
  • studio/src/lib/track.ts

@GrueneKatze GrueneKatze changed the title Add PostHog name properties to identify call feat: add PostHog name properties to identify call May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant