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.

stash scripts

Steven Tey13e390e13b8a
diff --git a/apps/web/scripts/analyze-domains.ts b/apps/web/scripts/analyze-domains.ts
new file mode 100644
index 0000000000..e34dd1ee2a
--- /dev/null
+++ b/apps/web/scripts/analyze-domains.ts
@@ -0,0 +1,85 @@
+import { prisma } from "@/lib/prisma";
+import "dotenv-flow/config";
+
+async function main() {
+ const totalDomains = await prisma.domain.count({
+ where: {
+ verified: true,
+ },
+ });
+
+ const subdomains = await prisma.domain.count({
+ where: {
+ verified: true,
+ OR: [
+ {
+ slug: {
+ startsWith: "go.",
+ },
+ },
+ {
+ slug: {
+ startsWith: "link.",
+ },
+ },
+ {
+ slug: {
+ startsWith: "links.",
+ },
+ },
+ ],
+ },
+ });
+
+ const tldDomains = await prisma.domain.count({
+ where: {
+ verified: true,
+ OR: [
+ {
+ slug: {
+ endsWith: ".link",
+ },
+ },
+ {
+ slug: {
+ endsWith: ".fyi",
+ },
+ },
+ {
+ slug: {
+ endsWith: ".to",
+ },
+ },
+ ],
+ },
+ });
+
+ const domainProjects = await prisma.domain.findMany({
+ where: {
+ verified: true,
+ },
+ select: {
+ slug: true,
+ project: {
+ select: {
+ slug: true,
+ },
+ },
+ },
+ });
+
+ const domainHacks = domainProjects.filter(
+ (domain) => domain.project?.slug === domain.slug.replace(".", ""),
+ );
+
+ console.table(domainHacks);
+
+ console.log({
+ totalDomains,
+ subdomains,
+ tldDomains,
+ domainHacks: domainHacks.length,
+ });
+}
+
+main();
diff --git a/apps/web/scripts/analyze-utms.ts b/apps/web/scripts/analyze-utms.ts
new file mode 100644
index 0000000000..e7637f2bdb
--- /dev/null
+++ b/apps/web/scripts/analyze-utms.ts
@@ -0,0 +1,34 @@
+import { prisma } from "@/lib/prisma";
+import { truncate } from "@dub/utils";
+import "dotenv-flow/config";
+
+const utmTag = "utm_campaign";
+
+async function main() {
+ const utms = await prisma.link.groupBy({
+ where: {
+ [utmTag]: {
+ not: null,
+ },
+ },
+ by: [utmTag],
+ _count: {
+ [utmTag]: true,
+ },
+ take: 100,
+ orderBy: {
+ _count: {
+ [utmTag]: "desc",
+ },
+ },
+ });
+
+ console.table(
+ utms.map((utm) => ({
+ [utmTag]: truncate(utm[utmTag], 20),
+ count: utm._count[utmTag],
+ })),
+ );
+}
+
+main();