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.

fixed links

Steven Tey53650f39d18b
diff --git a/apps/web/lib/analytics/get-events.ts b/apps/web/lib/analytics/get-events.ts
index 276f7bc2dc..838626265e 100644
--- a/apps/web/lib/analytics/get-events.ts
+++ b/apps/web/lib/analytics/get-events.ts
@@ -1,7 +1,7 @@
import { tb } from "@/lib/tinybird";
import { tbDemo } from "../tinybird/demo-client";
import { analyticsFilterTB } from "../zod/schemas/analytics";
-import { clickEventMVSchemaTB } from "../zod/schemas/clicks";
+import { clickEventEnrichedSchema } from "../zod/schemas/clicks";
import { INTERVAL_DATA } from "./constants";
import { EventsFilters } from "./types";
@@ -27,7 +27,7 @@ export const getEvents = async (params: EventsFilters) => {
const pipe = (isDemo ? tbDemo : tb).buildPipe({
pipe: `v1_events`,
parameters: analyticsFilterTB,
- data: clickEventMVSchemaTB,
+ data: clickEventEnrichedSchema,
});
const response = await pipe({
@@ -38,5 +38,13 @@ export const getEvents = async (params: EventsFilters) => {
end: end.toISOString().replace("T", " ").replace("Z", ""),
});
- return response.data;
+ return response.data.map((d) => ({
+ ...d,
+ link: {
+ id: d.link_id,
+ domain: d.domain,
+ key: d.key,
+ url: d.url,
+ },
+ }));
};
diff --git a/apps/web/lib/zod/schemas/clicks.ts b/apps/web/lib/zod/schemas/clicks.ts
index 65d59d5913..b8713fd96d 100644
--- a/apps/web/lib/zod/schemas/clicks.ts
+++ b/apps/web/lib/zod/schemas/clicks.ts
@@ -28,10 +28,12 @@ export const clickEventSchemaTB = z.object({
qr: z.number().nullable(),
});
-export const clickEventMVSchemaTB = z.object({
+export const clickEventEnrichedSchema = z.object({
timestamp: z.string(),
click_id: z.string(),
link_id: z.string(),
+ domain: z.string(),
+ key: z.string(),
url: z.string(),
country: z.string().nullable(),
city: z.string().nullable(),
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index da3f6fa3ad..e5310a12cc 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -1,7 +1,6 @@
"use client";
import { editQueryString } from "@/lib/analytics/utils";
-import useWorkspace from "@/lib/swr/use-workspace";
import { Button, LinkLogo, LoadingSpinner } from "@dub/ui";
import { COUNTRIES, capitalize, cn, fetcher } from "@dub/utils";
import {
@@ -19,21 +18,18 @@ import useSWR from "swr";
import { AnalyticsContext } from "../analytics-provider";
import DeviceIcon from "../device-icon";
-const PAGE_SIZE = 15;
+const PAGE_SIZE = 100;
const tableCellClassName =
"border-r border-b border-gray-200 px-4 py-2.5 text-left text-sm leading-6";
type FakeDatum = {
- // link: { domain: string; key: string; url: string };
- link_id: string;
+ link: { id: string; domain: string; key: string };
country: string;
device: string;
timestamp: string;
};
export default function EventsTable() {
- const { id: workspaceId } = useWorkspace();
-
const [pagination, setPagination] = useState<PaginationState>({
pageIndex: 0,
pageSize: PAGE_SIZE,
@@ -57,9 +53,9 @@ export default function EventsTable() {
/>
<span>
<span className="font-medium text-gray-950">
- {/* {getValue().domain} */}dub.sh
+ {getValue().domain}
</span>
- /{getValue()}
+ {getValue().key === "_root" ? "" : `/${getValue().key}`}
</span>
</div>
),