Skip to content

Commit

Permalink
chore: 🛂 Add context variables to support typebot
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 18, 2022
1 parent 9b9e0f6 commit 7402ad5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 10 additions & 0 deletions apps/builder/components/shared/SupportBubble.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useTypebot } from 'contexts/TypebotContext'
import { useUser } from 'contexts/UserContext'
import { useRouter } from 'next/router'
import React, { useEffect } from 'react'
import { initBubble } from 'typebot-js'

export const SupportBubble = () => {
const { typebot } = useTypebot()
const { user } = useUser()
const router = useRouter()

useEffect(() => {
Expand All @@ -11,6 +15,12 @@ export const SupportBubble = () => {
viewerHost: process.env.NEXT_PUBLIC_VIEWER_HOST,
backgroundColor: '#ffffff',
button: { color: '#0042DA' },
hiddenVariables: {
'Current URL': window.location.href,
'User ID': user?.id,
Email: user?.email ?? undefined,
'Typebot ID': typebot?.id,
},
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [router])
Expand Down
7 changes: 5 additions & 2 deletions apps/builder/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ const App = ({ Component, pageProps }: AppProps) => {
{typebotId ? (
<TypebotContext typebotId={typebotId}>
<Component />
<SupportBubble />
</TypebotContext>
) : (
<Component {...pageProps} />
<>
<Component {...pageProps} />
<SupportBubble />
</>
)}
<SupportBubble />
</UserContext>
</SessionProvider>
</KBarProvider>
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/services/typebots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export const checkIfPublished = (
) =>
deepEqual(parseBlocksToPublicBlocks(typebot.blocks), publicTypebot.blocks) &&
deepEqual(typebot.settings, publicTypebot.settings) &&
deepEqual(typebot.theme, publicTypebot.theme)
deepEqual(typebot.theme, publicTypebot.theme) &&
deepEqual(typebot.variables, publicTypebot.variables)

export const parseDefaultPublicId = (name: string, id: string) =>
toKebabCase(name) + `-${id?.slice(-7)}`
Expand Down

2 comments on commit 7402ad5

@vercel
Copy link

@vercel vercel bot commented on 7402ad5 Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 7402ad5 Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

app.typebot.io
builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app

Please sign in to comment.