From 0f8419778ca666b4bbfdb63c1f4be9f8ebe54130 Mon Sep 17 00:00:00 2001 From: William Tso Date: Wed, 2 Apr 2025 20:18:08 +0800 Subject: [PATCH] device ana --- app/api/events/devices/route.ts | 11 ++++++++++- lib/analytics.ts | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/api/events/devices/route.ts b/app/api/events/devices/route.ts index 7c90d89..3d4d2b2 100644 --- a/app/api/events/devices/route.ts +++ b/app/api/events/devices/route.ts @@ -6,10 +6,19 @@ export async function GET(request: NextRequest) { try { const searchParams = request.nextUrl.searchParams; + // 获取团队、项目和标签筛选参数 + const teamIds = searchParams.getAll('teamId'); + const projectIds = searchParams.getAll('projectId'); + const tagIds = searchParams.getAll('tagId'); + const data = await getDeviceAnalytics({ startTime: searchParams.get('startTime') || undefined, endTime: searchParams.get('endTime') || undefined, - linkId: searchParams.get('linkId') || undefined + linkId: searchParams.get('linkId') || undefined, + // 添加团队、项目和标签筛选 + teamIds: teamIds.length > 0 ? teamIds : undefined, + projectIds: projectIds.length > 0 ? projectIds : undefined, + tagIds: tagIds.length > 0 ? tagIds : undefined }); const response: ApiResponse = { diff --git a/lib/analytics.ts b/lib/analytics.ts index 132d7a0..0cd55af 100644 --- a/lib/analytics.ts +++ b/lib/analytics.ts @@ -245,6 +245,9 @@ export async function getDeviceAnalytics(params: { startTime?: string; endTime?: string; linkId?: string; + teamIds?: string[]; + projectIds?: string[]; + tagIds?: string[]; }): Promise { const filter = buildFilter(params);