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.

Refactor folder filtering in analytics and events endpoints

Kiran Kd75379fdfd35
diff --git a/apps/web/app/api/analytics/dashboard/route.ts b/apps/web/app/api/analytics/dashboard/route.ts
index 1b5d0f1b57..a46cf4edeb 100644
--- a/apps/web/app/api/analytics/dashboard/route.ts
+++ b/apps/web/app/api/analytics/dashboard/route.ts
@@ -13,6 +13,7 @@ import { DUB_DEMO_LINKS, DUB_WORKSPACE_ID, getSearchParams } from "@dub/utils";
import { ipAddress } from "@vercel/functions";
import { NextResponse } from "next/server";
+// GET /api/analytics/dashboard – get analytics for the dashboard
export const GET = async (req: Request) => {
try {
const searchParams = getSearchParams(req.url);
diff --git a/apps/web/app/api/analytics/export/route.ts b/apps/web/app/api/analytics/export/route.ts
index 4dcfac36eb..72d6b19073 100644
--- a/apps/web/app/api/analytics/export/route.ts
+++ b/apps/web/app/api/analytics/export/route.ts
@@ -72,6 +72,7 @@ export const GET = withWorkspace(
...(link && { linkId: link.id }),
event: "clicks",
groupBy: endpoint,
+ folderId: folderId || "",
});
if (!response || response.length === 0) return;
diff --git a/apps/web/app/api/analytics/route.ts b/apps/web/app/api/analytics/route.ts
index 0cee3c2373..b5d2fcb9a0 100644
--- a/apps/web/app/api/analytics/route.ts
+++ b/apps/web/app/api/analytics/route.ts
@@ -125,4 +125,4 @@ export const GET = withWorkspace(
{
requiredPermissions: ["analytics.read"],
},
-);
+);
\ No newline at end of file
diff --git a/apps/web/app/api/events/export/route.ts b/apps/web/app/api/events/export/route.ts
index f3609b6f88..3d6e941672 100644
--- a/apps/web/app/api/events/export/route.ts
+++ b/apps/web/app/api/events/export/route.ts
@@ -84,6 +84,7 @@ export const GET = withWorkspace(
...(link && { linkId: link.id }),
workspaceId: workspace.id,
limit: 100000,
+ folderId: folderId || "",
});
const data = response.map((row) =>
diff --git a/apps/web/app/api/events/route.ts b/apps/web/app/api/events/route.ts
index b832e73512..febc3aad17 100644
--- a/apps/web/app/api/events/route.ts
+++ b/apps/web/app/api/events/route.ts
@@ -89,6 +89,7 @@ export const GET = withWorkspace(
...(link && { linkId: link.id }),
workspaceId: workspace.id,
folderIds,
+ folderId: folderId || "",
});
return NextResponse.json(response);
diff --git a/apps/web/lib/analytics/get-analytics.ts b/apps/web/lib/analytics/get-analytics.ts
index 62afd1b197..d5187dcfa5 100644
--- a/apps/web/lib/analytics/get-analytics.ts
+++ b/apps/web/lib/analytics/get-analytics.ts
@@ -29,7 +29,6 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
timezone = "UTC",
isDemo,
isDeprecatedClicksEndpoint = false,
- folderId,
dataAvailableFrom,
} = params;
@@ -98,7 +97,6 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
eventType: event,
workspaceId,
tagIds,
- folderId: folderId || (workspaceId ? "" : undefined),
qr,
start: startDate.toISOString().replace("T", " ").replace("Z", ""),
end: endDate.toISOString().replace("T", " ").replace("Z", ""),
diff --git a/apps/web/lib/analytics/get-events.ts b/apps/web/lib/analytics/get-events.ts
index 492aa29528..084ca3abf6 100644
--- a/apps/web/lib/analytics/get-events.ts
+++ b/apps/web/lib/analytics/get-events.ts
@@ -37,7 +37,6 @@ export const getEvents = async (params: EventsFilters) => {
isDemo,
order,
sortOrder,
- folderId,
dataAvailableFrom,
} = params;
@@ -89,7 +88,6 @@ export const getEvents = async (params: EventsFilters) => {
offset: (params.page - 1) * params.limit,
start: startDate.toISOString().replace("T", " ").replace("Z", ""),
end: endDate.toISOString().replace("T", " ").replace("Z", ""),
- folderId: folderId || "",
});
const [linksMap, customersMap] = await Promise.all([