Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

improve WEBHOOK_TRIGGER_DESCRIPTIONS

Steven Teyf16a2ecd77c7
diff --git a/apps/web/lib/webhook/constants.ts b/apps/web/lib/webhook/constants.ts
index c4d2395429..1cc12e5b0e 100644
--- a/apps/web/lib/webhook/constants.ts
+++ b/apps/web/lib/webhook/constants.ts
@@ -37,21 +37,26 @@ export const WEBHOOK_TRIGGERS = [
] as const;
export const WEBHOOK_TRIGGER_DESCRIPTIONS: Record<WebhookTrigger, string> = {
- "link.created": "Link created",
- "link.updated": "Link updated",
- "link.deleted": "Link deleted",
- "link.clicked": "Link clicked",
- "lead.created": "Lead created",
- "sale.created": "Sale created",
- "partner.application_submitted": "Partner application submitted",
- "partner.enrolled": "Partner enrolled",
- "partner.merged": "Partner accounts merged",
- "commission.created": "Commission created",
- "bounty.created": "Bounty created",
- "bounty.updated": "Bounty updated",
- "payout.confirmed": "Payout confirmed",
- "discount_code.created": "Discount code created",
- "discount_code.deleted": "Discount code deleted",
+ "link.created": "Occurs whenever a link is created",
+ "link.updated": "Occurs whenever a link is updated",
+ "link.deleted": "Occurs whenever a link is deleted",
+ "link.clicked": "Occurs whenever a link is clicked",
+ "lead.created": "Occurs whenever a lead is created",
+ "sale.created": "Occurs whenever a sale is created",
+ "partner.application_submitted":
+ "Occurs whenever a partner submits an application to your program",
+ "partner.enrolled":
+ "Occurs whenever a partner is enrolled in your program (either their application was approved, they accepted your invite, or via the API)",
+ "partner.merged": "Occurs when two partner accounts are merged",
+ "commission.created":
+ "Occurs whenever a commission is created for a partner (clawbacks will also trigger this event with a negative amount)",
+ "bounty.created": "Occurs whenever a bounty is created in your program",
+ "bounty.updated": "Occurs whenever a bounty in your program is updated",
+ "payout.confirmed": "Occurs whenever a payout in your program is confirmed",
+ "discount_code.created":
+ "Occurs whenever a discount code is created for a partner",
+ "discount_code.deleted":
+ "Occurs whenever a discount code for a partner is deleted",
} as const;
export const WEBHOOK_FAILURE_NOTIFY_THRESHOLDS = [5, 10, 15] as const;
diff --git a/apps/web/ui/modals/send-test-webhook-modal.tsx b/apps/web/ui/modals/send-test-webhook-modal.tsx
index cec9ee9f23..2df29f8edf 100644
--- a/apps/web/ui/modals/send-test-webhook-modal.tsx
+++ b/apps/web/ui/modals/send-test-webhook-modal.tsx
@@ -1,7 +1,7 @@
import { sendTestWebhookEvent } from "@/lib/actions/send-test-webhook";
import useWorkspace from "@/lib/swr/use-workspace";
import { WebhookProps } from "@/lib/types";
-import { WEBHOOK_TRIGGER_DESCRIPTIONS } from "@/lib/webhook/constants";
+import { WEBHOOK_TRIGGERS } from "@/lib/webhook/constants";
import type { WebhookTrigger } from "@/lib/webhook/types";
import { Button, Combobox, ComboboxOption, Modal } from "@dub/ui";
import { useAction } from "next-safe-action/hooks";
@@ -38,13 +38,6 @@ function SendTestWebhookModal({
},
});
- const triggers = Object.entries(WEBHOOK_TRIGGER_DESCRIPTIONS).map(
- ([key, value]) => ({
- value: key,
- label: value,
- }),
- );
-
return (
<Modal
showModal={showSendTestWebhookModal}
@@ -77,12 +70,17 @@ function SendTestWebhookModal({
<div className="mt-4">
<Combobox
- options={triggers}
+ options={WEBHOOK_TRIGGERS.map((trigger) => ({
+ value: trigger,
+ label: trigger,
+ }))}
selected={selectedTrigger}
setSelected={setSelectedTrigger}
placeholder="Select a webhook event"
matchTriggerWidth
caret
+ labelProps={{ className: "font-mono text-sm text-neutral-800" }}
+ optionClassName="font-mono"
/>
</div>
</div>
diff --git a/apps/web/ui/webhooks/webhook-trigger-selector.tsx b/apps/web/ui/webhooks/webhook-trigger-selector.tsx
index b1841d1e7b..2d43f05d64 100644
--- a/apps/web/ui/webhooks/webhook-trigger-selector.tsx
+++ b/apps/web/ui/webhooks/webhook-trigger-selector.tsx
@@ -162,10 +162,10 @@ export function WebhookTriggerSelector({
};
return (
- <div className="flex flex-col gap-2">
+ <div className="flex flex-col gap-3">
{availableTriggers.map((trigger) => (
<div key={trigger}>
- <div className="group flex gap-2">
+ <div className="group flex items-start gap-2">
<Checkbox
value={trigger}
id={trigger}
@@ -175,9 +175,17 @@ export function WebhookTriggerSelector({
/>
<label
htmlFor={trigger}
- className="flex select-none items-center gap-2 text-sm text-neutral-600 group-hover:text-neutral-800"
+ className={cn(
+ "flex min-w-0 select-none flex-col",
+ disabled ? "cursor-not-allowed" : "cursor-pointer",
+ )}
>
- {WEBHOOK_TRIGGER_DESCRIPTIONS[trigger]}
+ <span className="font-mono text-sm font-medium leading-5 text-neutral-800 group-hover:text-neutral-900">
+ {trigger}
+ </span>
+ <span className="text-[11px] leading-snug text-neutral-500">
+ {WEBHOOK_TRIGGER_DESCRIPTIONS[trigger]}
+ </span>
</label>
</div>