Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(clerk): show manual webhook setup instead of a failing create button (#122454)

Tom Owersebf9fa1bf721
diff --git a/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.test.tsx b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.test.tsx
index 046f2b57b3bd..777fd0f6b8db 100644
--- a/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.test.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.test.tsx
@@ -11,13 +11,14 @@ const FAILED_RESULT = { success: false, webhook_url: 'https://example.com/hook',
function renderFallback(
sourceConfig: Partial<SourceConfigResponseApi>,
onCreateWebhook: () => void = jest.fn(),
- autoCreationBlockedReason?: string
+ autoCreationBlockedReason?: string,
+ webhookResult: typeof FAILED_RESULT = FAILED_RESULT
): void {
render(
<WebhookSetupForm
sourceName="WooCommerce"
sourceConfig={{ name: 'WooCommerce', fields: [], ...sourceConfig } as unknown as SourceConfigResponseApi}
- webhookResult={FAILED_RESULT}
+ webhookResult={webhookResult}
webhookCreating={false}
autoCreationBlockedReason={autoCreationBlockedReason}
onCreateWebhook={onCreateWebhook}
@@ -28,10 +29,18 @@ function renderFallback(
describe('WebhookSetupForm', () => {
afterEach(cleanup)
- it('offers a retry after automatic creation fails', () => {
+ it.each([
+ ['automatic creation fails', {}, FAILED_RESULT],
+ [
+ 'a manual-only source gets no webhook URL',
+ { webhookManualOnly: true },
+ { ...FAILED_RESULT, webhook_url: '' },
+ ],
+ ])('offers a retry when %s', (_name, sourceConfig, webhookResult) => {
const onCreateWebhook = jest.fn()
- renderFallback({}, onCreateWebhook)
+ renderFallback(sourceConfig, onCreateWebhook, undefined, webhookResult)
+ expect(screen.getByText(webhookResult.error)).toBeInTheDocument()
fireEvent.click(screen.getByText('Try again'))
expect(onCreateWebhook).toHaveBeenCalledTimes(1)
diff --git a/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx
index f079b46bfc23..82218e4e13bb 100644
--- a/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx
@@ -193,18 +193,26 @@ export function WebhookSetupForm({
)
}
+ // A failed request returns no URL, so even a manual-only source needs the error and a retry.
+ const webhookUrlMissing = !webhookResult?.webhook_url
+
return (
<WebhookSetupCard>
<h3 className="text-lg font-semibold">Manual webhook setup for {sourceName}</h3>
- {(!manualOnly || !!autoCreationBlockedReason) && (
+ {(!manualOnly || !!autoCreationBlockedReason || webhookUrlMissing) && (
<LemonBanner type="warning">
- {autoCreationBlockedReason || webhookResult?.error || 'Could not create the webhook automatically.'}
+ {(webhookUrlMissing && webhookResult?.error) ||
+ autoCreationBlockedReason ||
+ webhookResult?.error ||
+ 'Could not create the webhook automatically.'}
</LemonBanner>
)}
- {!manualOnly && (
+ {(!manualOnly || webhookUrlMissing) && (
<div className="flex flex-col items-start gap-2">
<p className="m-0">
- Automatic setup can fail for a temporary reason. Try again, or set the webhook up by hand below.
+ {manualOnly
+ ? 'PostHog could not generate the webhook URL. Try again to get one.'
+ : 'Automatic setup can fail for a temporary reason. Try again, or set the webhook up by hand below.'}
</p>
<LemonButton type="secondary" onClick={onCreateWebhook}>
Try again
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py
index 3c9485ffa9d3..d999530104d8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py
@@ -204,6 +204,7 @@ The secret key starts with `sk_live_`.
),
],
),
+ webhookManualOnly=True,
webhookSetupCaption="""Webhook sync keeps the users, organizations, and organization memberships tables up to date. Set it up in Clerk:
1. In the [Clerk Dashboard](https://dashboard.clerk.com/), go to **Configure** > **Webhooks** and select **Add Endpoint**.