The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
small updates to constants
Steven Teyd9bd99f6eb27
diff --git a/apps/web/lib/embed/constants.ts b/apps/web/lib/embed/constants.tsindex 71108b5139..2de20843e7 100644--- a/apps/web/lib/embed/constants.ts+++ b/apps/web/lib/embed/constants.ts@@ -1,6 +1,6 @@// Embed public tokenexport const EMBED_PUBLIC_TOKEN_PREFIX = "dub_embed_";-export const PARTNER_LINKS_LIMIT = 5;+export const PARTNER_LINKS_LIMIT = 10;export const EMBED_PUBLIC_TOKEN_EXPIRY = 3 * 60 * 60; // 3 hoursdiff --git a/apps/web/lib/zod/schemas/misc.ts b/apps/web/lib/zod/schemas/misc.tsindex 6f84df6f5a..5cc015a2a1 100644--- a/apps/web/lib/zod/schemas/misc.ts+++ b/apps/web/lib/zod/schemas/misc.ts@@ -3,7 +3,7 @@ import z from "@/lib/zod";import { R2_URL } from "@dub/utils";import { fileTypeFromBuffer } from "file-type";-export const RECURRING_MAX_DURATIONS = [0, 3, 6, 12, 18, 24];+export const RECURRING_MAX_DURATIONS = [0, 3, 6, 12, 18, 24, 36];export const planSchema = z.enum(plans).describe("The plan of the workspace.");diff --git a/apps/web/scripts/analyze-link-webhooks.ts b/apps/web/scripts/analyze-link-webhooks.tsnew file mode 100644index 0000000000..06123d2f88--- /dev/null+++ b/apps/web/scripts/analyze-link-webhooks.ts@@ -0,0 +1,42 @@+import { prisma } from "@dub/prisma";+import "dotenv-flow/config";++/*++ One time script to analyze links that are associated with multiple webhooks.++ Also analyze projects that those links belong to.++*/++async function main() {+ const linkWebhooks = await prisma.linkWebhook.groupBy({+ by: ["linkId"],+ _count: true,+ });++ // order by _count desc+ const sortedLinkWebhooks = linkWebhooks+ .filter((l) => l._count > 1)+ .sort((a, b) => b._count - a._count);++ console.table(sortedLinkWebhooks);+ console.log(+ `Found ${sortedLinkWebhooks.length} links with multiple webhooks`,+ );++ const links = await prisma.link.groupBy({+ by: ["projectId"],+ where: {+ id: {+ in: sortedLinkWebhooks.map((l) => l.linkId),+ },+ },+ _count: true,+ });++ console.table(links);+ console.log(`Found ${links.length} projects with multiple links webhooks`);+}++main();diff --git a/apps/web/scripts/sitemap-importer.ts b/apps/web/scripts/sitemap-importer.tsindex a028cfd164..7747fea748 100644--- a/apps/web/scripts/sitemap-importer.ts+++ b/apps/web/scripts/sitemap-importer.ts@@ -1,4 +1,5 @@import { createId } from "@/lib/api/create-id";+import { prisma } from "@dub/prisma";import "dotenv-flow/config";import { XMLParser } from "fast-xml-parser";import { bulkCreateLinks } from "../lib/api/links";@@ -11,9 +12,15 @@ async function fetchSitemap(url: string) {return result.urlset.url.map((entry: { loc: string }) => entry.loc);}+const sitemapUrl = "https://dub.co/sitemap.xml";+const domain = "site.dub.co";+const projectId = "xxx";+const userId = "xxx";+const folderId = "xxx";+async function main() {// Fetch and parse sitemap- const sitemapUrls = await fetchSitemap("https://domain.com/sitemap.xml");+ const sitemapUrls = await fetchSitemap(sitemapUrl);// Filter out homepage and invalid URLsconst validUrls = sitemapUrls@@ -25,22 +32,35 @@ async function main() {}return {id: createId({ prefix: "link_" }),- domain: "site.domain.com",+ domain,key,url,trackConversion: true,- projectId: "xxx",- userId: "xxx",- folderId: "xxx",+ projectId,+ userId,+ folderId,};}).slice(0, 1000);- console.table(validUrls);- console.log(`Found ${validUrls.length} valid URLs to process`);+ const existingLinks = await prisma.link.findMany({+ where: {+ domain,+ key: {+ in: validUrls.map((link) => link.key),+ },+ },+ });++ const linksToCreate = validUrls.filter(+ (link) => !existingLinks.some((l) => l.key === link.key),+ );++ console.table(linksToCreate);+ console.log(`Found ${linksToCreate.length} links to create`);const res = await bulkCreateLinks({- links: validUrls,+ links: linksToCreate,skipRedisCache: true,});console.log(`Created ${res.length} links`);