Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

SUPPORT SUPERDAY: Lolu#46

Open
jesuloluwao wants to merge 1 commit into
PostHog:mainfrom
jesuloluwao:super-day-lolu/customerio
Open

SUPPORT SUPERDAY: Lolu#46
jesuloluwao wants to merge 1 commit into
PostHog:mainfrom
jesuloluwao:super-day-lolu/customerio

Conversation

@jesuloluwao

Copy link
Copy Markdown

Problem

The Customer.io PostHog plugin currently only sends events when the current event payload contains an email. If a user provides their email in one event but omits it in subsequent events, those later events are dropped or attributed to a separate profile by distinct_id, causing fragmented customer data in Customer.io.

Changes

  • Persist each user’s last known valid email in plugin storage under customer-email/<distinct_id>.
  • In syncCustomerMetadata, capture and validate emails from $set.email and store them; if an event lacks an email, retrieve the stored email.
  • In exportSingleEvent, only skip sending if no email is ever known. Otherwise, use the stored (or current) email as the Customer.io identifier.
  • Updated shouldCustomerBeTracked to rely on the actual presence of an email rather than just a status flag.
  • Added basic email format validation to prevent storing malformed addresses.

Did you write or update any docs for this change?

How did you test this code?

  • Automated tests simulate three scenarios for distinct_id = "user123":
    1. Initial event with email ($set.email = "user@acme.com"): plugin stores email and sends identify/track calls using "user@acme.com".
    2. Subsequent event without email: plugin retrieves stored "user@acme.com" and successfully tracks the event under the same profile.
    3. Email update event ($set.email = "new@acme.com"): plugin validates, updates storage, and all following events use "new@acme.com".
  • Manual testing in a PostHog instance confirmed that once an email is captured, all future events (even those without $set.email) appear under one Customer.io profile.
  • Verified no regression in scenarios where users never provide an email (events continue to be skipped).

@jesuloluwao

Copy link
Copy Markdown
Author

@abigailbramble Please review

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant