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.

use isMachine

Kiran K3062b3e16c01
diff --git a/apps/web/app/api/tokens/[id]/route.ts b/apps/web/app/api/tokens/[id]/route.ts
index 13984982d7..1871834bfa 100644
--- a/apps/web/app/api/tokens/[id]/route.ts
+++ b/apps/web/app/api/tokens/[id]/route.ts
@@ -25,7 +25,7 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
id: true,
name: true,
image: true,
- isBot: true,
+ isMachine: true,
},
},
},
@@ -66,7 +66,7 @@ export const PATCH = withWorkspace(async ({ workspace, params, req }) => {
id: true,
name: true,
image: true,
- isBot: true,
+ isMachine: true,
},
},
},
@@ -87,7 +87,7 @@ export const DELETE = withWorkspace(async ({ workspace, params }) => {
user: {
select: {
id: true,
- isBot: true,
+ isMachine: true,
},
},
},
@@ -95,7 +95,7 @@ export const DELETE = withWorkspace(async ({ workspace, params }) => {
// If the user is a service account, delete the user as well
// It is one-to-one relationship between service account and token
- if (token.user.isBot) {
+ if (token.user.isMachine) {
await prisma.user.delete({
where: {
id: token.user.id,
diff --git a/apps/web/app/api/tokens/route.ts b/apps/web/app/api/tokens/route.ts
index ab0b4d298e..41d64f05cc 100644
--- a/apps/web/app/api/tokens/route.ts
+++ b/apps/web/app/api/tokens/route.ts
@@ -11,18 +11,18 @@ import { NextResponse } from "next/server";
// POST /api/tokens – create a new token for a workspace
export const POST = withWorkspace(async ({ req, session, workspace }) => {
- const { name, isBot, scopes } = createTokenSchema.parse(
+ const { name, isMachine, scopes } = createTokenSchema.parse(
await parseRequestBody(req),
);
- let botUser: User | null = null;
+ let machineUser: User | null = null;
// Create service account
- if (isBot) {
- botUser = await prisma.user.create({
+ if (isMachine) {
+ machineUser = await prisma.user.create({
data: {
name,
- isBot: true,
+ isMachine: true,
},
});
}
@@ -37,7 +37,7 @@ export const POST = withWorkspace(async ({ req, session, workspace }) => {
name,
hashedKey,
partialKey,
- userId: botUser ? botUser.id : session.user.id,
+ userId: machineUser ? machineUser.id : session.user.id,
projectId: workspace.id,
scopes: scopes ? scopes.join(" ") : null,
},
@@ -76,7 +76,7 @@ export const GET = withWorkspace(async ({ workspace }) => {
id: true,
name: true,
image: true,
- isBot: true,
+ isMachine: true,
},
},
},
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts
index 39cd24e4b3..95022051d6 100644
--- a/apps/web/lib/middleware/link.ts
+++ b/apps/web/lib/middleware/link.ts
@@ -182,13 +182,13 @@ export default async function LinkMiddleware(
);
}
- const isBot = detectBot(req);
+ const isMachine = detectBot(req);
const { country } =
process.env.VERCEL === "1" && req.geo ? req.geo : LOCALHOST_GEO_DATA;
// rewrite to proxy page (/proxy/[domain]/[key]) if it's a bot and proxy is enabled
- if (isBot && proxy) {
+ if (isMachine && proxy) {
return NextResponse.rewrite(
new URL(`/proxy/${domain}/${encodeURIComponent(key)}`, req.url),
{
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.ts
index ce07f7a70b..cb996351a3 100644
--- a/apps/web/lib/tinybird/record-click.ts
+++ b/apps/web/lib/tinybird/record-click.ts
@@ -28,8 +28,8 @@ export async function recordClick({
url?: string;
root?: boolean;
}) {
- const isBot = detectBot(req);
- if (isBot) {
+ const isMachine = detectBot(req);
+ if (isMachine) {
return null; // don't record clicks from bots
}
const isQr = detectQr(req);
@@ -85,7 +85,7 @@ export async function recordClick({
os_version: ua.os.version || "Unknown",
cpu_architecture: ua.cpu?.architecture || "Unknown",
ua: ua.ua || "Unknown",
- bot: ua.isBot,
+ bot: ua.isMachine,
qr: isQr,
referer: referer
? getDomainWithoutWWW(referer) || "(direct)"
diff --git a/apps/web/lib/zod/schemas/token.ts b/apps/web/lib/zod/schemas/token.ts
index a999da5360..f561427f08 100644
--- a/apps/web/lib/zod/schemas/token.ts
+++ b/apps/web/lib/zod/schemas/token.ts
@@ -9,7 +9,7 @@ export const createTokenSchema = z.object({
})
.min(1)
.max(50),
- isBot: z.boolean().optional().default(false),
+ isMachine: z.boolean().optional().default(false),
scopes: z.array(z.enum(scopes)).optional(),
});
@@ -35,6 +35,6 @@ export const tokenSchema = z.object({
user: z.object({
id: z.string(),
name: z.string().nullable(),
- isBot: z.boolean(),
+ isMachine: z.boolean(),
}),
});
diff --git a/apps/web/prisma/schema.prisma b/apps/web/prisma/schema.prisma
index ff3b82c5b0..ed9ac623dd 100644
--- a/apps/web/prisma/schema.prisma
+++ b/apps/web/prisma/schema.prisma
@@ -18,7 +18,7 @@ model User {
email String? @unique
emailVerified DateTime?
image String?
- isBot Boolean @default(false)
+ isMachine Boolean @default(false)
accounts Account[]
sessions Session[]
diff --git a/apps/web/ui/charts/x-axis.tsx b/apps/web/ui/charts/x-axis.tsx
index 71df0e333f..b34938d059 100644
--- a/apps/web/ui/charts/x-axis.tsx
+++ b/apps/web/ui/charts/x-axis.tsx
@@ -1,4 +1,4 @@
-import { AxisBottom } from "@visx/axis";
+import { AxisMachinetom } from "@visx/axis";
import { Group } from "@visx/group";
import { Line } from "@visx/shape";
import { useMemo } from "react";
@@ -54,7 +54,7 @@ export default function XAxis({
return (
<>
- <AxisBottom
+ <AxisMachinetom
left={margin.left}
top={margin.top + height}
scale={xScale}