Skip to content

Commit 470edf7

Browse files
committed
fix(analytics): omit empty workspace_id on workspace-less file downloads
Address Greptile P1: the generic key-based /api/files/download route and the no-workspace markdown-export path emitted file_downloaded with workspace_id:'' creating a phantom '' bucket in PostHog. Make workspace_id optional on the event and omit it when there is no workspace (workspace-scoped routes still pass it).
1 parent 50052ba commit 470edf7

3 files changed

Lines changed: 2 additions & 3 deletions

File tree

apps/sim/app/api/files/download/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
9898
request,
9999
})
100100
captureServerEvent(userId, 'file_downloaded', {
101-
workspace_id: '',
102101
is_bulk: false,
103102
file_count: 1,
104103
})

apps/sim/app/api/files/export/[id]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const GET = withRouteHandler(
9797
userId,
9898
'file_downloaded',
9999
{
100-
workspace_id: record.workspaceId ?? '',
100+
...(record.workspaceId ? { workspace_id: record.workspaceId } : {}),
101101
is_bulk: assetCount > 0,
102102
file_count: 1 + assetCount,
103103
},

apps/sim/lib/posthog/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ export interface PostHogEventMap {
447447
}
448448

449449
file_downloaded: {
450-
workspace_id: string
450+
workspace_id?: string
451451
is_bulk: boolean
452452
file_count: number
453453
}

0 commit comments

Comments
 (0)