The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
enable webhooks for conversions
Steven Teyc15fb1b3600b
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsxindex 06c8a345c3..b736354af2 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/new/page-client.tsx@@ -12,9 +12,10 @@ export default function NewWebhookPageClient({}: {newSecret: string;}) {- const { slug, flags, role, plan } = useWorkspace();+ const { slug, flags, plan, conversionEnabled } = useWorkspace();- const needsHigherPlan = plan === "free" || plan === "pro";+ const needsHigherPlan =+ (plan === "free" || plan === "pro") && !conversionEnabled;if (!flags?.webhooks) {redirect(`/${slug}/settings`);diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/page-client.tsxindex 175f1c8c68..6558232be6 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/webhooks/page-client.tsx@@ -15,23 +15,31 @@ import useSWR from "swr";export default function WebhooksPageClient() {const router = useRouter();- const workspace = useWorkspace();+ const {+ id: workspaceId,+ slug,+ plan,+ role,+ conversionEnabled,+ flags,+ } = useWorkspace();- if (!workspace.flags?.webhooks) {- redirect(`/${workspace.slug}/settings`);+ if (!flags?.webhooks) {+ redirect(`/${slug}/settings`);}const { data: webhooks, isLoading } = useSWR<WebhookProps[]>(- `/api/webhooks?workspaceId=${workspace.id}`,+ `/api/webhooks?workspaceId=${workspaceId}`,fetcher,);const { error: permissionsError } = clientAccessCheck({action: "webhooks.write",- role: workspace.role,+ role: role,});- const needsHigherPlan = workspace.plan === "free" || workspace.plan === "pro";+ const needsHigherPlan =+ (plan === "free" || plan === "pro") && !conversionEnabled;if (needsHigherPlan) {return (@@ -42,7 +50,7 @@ export default function WebhooksPageClient() {description="Webhooks allow you to receive HTTP requests whenever a specific event (eg: someone clicked your link) occurs in Dub."learnMore="https://d.to/webhooks"buttonText="Upgrade to Business"- buttonLink={`/${workspace.slug}/upgrade`}+ buttonLink={`/${slug}/upgrade`}/></div>);@@ -70,9 +78,7 @@ export default function WebhooksPageClient() {<ButtonclassName="flex h-10 items-center justify-center whitespace-nowrap rounded-lg border px-4 text-sm"text="Add Webhook"- onClick={() =>- router.push(`/${workspace.slug}/settings/webhooks/new`)- }+ onClick={() => router.push(`/${slug}/settings/webhooks/new`)}disabledTooltip={permissionsError}/></div>diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.tsindex 3d3579a009..4b7cf97992 100644--- a/apps/web/lib/auth/workspace.ts+++ b/apps/web/lib/auth/workspace.ts@@ -337,15 +337,12 @@ export const withWorkspace = (const url = new URL(req.url || "", API_DOMAIN);- // TODO:- // We should do plan check for Webhooks API too-// plan checks- // special scenario – /events API is available for conversionEnabled workspaces- // (even if they're on a Pro plan)+ // special scenario – /events and /webhooks API is available for conversionEnabled workspaces (even if they're on a Pro plan)if (!requiredPlan.includes(workspace.plan) &&- url.pathname.includes("/events") &&+ (url.pathname.includes("/events") ||+ url.pathname.includes("/webhooks")) &&!workspace.conversionEnabled) {throw new DubApiError({