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.

small tweaks

Kiran K5918f65221b7
diff --git a/apps/web/app/api/analytics/export/route.ts b/apps/web/app/api/analytics/export/route.ts
index 5e0e7da216..518f4b9d3d 100644
--- a/apps/web/app/api/analytics/export/route.ts
+++ b/apps/web/app/api/analytics/export/route.ts
@@ -76,7 +76,7 @@ export const GET = withWorkspace(
...(link && { linkId: link.id }),
event: "clicks",
groupBy: endpoint,
- folderIds: folders.map((folder) => folder.id),
+ allowedFolderIds: folders.map((folder) => folder.id),
});
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 a22e5d090c..5d44187eeb 100644
--- a/apps/web/app/api/analytics/route.ts
+++ b/apps/web/app/api/analytics/route.ts
@@ -108,7 +108,7 @@ export const GET = withWorkspace(
...(link && { linkId: link.id }),
workspaceId: workspace.id,
isDeprecatedClicksEndpoint,
- folderIds: folders.map((folder) => folder.id),
+ allowedFolderIds: folders.map((folder) => folder.id),
});
return NextResponse.json(response);
diff --git a/apps/web/app/api/events/export/route.ts b/apps/web/app/api/events/export/route.ts
index 71bd0598b2..b7c30bc389 100644
--- a/apps/web/app/api/events/export/route.ts
+++ b/apps/web/app/api/events/export/route.ts
@@ -101,7 +101,7 @@ export const GET = withWorkspace(
...(link && { linkId: link.id }),
workspaceId: workspace.id,
limit: 100000,
- folderIds: folders.map((folder) => folder.id),
+ allowedFolderIds: folders.map((folder) => folder.id),
});
const data = response.map((row) =>
diff --git a/apps/web/app/api/events/route.ts b/apps/web/app/api/events/route.ts
index c8f2f69e62..c44e51f236 100644
--- a/apps/web/app/api/events/route.ts
+++ b/apps/web/app/api/events/route.ts
@@ -80,7 +80,7 @@ export const GET = withWorkspace(
event,
...(link && { linkId: link.id }),
workspaceId: workspace.id,
- folderIds: folders.map((folder) => folder.id),
+ allowedFolderIds: folders.map((folder) => folder.id),
});
return NextResponse.json(response);
diff --git a/apps/web/app/api/links/count/route.ts b/apps/web/app/api/links/count/route.ts
index 5d06c76317..bc7a247541 100644
--- a/apps/web/app/api/links/count/route.ts
+++ b/apps/web/app/api/links/count/route.ts
@@ -33,7 +33,7 @@ export const GET = withWorkspace(
const count = await getLinksCount({
searchParams: params,
workspaceId: workspace.id,
- folderIds: folders.map((folder) => folder.id),
+ allowedFolderIds: folders.map((folder) => folder.id),
});
return NextResponse.json(count, {
diff --git a/apps/web/lib/analytics/get-analytics.ts b/apps/web/lib/analytics/get-analytics.ts
index f313009ec5..4c3bf11674 100644
--- a/apps/web/lib/analytics/get-analytics.ts
+++ b/apps/web/lib/analytics/get-analytics.ts
@@ -22,9 +22,14 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
timezone = "UTC",
isDemo,
isDeprecatedClicksEndpoint = false,
- folderIds,
+ allowedFolderIds,
+ folderId
} = params;
+ if (folderId) {
+ allowedFolderIds = [folderId];
+ }
+
// get all-time clicks count if:
// 1. type is count
// 2. linkId is defined
@@ -86,7 +91,7 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
end: end.toISOString().replace("T", " ").replace("Z", ""),
granularity,
timezone,
- folderIds,
+ folderIds: allowedFolderIds,
});
if (groupBy === "count") {
@@ -112,7 +117,7 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
// This might be unnecessary because links are filtered by folderIds in the Tinybird pipe
// Remove after making sure TB works as expected
AND: {
- OR: [{ folderId: { in: folderIds } }, { folderId: null }],
+ OR: [{ folderId: { in: allowedFolderIds } }, { folderId: null }],
},
},
select: {
diff --git a/apps/web/lib/analytics/get-events.ts b/apps/web/lib/analytics/get-events.ts
index a70873f6e0..d0bdb21e68 100644
--- a/apps/web/lib/analytics/get-events.ts
+++ b/apps/web/lib/analytics/get-events.ts
@@ -31,9 +31,14 @@ export const getEvents = async (params: EventsFilters) => {
start,
end,
isDemo,
- folderIds,
+ folderId,
+ allowedFolderIds,
} = params;
+ if (folderId) {
+ allowedFolderIds = [folderId];
+ }
+
if (start) {
start = new Date(start);
end = end ? new Date(end) : new Date(Date.now());
@@ -66,7 +71,7 @@ export const getEvents = async (params: EventsFilters) => {
offset: (params.page - 1) * params.limit,
start: start.toISOString().replace("T", " ").replace("Z", ""),
end: end.toISOString().replace("T", " ").replace("Z", ""),
- folderIds,
+ folderIds: allowedFolderIds,
});
const [linksMap, customersMap] = await Promise.all([
diff --git a/apps/web/lib/analytics/types.ts b/apps/web/lib/analytics/types.ts
index 890419feec..d7083549ec 100644
--- a/apps/web/lib/analytics/types.ts
+++ b/apps/web/lib/analytics/types.ts
@@ -34,11 +34,11 @@ export type AnalyticsFilters = z.infer<typeof analyticsQuerySchema> & {
workspaceId?: string;
isDemo?: boolean;
isDeprecatedClicksEndpoint?: boolean;
- folderIds?: string[];
+ allowedFolderIds?: string[];
};
export type EventsFilters = z.infer<typeof eventsQuerySchema> & {
workspaceId?: string;
isDemo?: boolean;
- folderIds?: string[];
+ allowedFolderIds?: string[];
};
diff --git a/apps/web/lib/api/links/get-links-count.ts b/apps/web/lib/api/links/get-links-count.ts
index c6f1cae3a8..7c8b66998c 100644
--- a/apps/web/lib/api/links/get-links-count.ts
+++ b/apps/web/lib/api/links/get-links-count.ts
@@ -6,11 +6,11 @@ import { combineTagIds } from "./utils";
export async function getLinksCount({
searchParams,
workspaceId,
- folderIds,
+ allowedFolderIds,
}: {
searchParams: z.infer<typeof getLinksCountQuerySchema>;
workspaceId: string;
- folderIds?: string[];
+ allowedFolderIds: string[];
}) {
const {
groupBy,
@@ -57,7 +57,7 @@ export async function getLinksCount({
}),
AND: {
- OR: [{ folderId: { in: folderIds } }, { folderId: null }],
+ OR: [{ folderId: { in: allowedFolderIds } }, { folderId: null }],
},
};
@@ -101,7 +101,7 @@ export async function getLinksCount({
: {}),
AND: {
- OR: [{ folderId: { in: folderIds } }, { folderId: null }],
+ OR: [{ folderId: { in: allowedFolderIds } }, { folderId: null }],
},
};
diff --git a/apps/web/ui/folders/folder-switcher.tsx b/apps/web/ui/folders/folder-switcher.tsx
index 4277cac19d..2fb7836efe 100644
--- a/apps/web/ui/folders/folder-switcher.tsx
+++ b/apps/web/ui/folders/folder-switcher.tsx
@@ -1,6 +1,7 @@
import { Folder } from "@/lib/folder/types";
import { useCheckFolderPermission } from "@/lib/swr/use-folder-permissions";
import useFolders from "@/lib/swr/use-folders";
+import useWorkspace from "@/lib/swr/use-workspace";
import {
Button,
PenWriting,
@@ -18,7 +19,7 @@ import { useCallback, useEffect, useState } from "react";
import { useAddFolderModal } from "../modals/add-folder-modal";
import { useDeleteFolderModal } from "../modals/delete-folder-modal";
import { useRenameFolderModal } from "../modals/rename-folder-modal";
-import { Delete, ThreeDots } from "../shared/icons";
+import { Chart, Delete, ThreeDots } from "../shared/icons";
import { FolderAccessIcon } from "./folder-access-icon";
type FolderSummary = Pick<Folder, "id" | "name" | "accessLevel">;
@@ -215,6 +216,7 @@ const FolderActions = ({
onDelete: () => void;
}) => {
const router = useRouter();
+ const { slug: workspaceSlug } = useWorkspace();
const [openPopover, setOpenPopover] = useState(false);
const canUpdateFolder = useCheckFolderPermission(folder.id, "folders.write");
@@ -233,6 +235,20 @@ const FolderActions = ({
<Popover
content={
<div className="grid w-full gap-px p-2 sm:w-48">
+ <Button
+ text="Analytics"
+ variant="outline"
+ onClick={() => {
+ setOpenPopover(false);
+ router.push(
+ `/${workspaceSlug}/analytics?folderId=${folder.id}`,
+ );
+ }}
+ icon={<Chart className="h-4 w-4" />}
+ shortcut="A"
+ className="h-9 px-2 font-medium"
+ />
+
{canUpdateFolder && (
<Button
text="Rename"