The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added observability to cron jobs
Steven Tey878fc2346acb
diff --git a/lib/cron/usage.tsx b/lib/cron/usage.tsxindex a769811fd3..60b4164330 100644--- a/lib/cron/usage.tsx+++ b/lib/cron/usage.tsx@@ -1,7 +1,7 @@import sendMail from "emails";import UsageExceeded from "emails/UsageExceeded";import prisma from "@/lib/prisma";-import { getFirstAndLastDay, log } from "@/lib/utils";+import { log } from "@/lib/utils";import { ProjectProps } from "../types";export const updateUsage = async () => {diff --git a/pages/api/cron/domains.ts b/pages/api/cron/domains.tsindex 3a41f381f7..3ce530929c 100644--- a/pages/api/cron/domains.ts+++ b/pages/api/cron/domains.ts@@ -7,6 +7,7 @@ import {verifyDomain,} from "@/lib/api/domains";import prisma from "@/lib/prisma";+import { log } from "@/lib/utils";/*** Cron to check if domains are verified.@@ -108,6 +109,7 @@ async function handler(_req: NextApiRequest, res: NextApiResponse) {);res.status(200).json(results);} catch (error) {+ await log("Domains cron failed. Error: " + error.message, "cron", true);res.status(500).json({ error: error.message });}}diff --git a/pages/api/cron/usage.ts b/pages/api/cron/usage.tsindex ddaf5f7d81..eb0822ecc1 100644--- a/pages/api/cron/usage.ts+++ b/pages/api/cron/usage.ts@@ -1,6 +1,7 @@import type { NextApiRequest, NextApiResponse } from "next";import { verifySignature } from "@upstash/qstash/nextjs";import { updateUsage } from "@/lib/cron/usage";+import { log } from "@/lib/utils";/*** Cron to update the usage stats of each project.@@ -12,6 +13,7 @@ async function handler(_req: NextApiRequest, res: NextApiResponse) {const results = await updateUsage();res.status(200).json(results);} catch (error) {+ await log("Usage cron failed. Error: " + error.message, "cron", true);res.status(500).json({ error: error.message });}}