Skip to content

fix: route Request Created to Customer.io via identified profile to stop email-less profiles [INS-2678]#10019

Open
pavkout wants to merge 3 commits into
Kong:developfrom
pavkout:INS-2678
Open

fix: route Request Created to Customer.io via identified profile to stop email-less profiles [INS-2678]#10019
pavkout wants to merge 3 commits into
Kong:developfrom
pavkout:INS-2678

Conversation

@pavkout

@pavkout pavkout commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Problem

The Request Created event was wired through Segment → Customer.io as a destination.
This created several thousand Customer.io profiles in a few hours, the vast majority
without an email. We pay per profile in Customer.io, so this is costly garbage.

Root cause

The app has two separate analytics pipelines keyed by different identifiers:

  • Segment (main/analytics.ts): only ever calls track() / page() — never
    identify(). Its userId is a SHA-256 hash of the account ID and its
    anonymousId is the device ID. It also fires for not-logged-in users
    (the gate is enableAnalytics || hashedAccountId, and enableAnalytics
    defaults to true).
  • Customer.io browser SDK (use-cio.tsx): the only place an email reaches
    Customer.io, via identify(accountId, { email, ... }), keyed by the raw
    accountId, and only for logged-in users.

So when Segment forwarded Request Created to Customer.io:

  1. Anonymous/not-logged-in users created brand-new email-less profiles (the bulk).
  2. Logged-in users created duplicate profiles keyed by the hash, which never
    reconciles with the raw-accountId email profile.

Fix

Stop relying on the Segment → Customer.io destination and emit Request Created
through the Customer.io browser SDK directly, tied to the already-identified,
email-bearing profile:

  • Added a module-level trackCioEvent() helper in use-cio.tsx that reuses the
    existing global SDK singleton. It no-ops unless a user is identified, so it
    can never create anonymous, email-less profiles.
  • Track identifiedUserId on identify(), and reset() it on logout so events
    aren't misattributed to a previous account on shared machines / account switches.
  • Both Request Created call sites now send to Customer.io directly alongside the
    existing Segment track() (Segment still feeds the warehouse/other destinations).

Follow-ups (outside this repo)

  • Disable the Segment → Customer.io destination for Request Created in the Segment dashboard.
  • Notify Cam before re-enabling anything for testing, and clean up the existing email-less profiles in Customer.io.

Copilot AI review requested due to automatic review settings June 3, 2026 08:11
@pavkout pavkout self-assigned this Jun 3, 2026
@pavkout pavkout requested a review from a team June 3, 2026 08:11

Copilot AI 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.

Pull request overview

Routes the Request Created analytics event to Customer.io via the browser SDK’s already-identified (email-bearing) profile, to prevent creation of anonymous/email-less Customer.io profiles while keeping Segment tracking for warehouse/other destinations.

Changes:

  • Added trackCioEvent() helper in use-cio.tsx to send Customer.io events only when a user is identified.
  • Updated Customer.io identification lifecycle to record/reset the identified user ID and reset on logout.
  • Updated both Request Created clientAction call sites to emit the event to Customer.io directly alongside existing Segment tracking.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/insomnia/src/ui/hooks/use-cio.tsx Adds trackCioEvent and tracks/reset identified user state for Customer.io SDK usage.
packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.new.tsx Sends Request Created to Customer.io directly (in addition to Segment) with shared properties object.
packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.request.new.tsx Sends Request Created to Customer.io directly (in addition to Segment) with shared metrics properties object.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/insomnia/src/ui/hooks/use-cio.tsx
@pavkout pavkout force-pushed the INS-2678 branch 3 times, most recently from 7bb0d2c to c237906 Compare June 3, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants