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.

small tweaks

Steven Tey39fda57b7447
diff --git a/lib/cron/domains.tsx b/lib/cron/domains.tsx
index 408ccc5bc6..8a956be871 100644
--- a/lib/cron/domains.tsx
+++ b/lib/cron/domains.tsx
@@ -5,8 +5,7 @@ import { log } from "@/lib/utils";
import { removeDomain } from "@/lib/domains";
import prisma from "@/lib/prisma";
import { deleteProjectLinks } from "@/lib/api/links";
-import { redis } from "@/lib/upstash";
-import { getClicks } from "../tinybird";
+import { getClicks } from "@/lib/tinybird";
export const handleDomainUpdates = async (
projectSlug: string,
@@ -44,8 +43,8 @@ export const handleDomainUpdates = async (
if (invalidDays >= 30) {
const clicks = await getClicks({ domain });
+ // only delete if there are no clicks recorded in Tinybird
if (clicks === 0) {
- // only delete if there are no clicks recorded in Tinybird
const ownerEmail = await getProjectOwnerEmail(projectSlug);
return await Promise.all([
prisma.project.delete({
@@ -69,7 +68,7 @@ export const handleDomainUpdates = async (
]);
} else {
return await log(
- `Domain *${domain}* has been invalid for > 30 days but has links, not deleting.`,
+ `Domain *${domain}* has been invalid for > 30 days but has link clicks, not deleting.`,
"cron",
);
}
diff --git a/lib/tinybird.ts b/lib/tinybird.ts
index d6c5fb8b1c..c5ca13f66e 100644
--- a/lib/tinybird.ts
+++ b/lib/tinybird.ts
@@ -16,7 +16,7 @@ export async function recordClick(
const ua = userAgent(req);
const referer = req.headers.get("referer");
- const response = await Promise.allSettled([
+ return await Promise.allSettled([
fetch(
"https://api.us-east.tinybird.co/v0/events?name=click_events&wait=true",
{
@@ -58,8 +58,6 @@ export async function recordClick(
),
]),
]);
- console.log(response);
- return response;
}
export async function getClicks({