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.

remove accessLevel from top_folders analytics schema

Steven Tey45a227ddfc55
diff --git a/apps/web/lib/analytics/get-analytics.ts b/apps/web/lib/analytics/get-analytics.ts
index 2a4b866890..a5e19cd8a9 100644
--- a/apps/web/lib/analytics/get-analytics.ts
+++ b/apps/web/lib/analytics/get-analytics.ts
@@ -2,6 +2,7 @@ import { combineTagIds } from "@/lib/api/tags/combine-tag-ids";
import { tb } from "@/lib/tinybird";
import { prisma } from "@dub/prisma";
import { linkConstructor, punyEncode } from "@dub/utils";
+import { FolderAccessLevel } from "@prisma/client";
import { decodeKeyIfCaseSensitive } from "../api/links/case-sensitivity";
import { conn } from "../planetscale";
import z from "../zod";
@@ -279,11 +280,17 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
.map((item) => {
const folder = folders.find((f) => f.id === item.groupByField);
if (!folder) return null;
- return analyticsResponse[groupBy].parse({
- ...item,
- folderId: item.groupByField,
- folder,
- });
+ return analyticsResponse.top_folders
+ .extend({
+ folder: analyticsResponse.top_folders.shape.folder.extend({
+ accessLevel: z.nativeEnum(FolderAccessLevel).nullish(),
+ }),
+ })
+ .parse({
+ ...item,
+ folderId: item.groupByField,
+ folder,
+ });
})
.filter((d) => d !== null);
}
diff --git a/apps/web/lib/zod/schemas/analytics-response.ts b/apps/web/lib/zod/schemas/analytics-response.ts
index 9cbdb6301a..11eeef4d51 100644
--- a/apps/web/lib/zod/schemas/analytics-response.ts
+++ b/apps/web/lib/zod/schemas/analytics-response.ts
@@ -1,7 +1,6 @@
import { TRIGGER_TYPES } from "@/lib/analytics/constants";
import z from "@/lib/zod";
import { CONTINENT_CODES } from "@dub/utils";
-import { FolderAccessLevel } from "@prisma/client";
import { LinkTagSchema } from "./tags";
const analyticsTriggersResponse = z
@@ -473,9 +472,6 @@ export const analyticsResponse = {
folder: z.object({
id: z.string().describe("The ID of the folder"),
name: z.string().describe("The name of the folder"),
- accessLevel: z
- .nativeEnum(FolderAccessLevel)
- .describe("The access level of the folder"),
}),
clicks: z.number().describe("The total number of clicks").default(0),
leads: z.number().describe("The total number of leads").default(0),