Skip to content

fix(desktop): relay Brain analytics with Desktop identity - #7356

Open
zjy365 wants to merge 1 commit into
labring:mainfrom
zjy365:codex/relay-brain-analytics
Open

zjy365 wants to merge 1 commit into
labring:mainfrom
zjy365:codex/relay-brain-analytics

Conversation

@zjy365

@zjy365 zjy365 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

After Desktop emits module_open, embedded Brain events use a different analytics context and cannot read Desktop's persisted UUID. Deployment creation can be blocked by GTM's missing-identity rule, and the current GTM whitelist omits onboarding/cancellation events.

Expose an optional analytics capability through the existing host-config API and accept Brain events through the existing SDK event bus. Event callbacks receive browser-provided source/origin metadata; the relay accepts only the running Brain iframe and its installed origin. GTM-covered events enter the parent dataLayer once, inheriting the canonical Desktop UUID and attribution. Events absent from the GTM whitelist use the parent Rybbit SDK once, identifying with that same UUID and respecting the primitive/2KB property contract. Direct delivery waits for asynchronous SDK loading; event fields are allowlisted.

Companion Brain PR: labring/brain#359. Deploy this Desktop change first for immediate continuity. Either PR remains independently mergeable; Brain negotiates capability and keeps its previous transport on older Desktop deployments. Existing website token-login tracking from main is retained.

Validation:

  • 19 focused tests passed: pnpm test:ci src/__tests__/unit/utils/brain-analytics.test.ts src/__tests__/unit/utils/brain-analytics-sdk.test.ts src/__tests__/unit/utils/gtm.test.ts src/__tests__/unit/utils/marketing-attribution.test.ts from frontend/desktop.
  • pnpm exec tsc --noEmit --incremental false from frontend/desktop.
  • pnpm build from frontend/packages/client-sdk.
  • Coverage includes real SDK sender propagation/acknowledgement, iframe/origin rejection, one-time GTM/Rybbit dispatch, UUID identity, late script loading, byte limits, and exclusion of credentials/feedback text.

This branch has not been deployed

No deployments
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