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.

Include region data in cities groupBy

Steven Tey5e554b048ca1
diff --git a/apps/web/lib/analytics/get-analytics.ts b/apps/web/lib/analytics/get-analytics.ts
index f079766d06..e7b5b21ec0 100644
--- a/apps/web/lib/analytics/get-analytics.ts
+++ b/apps/web/lib/analytics/get-analytics.ts
@@ -94,7 +94,7 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
// Create a Tinybird pipe
const pipe = tb.buildPipe({
- pipe: `v2_${UTM_TAGS_PLURAL_LIST.includes(groupBy) ? "utms" : groupBy}`,
+ pipe: `v2_${UTM_TAGS_PLURAL_LIST.includes(groupBy) ? "utms" : groupBy}${groupBy === "cities" ? "_new" : ""}`,
parameters: analyticsFilterTB,
data:
groupBy === "top_links" || UTM_TAGS_PLURAL_LIST.includes(groupBy)
diff --git a/apps/web/lib/zod/schemas/analytics-response.ts b/apps/web/lib/zod/schemas/analytics-response.ts
index 90cdc3410d..762e9ed2c8 100644
--- a/apps/web/lib/zod/schemas/analytics-response.ts
+++ b/apps/web/lib/zod/schemas/analytics-response.ts
@@ -149,7 +149,11 @@ export const analyticsResponse = {
country: z
.enum(COUNTRY_CODES)
.describe("The 2-letter country code of the city: https://d.to/geo"),
- region: z.literal("*").default("*"),
+ region: z
+ .string()
+ .describe(
+ "The 2-letter ISO 3166-2 region code representing the region associated with the location of the user.",
+ ),
city: z.string().describe("The name of the city"),
clicks: z
.number()
diff --git a/apps/web/ui/analytics/locations.tsx b/apps/web/ui/analytics/locations.tsx
index 32da1cc7d1..1f5b7c80f5 100644
--- a/apps/web/ui/analytics/locations.tsx
+++ b/apps/web/ui/analytics/locations.tsx
@@ -22,7 +22,7 @@ export default function Locations() {
const dataKey = selectedTab === "sales" ? saleUnit : "count";
const [tab, setTab] = useState<
- "countries" | "cities" | "continents" | "regions"
+ "countries" | "cities" | "regions" | "continents"
>("countries");
const { data } = useAnalyticsFilterOption(tab);
@@ -67,9 +67,7 @@ export default function Locations() {
? CONTINENTS[d.continent]
: tab === "countries"
? COUNTRIES[d.country]
- : tab === "regions"
- ? REGIONS[d.region] || d.region.split("-")[1]
- : d.city,
+ : `${tab === "cities" ? `${d.city}, ` : ""}${REGIONS[d.region] || d.region.split("-")[1]}`,
href: queryParams({
...(searchParams.has(singularTabName)
? { del: singularTabName }