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 logs

Steven Tey92c3cc3d0331
diff --git a/apps/web/app/(ee)/api/cron/domains/renewal-payments/route.ts b/apps/web/app/(ee)/api/cron/domains/renewal-payments/route.ts
index 38011a714b..a1d00da066 100644
--- a/apps/web/app/(ee)/api/cron/domains/renewal-payments/route.ts
+++ b/apps/web/app/(ee)/api/cron/domains/renewal-payments/route.ts
@@ -29,6 +29,8 @@ export async function GET(req: Request) {
const targetDate = addDays(new Date(), 14);
+ console.log("targetDate", targetDate);
+
// Find all domains expiring in 14 days
const domains = await prisma.registeredDomain.findMany({
where: {
@@ -50,11 +52,16 @@ export async function GET(req: Request) {
});
if (domains.length === 0) {
+ console.log(
+ "No domains found expiring exactly 14 days from today. Skipping...",
+ );
return NextResponse.json(
"No domains found expiring exactly 14 days from today.",
);
}
+ console.table(domains, ["slug", "expiresAt", "renewalFee"]);
+
// Group domains by workspaceId
const groupedByWorkspace = domains.reduce(
(acc, domain) => {
@@ -114,7 +121,7 @@ export async function GET(req: Request) {
});
console.log(
- `Invoice ${invoice.id} created for workspace ${workspace.id} to renew ${domains.length} domains.`,
+ `Invoice ${invoice.id} with total ${invoice.total} created for workspace ${workspace.id} to renew ${domains.length} domains.`,
);
invoices.push(invoice);
@@ -129,7 +136,7 @@ export async function GET(req: Request) {
continue;
}
- await createPaymentIntent({
+ const res = await createPaymentIntent({
stripeId: workspace.stripeId!,
amount: invoice.total,
invoiceId: invoice.id,
@@ -137,6 +144,8 @@ export async function GET(req: Request) {
description: `Domain renewal invoice (${invoice.id})`,
idempotencyKey: `${invoice.id}-${invoice.failedAttempts}`,
});
+
+ console.log(`Payment intent created for invoice ${invoice.id}`, res);
}
return NextResponse.json("OK");
diff --git a/apps/web/app/(ee)/api/cron/domains/renewal-reminders/route.ts b/apps/web/app/(ee)/api/cron/domains/renewal-reminders/route.ts
index 91f24b8d04..2badc86648 100644
--- a/apps/web/app/(ee)/api/cron/domains/renewal-reminders/route.ts
+++ b/apps/web/app/(ee)/api/cron/domains/renewal-reminders/route.ts
@@ -45,6 +45,8 @@ export async function GET(req: Request) {
};
});
+ console.log("targetDates", targetDates);
+
// Find all domains that are eligible for renewal reminders
const domains = await prisma.registeredDomain.findMany({
where: {
@@ -73,6 +75,7 @@ export async function GET(req: Request) {
});
if (domains.length === 0) {
+ console.log("No domains found to send reminders for. Skipping...");
return NextResponse.json("No domains found to send reminders for.");
}
@@ -100,16 +103,12 @@ export async function GET(req: Request) {
},
);
- const reminderDomainsChunks = chunk(reminderDomains, 100);
+ console.table(reminderDomains);
- if (!resend) {
- return NextResponse.json(
- "Resend is not configured, skipping email sending.",
- );
- }
+ const reminderDomainsChunks = chunk(reminderDomains, 100);
for (const reminderDomainsChunk of reminderDomainsChunks) {
- await resend.batch.send(
+ const res = await resend?.batch.send(
reminderDomainsChunk.map(({ workspace, user, domain }) => ({
from: VARIANT_TO_FROM_MAP.notifications,
to: user.email!,
@@ -122,6 +121,7 @@ export async function GET(req: Request) {
}),
})),
);
+ console.log(`Sent ${reminderDomainsChunk.length} emails`, res);
}
return NextResponse.json(reminderDomains);
diff --git a/apps/web/lib/cron/verify-vercel.ts b/apps/web/lib/cron/verify-vercel.ts
index ecb1f93a31..e5417837b5 100644
--- a/apps/web/lib/cron/verify-vercel.ts
+++ b/apps/web/lib/cron/verify-vercel.ts
@@ -13,7 +13,7 @@ export const verifyVercelSignature = async (req: Request) => {
) {
throw new DubApiError({
code: "unauthorized",
- message: "Invalid QStash request signature",
+ message: "Invalid Vercel cron request signature",
});
}
};