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.

Make Slack upgrade CTA a primary button and add a 10s webhook timeout.

Kiran K9865e36ad2bc
diff --git a/apps/web/app/(ee)/api/cron/usage/utils.ts b/apps/web/app/(ee)/api/cron/usage/utils.ts
index a141605390..8e28ddac28 100644
--- a/apps/web/app/(ee)/api/cron/usage/utils.ts
+++ b/apps/web/app/(ee)/api/cron/usage/utils.ts
@@ -235,7 +235,7 @@ export const updateUsage = async () => {
(email) => email.type === "firstUsageLimitEmail",
);
if (!sentFirstUsageLimitEmail) {
- sendWorkspaceLimitAlert({
+ await sendWorkspaceLimitAlert({
emails,
workspace: workspace as unknown as WorkspaceProps,
type: "firstUsageLimitEmail",
diff --git a/apps/web/lib/cron/send-limit-alert.ts b/apps/web/lib/cron/send-limit-alert.ts
index 05337df7f9..3dac56d0de 100644
--- a/apps/web/lib/cron/send-limit-alert.ts
+++ b/apps/web/lib/cron/send-limit-alert.ts
@@ -59,6 +59,21 @@ export const getSlackWebhooks = async (workspaceIds: string[]) => {
return slackWebhookByWorkspace;
};
+const getUpgradePlanButton = (billingUrl: string) => ({
+ type: "actions",
+ elements: [
+ {
+ type: "button",
+ text: {
+ type: "plain_text",
+ text: "Upgrade your plan",
+ },
+ url: billingUrl,
+ style: "primary",
+ },
+ ],
+});
+
const formatLimitSlackMessage = ({
workspace,
type,
@@ -99,15 +114,7 @@ const formatLimitSlackMessage = ({
},
],
},
- {
- type: "context",
- elements: [
- {
- type: "mrkdwn",
- text: `<${billingUrl}|Upgrade your plan>`,
- },
- ],
- },
+ getUpgradePlanButton(billingUrl),
],
};
}
@@ -145,20 +152,12 @@ const formatLimitSlackMessage = ({
},
],
},
- {
- type: "context",
- elements: [
- {
- type: "mrkdwn",
- text: `<${billingUrl}|Upgrade your plan>`,
- },
- ],
- },
+ getUpgradePlanButton(billingUrl),
],
};
};
-const sendLimitSlackAlert = async ({
+const notifyViaSlack = async ({
workspace,
type,
slackWebhookUrl,
@@ -174,6 +173,7 @@ const sendLimitSlackAlert = async ({
"Content-Type": "application/json",
},
body: JSON.stringify(formatLimitSlackMessage({ workspace, type })),
+ signal: AbortSignal.timeout(10_000),
});
if (!response.ok) {
@@ -234,7 +234,7 @@ export const sendWorkspaceLimitAlert = async ({
...(slackWebhookUrl
? [
- sendLimitSlackAlert({
+ notifyViaSlack({
workspace,
type,
slackWebhookUrl,