Skip to content

Commit

Permalink
feat: 🚩 Add webhook url call on user creation
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 23, 2022
1 parent 953b95d commit 39b0143
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/builder/pages/api/auth/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PrismaClient, Prisma, Invitation, Plan } from 'db'
import { randomUUID } from 'crypto'
import type { Adapter, AdapterUser } from 'next-auth/adapters'
import cuid from 'cuid'
import { got } from 'got'

export function CustomAdapter(p: PrismaClient): Adapter {
return {
Expand All @@ -19,6 +20,10 @@ export function CustomAdapter(p: PrismaClient): Adapter {
plan: process.env.ADMIN_EMAIL === data.email ? Plan.PRO : Plan.FREE,
},
})
if (process.env.USER_CREATED_WEBHOOK_URL)
await got.post(process.env.USER_CREATED_WEBHOOK_URL, {
json: data,
})
if (invitations.length > 0)
await convertInvitationsToCollaborations(p, user, invitations)
return createdUser
Expand Down
9 changes: 9 additions & 0 deletions apps/docs/docs/self-hosting/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,12 @@ These can also be added to the `viewer` environment
| SLEEKPLAN_SSO_KEY | -- | Sleekplan SSO key used to automatically authenticate a user in Sleekplan |

</p></details>

<details><summary>Webhooks</summary>
<p>

| Parameter | Default | Description |
| ------------------------ | ------- | --------------------------------------------------------------------------------------------- |
| USER_CREATED_WEBHOOK_URL | -- | Webhook URL called whenever a new user is created (used for importing a new SendGrid contact) |

</p></details>

4 comments on commit 39b0143

@vercel
Copy link

@vercel vercel bot commented on 39b0143 Mar 23, 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:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 39b0143 Mar 23, 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 39b0143 Mar 23, 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

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

Please sign in to comment.