diff --git a/components/metrics/MetricsBar.js b/components/metrics/MetricsBar.js index 2b94d303..1f218ba8 100644 --- a/components/metrics/MetricsBar.js +++ b/components/metrics/MetricsBar.js @@ -16,11 +16,14 @@ export default function MetricsBar({ websiteId }) { const { startDate, endDate, modified } = dateRange; const [format, setFormat] = useState(true); const { - query: { url, referrer, os, browser, device, country }, + query: { url, referrer, os, browser, device, country, region, city }, } = usePageQuery(); const { data, error, isLoading, isFetched } = useQuery( - ['websites:stats', { websiteId, modified, url, referrer, os, browser, device, country }], + [ + 'websites:stats', + { websiteId, modified, url, referrer, os, browser, device, country, region, city }, + ], () => get(`/websites/${websiteId}/stats`, { startAt: +startDate, @@ -31,6 +34,8 @@ export default function MetricsBar({ websiteId }) { browser, device, country, + region, + city, }), ); diff --git a/lib/prisma.ts b/lib/prisma.ts index 9364e7bc..0a10d981 100644 --- a/lib/prisma.ts +++ b/lib/prisma.ts @@ -127,11 +127,11 @@ function parseFilters( params = [], sessionKey = 'session_id', ) { - const { os, browser, device, country, subdivision1, subdivision2, city } = filters; + const { os, browser, device, country, region, city } = filters; return { joinSession: - os || browser || device || country || subdivision1 || subdivision2 || city + os || browser || device || country || region || city ? `inner join session on website_event.${sessionKey} = session.${sessionKey}` : '', filterQuery: getFilterQuery(filters, params), diff --git a/lib/types.ts b/lib/types.ts index 5db5a586..37c1ffdc 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -82,8 +82,7 @@ export interface WebsiteMetricFilter { browser?: string; device?: string; country?: string; - subdivision1?: string; - subdivision2?: string; + region?: string; city?: string; } diff --git a/pages/api/websites/[id]/pageviews.ts b/pages/api/websites/[id]/pageviews.ts index c38b6c75..775a4d82 100644 --- a/pages/api/websites/[id]/pageviews.ts +++ b/pages/api/websites/[id]/pageviews.ts @@ -21,8 +21,7 @@ export interface WebsitePageviewRequestQuery { browser?: string; device?: string; country?: string; - subdivision1?: string; - subdivision2?: string; + region: string; city?: string; } @@ -46,8 +45,7 @@ export default async ( browser, device, country, - subdivision1, - subdivision2, + region, city, } = req.query; @@ -78,8 +76,7 @@ export default async ( browser, device, country, - subdivision1, - subdivision2, + region, city, }, }), @@ -96,8 +93,7 @@ export default async ( browser, device, country, - subdivision1, - subdivision2, + region, city, }, }), diff --git a/pages/api/websites/[id]/stats.ts b/pages/api/websites/[id]/stats.ts index f89ea5d1..1e2f2292 100644 --- a/pages/api/websites/[id]/stats.ts +++ b/pages/api/websites/[id]/stats.ts @@ -18,8 +18,7 @@ export interface WebsiteStatsRequestQuery { browser: string; device: string; country: string; - subdivision1: string; - subdivision2: string; + region: string; city: string; } @@ -43,8 +42,7 @@ export default async ( browser, device, country, - subdivision1, - subdivision2, + region, city, } = req.query; @@ -73,8 +71,7 @@ export default async ( browser, device, country, - subdivision1, - subdivision2, + region, city, }, }); @@ -91,8 +88,7 @@ export default async ( browser, device, country, - subdivision1, - subdivision2, + region, city, }, });