The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update to Json column
Kiran K4769f1dab561
diff --git a/apps/web/app/api/track/click/route.ts b/apps/web/app/api/track/click/route.tsindex 163d2ea4d7..421c1e0192 100644--- a/apps/web/app/api/track/click/route.ts+++ b/apps/web/app/api/track/click/route.ts@@ -44,7 +44,7 @@ export const POST = async (req: Request) => {id: string;url: string;projectId: string;- allowedHostnames: string;+ allowedHostnames: string[];}>("SELECT Link.id, Link.url, projectId, allowedHostnames FROM Link LEFT JOIN Project ON Link.projectId = Project.id WHERE domain = ? AND `key` = ?",[domain, punyEncode(decodeURIComponent(key))],@@ -60,8 +60,9 @@ export const POST = async (req: Request) => {});}- if (link.allowedHostnames) {- const allowedHostnames = link.allowedHostnames.split(" ");+ const allowedHostnames = link.allowedHostnames;++ if (allowedHostnames && allowedHostnames.length > 0) {const source = req.headers.get("referer") || req.headers.get("origin");const sourceUrl = source ? new URL(source) : null;const hostname = sourceUrl?.hostname.replace(/^www\./, "");diff --git a/apps/web/app/api/workspaces/[idOrSlug]/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/route.tsindex 0ff2522b95..03eb6520b5 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/route.ts+++ b/apps/web/app/api/workspaces/[idOrSlug]/route.ts@@ -44,7 +44,6 @@ export const GET = withWorkspace(flags: await getFeatureFlags({workspaceId: workspace.id,}),- allowedHostnames: workspace.allowedHostnames?.split(" "),}),yearInReview: yearInReviews.length > 0 ? yearInReviews[0] : null,},@@ -91,9 +90,7 @@ export const PATCH = withWorkspace(...(slug && { slug }),...(logoUploaded && { logo: logoUploaded.url }),...(conversionEnabled !== undefined && { conversionEnabled }),- ...(allowedHostnames && {- allowedHostnames: allowedHostnames.join(" "),- }),+ ...(allowedHostnames && { allowedHostnames }),},include: {domains: true,diff --git a/apps/web/app/api/workspaces/route.ts b/apps/web/app/api/workspaces/route.tsindex fd2fb81fe8..dbae9b5b7f 100644--- a/apps/web/app/api/workspaces/route.ts+++ b/apps/web/app/api/workspaces/route.ts@@ -44,7 +44,10 @@ export const GET = withSession(async ({ session }) => {});return NextResponse.json(workspaces.map((project) =>- WorkspaceSchema.parse({ ...project, id: `ws_${project.id}` }),+ WorkspaceSchema.parse({+ ...project,+ id: `ws_${project.id}`,+ }),),);});diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsxindex 0dddcc0ed4..462da6061e 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsx@@ -1,9 +1,17 @@+"use client";+import useWorkspace from "@/lib/swr/use-workspace";-import { useState } from "react";+import { useEffect, useState } from "react";export const AllowedHostnames = () => {- const { id } = useWorkspace();- const [hostname, setHostname] = useState("");+ const { id, allowedHostnames } = useWorkspace();+ const [hostname, setHostname] = useState<string>("");++ useEffect(() => {+ if (allowedHostnames) {+ setHostname(allowedHostnames.join("\n"));+ }+ }, [allowedHostnames]);const handleSave = async () => {try {@@ -39,6 +47,8 @@ export const AllowedHostnames = () => {onChange={(e) => setHostname(e.target.value)}placeholder="Enter allowed hostname"className="w-full rounded border p-2"+ rows={5}+ autoFocus/><buttononClick={handleSave}diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex ddc7b88879..3bcb770b12 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -141,6 +141,7 @@ export type ExpandedWorkspaceProps = WorkspaceProps & {name: string;}[];yearInReview: YearInReview | null;+ allowedHostnames: string[];};export type WorkspaceWithUsers = Omit<WorkspaceProps, "domains">;diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.tsindex 4f863f2421..851e16ca26 100644--- a/apps/web/lib/zod/schemas/workspaces.ts+++ b/apps/web/lib/zod/schemas/workspaces.ts@@ -107,7 +107,7 @@ export const WorkspaceSchema = z.describe("The miscellaneous key-value store of the workspace."),allowedHostnames: z.array(z.string())- .default([])+ .nullable().describe("Specifies hostnames permitted for client-side click tracking.").openapi({ example: ["dub.sh"] }),})diff --git a/packages/prisma/schema/workspace.prisma b/packages/prisma/schema/workspace.prismaindex 56f6e5837c..83e12702f0 100644--- a/packages/prisma/schema/workspace.prisma+++ b/packages/prisma/schema/workspace.prisma@@ -30,7 +30,7 @@ model Project {referredSignups Int @default(0)store Json? // General key-value store for things like persisting toggles, dismissing popups, etc.- allowedHostnames String?+ allowedHostnames Json?conversionEnabled Boolean @default(false) // Whether to enable conversion tracking for links by defaultwebhookEnabled Boolean @default(false)