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(data-warehouse): let you retry webhook setup after it fails (#96092)

Tom Owers98f29fa33a80
diff --git a/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.test.tsx b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.test.tsx
new file mode 100644
index 000000000000..0255c619db7e
--- /dev/null
+++ b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.test.tsx
@@ -0,0 +1,48 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+
+import { SourceConfig } from '~/queries/schema/schema-general'
+
+import { WebhookSetupForm } from './WebhookSetupForm'
+
+const FAILED_RESULT = { success: false, webhook_url: 'https://example.com/hook', error: 'Store rejected the request' }
+
+function renderFallback(
+ sourceConfig: Partial<SourceConfig>,
+ onCreateWebhook: () => void = jest.fn(),
+ autoCreationBlockedReason?: string
+): void {
+ render(
+ <WebhookSetupForm
+ sourceName="WooCommerce"
+ sourceConfig={{ name: 'WooCommerce', fields: [], ...sourceConfig } as unknown as SourceConfig}
+ webhookResult={FAILED_RESULT}
+ webhookCreating={false}
+ autoCreationBlockedReason={autoCreationBlockedReason}
+ onCreateWebhook={onCreateWebhook}
+ />
+ )
+}
+
+describe('WebhookSetupForm', () => {
+ afterEach(cleanup)
+
+ it('offers a retry after automatic creation fails', () => {
+ const onCreateWebhook = jest.fn()
+ renderFallback({}, onCreateWebhook)
+
+ fireEvent.click(screen.getByText('Try again'))
+
+ expect(onCreateWebhook).toHaveBeenCalledTimes(1)
+ })
+
+ it.each([
+ ['the source only supports manual setup', { webhookManualOnly: true }, undefined],
+ ['the connection cannot register webhooks', {}, 'This connection cannot manage webhooks.'],
+ ])('offers no retry when %s', (_name, sourceConfig, autoCreationBlockedReason) => {
+ renderFallback(sourceConfig, jest.fn(), autoCreationBlockedReason)
+
+ expect(screen.queryByText('Try again')).not.toBeInTheDocument()
+ })
+})
diff --git a/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx
index 43601a176449..6abacd336b1c 100644
--- a/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/WebhookSetupForm.tsx
@@ -200,10 +200,20 @@ export function WebhookSetupForm({
{autoCreationBlockedReason || webhookResult?.error || 'Could not create the webhook automatically.'}
</LemonBanner>
)}
+ {!manualOnly && (
+ <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.
+ </p>
+ <LemonButton type="secondary" onClick={onCreateWebhook}>
+ Try again
+ </LemonButton>
+ </div>
+ )}
<p>
{manualOnly
? `Copy the URL below and register it as a webhook endpoint in your ${sourceName} app settings.`
- : `You'll need to manually configure the webhook in your ${sourceName} account. Copy the URL below and add it as a webhook endpoint in your ${sourceName} settings.`}
+ : `Copy the URL below and add it as a webhook endpoint in your ${sourceName} settings.`}
</p>
{webhookResult?.webhook_url && <WebhookUrlDisplay url={webhookResult.webhook_url} />}
{sourceConfig?.webhookSetupCaption && (