The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fix link filtering by tag (single or multiple tags)
Tim Wilson673a975ea059
diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.tsindex e65165e6c8..390290e0f3 100644--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@ -22,7 +22,8 @@ export const GET = withAuth(async ({ headers, searchParams, project }) => {const response = await getLinksForProject({projectId: project.id,domain,- tagIds: (tagIds ?? []).concat(tagId ?? []),+ tagId,+ tagIds,search,sort,page,diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.tsindex 4b09e3195d..bd1600acc7 100644--- a/apps/web/lib/api/links.ts+++ b/apps/web/lib/api/links.ts@@ -32,6 +32,7 @@ import { getLinkViaEdge } from "../planetscale";export async function getLinksForProject({projectId,domain,+ tagId,tagIds,search,sort = "createdAt",@@ -41,6 +42,7 @@ export async function getLinksForProject({}: {projectId: string;domain?: string;+ tagId?: string;tagIds?: string[];search?: string;sort?: "createdAt" | "clicks" | "lastClicked"; // descending for all@@ -48,6 +50,8 @@ export async function getLinksForProject({userId?: string | null;showArchived?: boolean;}): Promise<LinkProps[]> {+ const combinedTagIds = combineTagIds({ tagId, tagIds });+const links = await prisma.link.findMany({where: {projectId,@@ -63,7 +67,9 @@ export async function getLinksForProject({},],}),- ...(tagIds?.length && { tags: { some: { id: { in: tagIds } } } }),+ ...(combinedTagIds?.length && {+ tags: { some: { tagId: { in: combinedTagIds } } },+ }),...(userId && { userId }),},include: {