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.

Update route.ts

Steven Tey9e23eb6ff742
diff --git a/apps/web/app/api/cron/year-in-review/route.ts b/apps/web/app/api/cron/year-in-review/route.ts
index 66aa813144..041c2cf716 100644
--- a/apps/web/app/api/cron/year-in-review/route.ts
+++ b/apps/web/app/api/cron/year-in-review/route.ts
@@ -57,45 +57,43 @@ export async function POST(req: Request) {
return new Response("No jobs found. Skipping...");
}
- const emailData = yearInReviews
- .flatMap(
- ({ workspace, totalClicks, totalLinks, topCountries, topLinks }) =>
- workspace.users
- .map(({ user }) => {
- if (!user.email) {
- return null;
- }
-
- return {
- workspaceId: workspace.id,
- email: {
- from: "Steven from Dub.co <[email protected]>",
- to: user.email,
- reply_to: "[email protected]",
- subject: "Dub Year in Review 🎊",
- text: "Thank you for your support and here's to another year of your activity on Dub! Here's a look back at your activity in 2024.",
- react: DubWrapped({
- email: user.email,
- workspace: {
- logo: workspace.logo,
- name: workspace.name,
- slug: workspace.slug,
- },
- stats: {
- "Total Links": totalLinks,
- "Total Clicks": totalClicks,
- },
- // @ts-ignore
- topLinks,
- // @ts-ignore
- topCountries,
- }),
- },
- };
- })
- .filter((data) => data !== null),
- )
- .filter((data) => data !== null);
+ const emailData = yearInReviews.flatMap(
+ ({ workspace, totalClicks, totalLinks, topCountries, topLinks }) =>
+ workspace.users
+ .map(({ user }) => {
+ if (!user.email) {
+ return null;
+ }
+
+ return {
+ workspaceId: workspace.id,
+ email: {
+ from: "Steven from Dub.co <[email protected]>",
+ to: user.email,
+ reply_to: "[email protected]",
+ subject: "Dub Year in Review 🎊",
+ text: "Thank you for your support and here's to another year of your activity on Dub! Here's a look back at your activity in 2024.",
+ react: DubWrapped({
+ email: user.email,
+ workspace: {
+ logo: workspace.logo,
+ name: workspace.name,
+ slug: workspace.slug,
+ },
+ stats: {
+ "Total Links": totalLinks,
+ "Total Clicks": totalClicks,
+ },
+ // @ts-ignore
+ topLinks,
+ // @ts-ignore
+ topCountries,
+ }),
+ },
+ };
+ })
+ .filter((data) => data !== null),
+ );
if (emailData.length === 0) {
return new Response("No email data found. Skipping...");
@@ -110,6 +108,7 @@ export async function POST(req: Request) {
console.log(
`πŸ“¨ Recipients:`,
+ // @ts-ignore
batch.map((b) => b.email.to),
);
@@ -118,6 +117,7 @@ export async function POST(req: Request) {
}
const { data, error } = await resend.batch.send(
+ // @ts-ignore
batch.map((b) => b.email),
);