Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/lib/seam/connect-webviews/use-create-connect-webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
SeamError,
} from 'seamapi'

import { useClientSession } from 'lib/seam/client-sessions/use-client-session.js'
import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'

export interface UseCreateConnectWebviewParams {
Expand All @@ -23,6 +24,7 @@ export function useCreateConnectWebview({
UseCreateConnectWebviewMutationParams
> {
const { client } = useSeamClient()
const { clientSession } = useClientSession()

return useMutation<
ConnectWebviewCreateResponse['connect_webview'],
Expand All @@ -33,7 +35,14 @@ export function useCreateConnectWebview({
mutationParams: UseCreateConnectWebviewMutationParams
) => {
if (client === null) throw new NullSeamClientError()
return await client.connectWebviews.create(mutationParams)
return await client.connectWebviews.create({
custom_metadata: {
client_session_id: clientSession?.client_session_id ?? null,
user_identifier_key: clientSession?.user_identifier_key ?? null,
...mutationParams.custom_metadata,
},
...mutationParams,
})
},
onSuccess: ({ url }) => {
if (willNavigateToWebview && url != null) {
Expand Down