File tree 3 files changed +37
-6
lines changed
3 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ export const intervals = [
10
10
"qtd" ,
11
11
"ytd" ,
12
12
"all" ,
13
- "all_unfiltered" ,
14
13
] as const ;
15
14
16
15
export const eventIntervals = [
@@ -187,7 +186,7 @@ export const VALID_ANALYTICS_FILTERS = [
187
186
"tagId" ,
188
187
"folderId" ,
189
188
"tagIds" ,
190
- "qr" ,
189
+ "qr" , // deprecated, but keeping for now for backwards compatibility
191
190
"root" ,
192
191
"utm_source" ,
193
192
"utm_medium" ,
@@ -196,6 +195,27 @@ export const VALID_ANALYTICS_FILTERS = [
196
195
"utm_content" ,
197
196
] ;
198
197
198
+ // possible analytics filters for a given linkId
199
+ export const DIMENSIONAL_ANALYTICS_FILTERS = [
200
+ "country" ,
201
+ "city" ,
202
+ "region" ,
203
+ "continent" ,
204
+ "device" ,
205
+ "browser" ,
206
+ "os" ,
207
+ "trigger" ,
208
+ "referer" ,
209
+ "refererUrl" ,
210
+ "url" ,
211
+ "qr" , // deprecated, but keeping for now for backwards compatibility
212
+ "utm_source" ,
213
+ "utm_medium" ,
214
+ "utm_campaign" ,
215
+ "utm_term" ,
216
+ "utm_content" ,
217
+ ] ;
218
+
199
219
export const TRIGGER_DISPLAY = {
200
220
qr : "QR Scan" ,
201
221
link : "Link Click" ,
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ import { conn } from "../planetscale";
7
7
import z from "../zod" ;
8
8
import { analyticsFilterTB } from "../zod/schemas/analytics" ;
9
9
import { analyticsResponse } from "../zod/schemas/analytics-response" ;
10
- import { SINGULAR_ANALYTICS_ENDPOINTS } from "./constants" ;
10
+ import {
11
+ DIMENSIONAL_ANALYTICS_FILTERS ,
12
+ SINGULAR_ANALYTICS_ENDPOINTS ,
13
+ } from "./constants" ;
11
14
import { AnalyticsFilters } from "./types" ;
12
15
import { getStartEndDates } from "./utils/get-start-end-dates" ;
13
16
@@ -35,8 +38,16 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
35
38
// get all-time clicks count if:
36
39
// 1. linkId is defined
37
40
// 2. type is count
38
- // 3. interval is all_unfiltered
39
- if ( linkId && groupBy === "count" && interval === "all_unfiltered" ) {
41
+ // 3. interval is all
42
+ // 4. no other dimensional filters are applied
43
+ if (
44
+ linkId &&
45
+ groupBy === "count" &&
46
+ interval === "all" &&
47
+ DIMENSIONAL_ANALYTICS_FILTERS . every (
48
+ ( filter ) => ! params [ filter as keyof AnalyticsFilters ] ,
49
+ )
50
+ ) {
40
51
const columns =
41
52
event === "composite"
42
53
? `clicks, leads, sales, saleAmount`
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ function AnalyticsBadge({ link }: { link: ResponseLink }) {
201
201
202
202
return isMobile ? (
203
203
< Link
204
- href = { `/${ slug } /analytics?domain=${ domain } &key=${ key } &interval= ${ plan === "free" ? "30d" : plan === "pro" ? "1y" : "all" } ` }
204
+ href = { `/${ slug } /analytics?domain=${ domain } &key=${ key } ` }
205
205
className = "flex items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-sm text-neutral-800"
206
206
>
207
207
< CursorRays className = "h-4 w-4 text-neutral-600" />
You can’t perform that action at this time.
0 commit comments