Skip to content

feat: adopt a session handed over by the widget after a verified email - #185

Open
boehlerlukas wants to merge 1 commit into
masterfrom
feat/adopt-session
Open

boehlerlukas wants to merge 1 commit into
masterfrom
feat/adopt-session

Conversation

@boehlerlukas

Copy link
Copy Markdown
Contributor

Why

The new "Verify email" workflow step (GleapSDK/Server#2385, GleapSDK/Messenger-App#263) can move a guest's conversation to the existing contact with that email. The widget must then continue as that contact, and the switch has to survive a reload.

What

  • GleapSession.adoptSession({gleapId, gleapHash}):
    • Calls POST /sessions with those headers. The server only returns the session when the hash matches.
    • On success it switches with validateSession, so the session is stored like any other and the frame gets the update, and bumps contactVersion so an older in-flight answer can't switch back.
    • Ignored while the app identifies its own user (lastIdentify.userId) or when it's already that session.
  • GleapFrameManager:
    • Handles adopt-session, and only from the Messenger frame (never banners).
    • session-update now carries capabilities: { adoptSession: true }, so the widget knows it can ask.

Native SDKs (iOS/Android) don't have this yet. There the widget falls back to switching for the current view only.

Verification

  • npm test 571 pass; npm run build compiles. Build output reverted; the release build produces it.
  • The full browser round trip with the live server isn't done yet.

🤖 Generated with Claude Code

The Messenger's "Verify email" step can move a conversation to the contact
with that email. The widget then posts `adopt-session {gleapId, gleapHash}`;
the SDK checks it with POST /sessions and switches (stored like any session).
Only the Messenger frame may send it, never while the app identifies its own
user. `session-update` announces `capabilities.adoptSession`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant