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.

Add metadata filtering to analytics & events wip

Kiran Ke8996e91b789
diff --git a/apps/web/app/(ee)/api/events/route.ts b/apps/web/app/(ee)/api/events/route.ts
index efcb8bfa09..04b0b7487d 100644
--- a/apps/web/app/(ee)/api/events/route.ts
+++ b/apps/web/app/(ee)/api/events/route.ts
@@ -10,6 +10,7 @@ import { eventsQuerySchema } from "@/lib/zod/schemas/analytics";
import { Folder, Link } from "@dub/prisma/client";
import { NextResponse } from "next/server";
+// GET /api/events
export const GET = withWorkspace(
async ({ searchParams, workspace, session }) => {
throwIfClicksUsageExceeded(workspace);
diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.ts
index 2098ad20d7..430c079b3c 100644
--- a/apps/web/lib/zod/schemas/analytics.ts
+++ b/apps/web/lib/zod/schemas/analytics.ts
@@ -226,6 +226,13 @@ export const analyticsQuerySchema = z
.describe(
"Filter for root domains. If true, filter for domains only. If false, filter for links only. If undefined, return both.",
),
+ metadata: z
+ .record(z.string(), z.string())
+ .optional()
+ .describe(
+ "Filter by event metadata key-value pairs. Format: key=value. Only available for lead and sale events.",
+ )
+ .openapi({ example: { product: "premium" } }),
})
.merge(utmTagsSchema);