The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
final changes
Steven Teybfa24168b292
diff --git a/apps/web/app/api/cron/links/usage/route.ts b/apps/web/app/api/cron/links/usage/route.tsindex d7169dc4cc..614c23b7da 100644--- a/apps/web/app/api/cron/links/usage/route.ts+++ b/apps/web/app/api/cron/links/usage/route.ts@@ -13,11 +13,11 @@ export async function GET(req: Request) {return new Response("Unauthorized", { status: 401 });}- // get links created in the last 5 minutes+ // get links created in the last 10 minutesconst links = await prisma.link.findMany({where: {createdAt: {- gte: new Date(Date.now() - 5 * 60 * 1000),+ gte: new Date(Date.now() - 10 * 60 * 1000),},},select: {@@ -29,6 +29,13 @@ export async function GET(req: Request) {.map((link) => link.projectId).filter(Boolean) as string[];+ console.log(+ "Links created in the last 10 minutes: ",+ links.length,+ "Workspaces to check: ",+ workspacesToCheck,+ );+const workspaces = await prisma.project.findMany({select: {id: true,diff --git a/apps/web/app/api/cron/links/usage/utils.ts b/apps/web/app/api/cron/links/usage/utils.tsindex 4bc6d5aa24..9fcb1107d6 100644--- a/apps/web/app/api/cron/links/usage/utils.ts+++ b/apps/web/app/api/cron/links/usage/utils.ts@@ -10,7 +10,7 @@ export const sendLinksUsageEmail = async (Project,"id" | "name" | "slug" | "plan" | "linksUsage" | "linksLimit"> & {- sentEmails?: SentEmail[];+ sentEmails: SentEmail[];},) => {const percentage = Math.round(@@ -19,12 +19,13 @@ export const sendLinksUsageEmail = async (// Skip if the workspace is below 80% of the limitif (percentage < 80) {+ console.log(+ `${workspace.slug} is below 80% of the links limit (${percentage}%), skipping...`,+ );return;}- const sentEmails = workspace.sentEmails || [];-- const sentNotification = sentEmails.some(+ const sentNotification = workspace.sentEmails.some((email) =>email.type ===(percentage >= 80 && percentage < 100@@ -34,6 +35,7 @@ export const sendLinksUsageEmail = async (// Skip if the email has already been sentif (sentNotification) {+ console.log(`${workspace.slug} has already been notified, skipping...`);return;}@@ -55,7 +57,7 @@ export const sendLinksUsageEmail = async (await Promise.allSettled([sendLimitEmail({emails,- workspace: workspace as WorkspaceProps,+ workspace: workspace as WorkspaceProps & { sentEmails: SentEmail[] },type:percentage >= 80 && percentage < 100? "firstLinksLimitEmail"