Skip to content

feat: forward analytics identifiers on session creation - #23

Merged
kolchinski merged 1 commit into
mainfrom
feat/session-analytics
Aug 18, 2026
Merged

kolchinski merged 1 commit into
mainfrom
feat/session-analytics

Conversation

@kolchinski

Copy link
Copy Markdown
Member

Adds an optional analytics?: () => WidgetAnalyticsContext | undefined option (hook + component + mount). When the host provides it, the widget reads the visitor's current analytics distinct id and session-replay URL at connect time and forwards them as analytics_distinct_id / analytics_replay_url in the POST /widget/session body, so the platform can join demo calls to the visitor's analytics session.

  • Read at call time via a getter (not static props): replay URLs and distinct ids typically arrive after mount, and connect() runs on a user click when they exist.
  • Both body keys are conditional — absent when the host doesn't opt in, so existing embeds send byte-identical requests.
  • Server side (POST /v1/widget/session) ignores unknown keys today and gains storage/emission in autophonix/thunderphone PR "feat(analytics): cross-tag replay+posthog sessions" — safe to ship in either order.

Verification: npm run lint (tsc) clean, vitest 8/8 (new exact-body test for the analytics fields), tsup build clean.

🤖 Generated with Claude Code

Hosts can pass an analytics() getter returning the visitor's current
analytics distinct id and session-replay URL; both are read at connect
time (they typically arrive after mount) and forwarded as
analytics_distinct_id / analytics_replay_url on POST /widget/session so
the platform can join demo calls to the visitor's analytics session.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kolchinski
kolchinski requested a review from alec-bell August 18, 2026 03:57
@kolchinski
kolchinski merged commit 8fdba41 into main Aug 18, 2026
1 check passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants