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.

make sure events table works

Steven Tey38ab11e57a87
diff --git a/apps/web/lib/analytics/get-analytics.ts b/apps/web/lib/analytics/get-analytics.ts
index 9ee53e6827..2bc723c7ea 100644
--- a/apps/web/lib/analytics/get-analytics.ts
+++ b/apps/web/lib/analytics/get-analytics.ts
@@ -22,11 +22,11 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
end,
qr,
trigger,
+ region,
+ country,
timezone = "UTC",
isDemo,
isDeprecatedClicksEndpoint = false,
- region,
- country,
} = params;
const tagIds = combineTagIds(params);
diff --git a/apps/web/lib/analytics/get-events.ts b/apps/web/lib/analytics/get-events.ts
index a41e7c6494..39b2e16476 100644
--- a/apps/web/lib/analytics/get-events.ts
+++ b/apps/web/lib/analytics/get-events.ts
@@ -32,6 +32,8 @@ export const getEvents = async (params: EventsFilters) => {
end,
qr,
trigger,
+ region,
+ country,
isDemo,
} = params;
@@ -49,6 +51,12 @@ export const getEvents = async (params: EventsFilters) => {
}
}
+ if (region) {
+ const split = region.split("-");
+ country = split[0];
+ region = split[1];
+ }
+
const pipe = (isDemo ? tbDemo : tb).buildPipe({
pipe: "v2_events",
parameters: eventsFilterTB,
@@ -65,6 +73,8 @@ export const getEvents = async (params: EventsFilters) => {
eventType,
workspaceId,
qr,
+ country,
+ region,
offset: (params.page - 1) * params.limit,
start: startDate.toISOString().replace("T", " ").replace("Z", ""),
end: endDate.toISOString().replace("T", " ").replace("Z", ""),
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 80aca57b57..bd0084e28d 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -237,6 +237,9 @@ export default function EventsTable({
id: "city",
header: "City",
accessorKey: "click.city",
+ meta: {
+ filterParams: ({ getValue }) => ({ city: getValue() }),
+ },
minSize: 160,
cell: ({ getValue, row }) => (
<div className="flex items-center gap-3" title={getValue()}>
@@ -257,6 +260,9 @@ export default function EventsTable({
id: "region",
header: "Region",
accessorKey: "click.region",
+ meta: {
+ filterParams: ({ getValue }) => ({ region: getValue() }),
+ },
minSize: 160,
cell: ({ getValue, row }) => (
<div className="flex items-center gap-3" title={getValue()}>
diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsx
index 3e3eb57a38..b961cc91ad 100644
--- a/apps/web/ui/analytics/toggle.tsx
+++ b/apps/web/ui/analytics/toggle.tsx
@@ -433,21 +433,6 @@ export default function Toggle({
right: nFormatter(count, { full: true }),
})) ?? null,
},
- {
- key: "continent",
- icon: MapPosition,
- label: "Continent",
- getOptionIcon: (value) => (
- <ContinentIcon display={value} className="size-2.5" />
- ),
- getOptionLabel: (value) => CONTINENTS[value],
- options:
- continents?.map(({ continent, count }) => ({
- value: continent,
- label: CONTINENTS[continent],
- right: nFormatter(count, { full: true }),
- })) ?? null,
- },
{
key: "region",
icon: LocationPin,
@@ -466,6 +451,21 @@ export default function Toggle({
right: nFormatter(count, { full: true }),
})) ?? null,
},
+ {
+ key: "continent",
+ icon: MapPosition,
+ label: "Continent",
+ getOptionIcon: (value) => (
+ <ContinentIcon display={value} className="size-2.5" />
+ ),
+ getOptionLabel: (value) => CONTINENTS[value],
+ options:
+ continents?.map(({ continent, count }) => ({
+ value: continent,
+ label: CONTINENTS[continent],
+ right: nFormatter(count, { full: true }),
+ })) ?? null,
+ },
{
key: "device",
icon: MobilePhone,