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.

Add Slack template for partner.created webhook event

Kiran K83b3f8a481ba
diff --git a/apps/web/lib/integrations/slack/transform.ts b/apps/web/lib/integrations/slack/transform.ts
index 5eb3030140..775adfa0d1 100644
--- a/apps/web/lib/integrations/slack/transform.ts
+++ b/apps/web/lib/integrations/slack/transform.ts
@@ -6,6 +6,7 @@ import { webhookPayloadSchema } from "../../webhook/schemas";
import {
ClickEventWebhookData,
LeadEventWebhookData,
+ PartnerEventWebhookData,
SaleEventWebhookData,
} from "../../webhook/types";
@@ -199,13 +200,47 @@ const createSaleTemplate = ({ data }: { data: SaleEventWebhookData }) => {
};
};
+const createPartnerTemplate = ({ data }: { data: PartnerEventWebhookData }) => {
+ const { name, email, country } = data;
+
+ return {
+ blocks: [
+ {
+ type: "section",
+ text: {
+ type: "mrkdwn",
+ text: `*New partner created* :tada:`,
+ },
+ },
+ {
+ type: "section",
+ fields: [
+ {
+ type: "mrkdwn",
+ text: `*Name*\n${name}`,
+ },
+ {
+ type: "mrkdwn",
+ text: `*Email*\n<mailto:${email}|${email}>`,
+ },
+ {
+ type: "mrkdwn",
+ text: `*Country*\n${country}`,
+ },
+ ],
+ },
+ ],
+ };
+};
+
const slackTemplates: Record<WebhookTrigger, any> = {
"link.created": createLinkTemplate,
"link.updated": createLinkTemplate,
"link.deleted": createLinkTemplate,
+ "link.clicked": clickLinkTemplate,
"lead.created": createLeadTemplate,
"sale.created": createSaleTemplate,
- "link.clicked": clickLinkTemplate,
+ "partner.created": createPartnerTemplate,
};
export const formatEventForSlack = (
diff --git a/apps/web/lib/webhook/types.ts b/apps/web/lib/webhook/types.ts
index 86095f0b04..6fb503a293 100644
--- a/apps/web/lib/webhook/types.ts
+++ b/apps/web/lib/webhook/types.ts
@@ -35,3 +35,5 @@ export type ClickEventWebhookData = z.infer<typeof clickWebhookEventSchema>;
export type LeadEventWebhookData = z.infer<typeof leadWebhookEventSchema>;
export type SaleEventWebhookData = z.infer<typeof saleWebhookEventSchema>;
+
+export type PartnerEventWebhookData = z.infer<typeof PartnerSchema>;