Skip to content

Prefix PostHog identify id with "xpro:" for global uniqueness - #4025

Merged
ChristopherChudzicki merged 1 commit into
masterfrom
hq-12601-posthog-xpro-prefix
Jul 30, 2026
Merged

Prefix PostHog identify id with "xpro:" for global uniqueness#4025
ChristopherChudzicki merged 1 commit into
masterfrom
hq-12601-posthog-xpro-prefix

Conversation

@ChristopherChudzicki

@ChristopherChudzicki ChristopherChudzicki commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Part of https://github.com/mitodl/hq/issues/12601 (step 4)

Description (What does it do?)

Changes how xPro identifies posthog users.

  • Previously: identify(pk), like pk=123 user id primary key.
    • We use the same posthog project in mit-learn and xpro, so until now, whether Posthog User 123 was xpro or learn user 123 was entirely dependent on where they went first.
  • Now: Prefixed with xpro:pk

Ideally, this would be the same guid used in Learn and MITxOnline an (maybe, one day, ocw). But xpro isn't hooked up to keycloak, so we can't get the guid.

How can this be tested?

No functional UI change, so this is best verified by manual code review:

  • static/js/components/Header.js: confirm identify is now called with `xpro:${currentUser.id}` instead of the bare id.
  • Unit test added: Header_test.js.

Additional Context

Companion MITxOnline PR for step 3 of the same issue: mitodl/mitxonline#3798

For mitodl/hq#12601

xPro shares its PostHog project with other MIT applications that
identify people by a Keycloak global id, which xPro (no Keycloak)
doesn't have. Prefixing xPro's integer user id keeps it from
colliding with those ids.

@Anas12091101 Anas12091101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Heads up, this isn't a bug, just something to be aware of.

Right now PostHog knows each xPro user by their plain ID (e.g. 123). After this change, the same person becomes xpro:123. PostHog will treat that as a completely new person it won't connect their old activity to their new activity

@ChristopherChudzicki

ChristopherChudzicki commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Right now PostHog knows each xPro user by their plain ID (e.g. 123). After this change, the same person becomes xpro:123. PostHog will treat that as a completely new person it won't connect their old activity to their new activity

This is unfortunately not quite true 😄 Posthog user 123 is one of these two people:

  • Learn user with primary key 123
  • OR xpro user with primary key 123

Both apps used identify(pk) within the same posthog project.

Anyway, that's the reason for this change. Disambiguate the two.

Learn and MITxOnline are both moving to GUIDs, xPro doesn't have access to the GUID, though.

@ChristopherChudzicki
ChristopherChudzicki merged commit 1653d83 into master Jul 30, 2026
9 checks passed
@ChristopherChudzicki
ChristopherChudzicki deleted the hq-12601-posthog-xpro-prefix branch July 30, 2026 19:10
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.

2 participants