1+ import { Metric } from '../../../types/query-api'
12import {
23 DashboardState ,
34 dashboardStateDefaultValue ,
@@ -7,7 +8,7 @@ import { ComparisonMode, DashboardPeriod } from '../../dashboard-time-periods'
78import { PlausibleSite , siteContextDefaultValue } from '../../site-context'
89import { StatsQuery } from '../../stats-query'
910import { remapToApiFilters } from '../../util/filters'
10- import { chooseMetrics , MetricDef , topStatsQueries } from './fetch-top-stats'
11+ import { chooseMetrics , topStatsQueries } from './fetch-top-stats'
1112
1213const aGoalFilter = [ 'is' , 'goal' , [ 'any goal' ] ] as Filter
1314const aPageFilter = [ 'is' , 'page' , [ '/any/page' ] ] as Filter
@@ -41,7 +42,7 @@ type TestCase = [
4142 Pick < DashboardState , 'filters' | 'period' > &
4243 Partial < { site ?: Pick < PlausibleSite , 'revenueGoals' > } > ,
4344 /** expected metrics */
44- MetricDef [ ] ,
45+ Metric [ ] ,
4546 /** expected queries */
4647 [ StatsQuery , null | StatsQuery ]
4748]
@@ -50,10 +51,7 @@ const cases: TestCase[] = [
5051 [
5152 'realtime and goal filter' ,
5253 { period : DashboardPeriod . realtime , filters : [ aGoalFilter ] } ,
53- [
54- { key : 'visitors' , label : 'Unique conversions (last 30 min)' } ,
55- { key : 'events' , label : 'Total conversions (last 30 min)' }
56- ] ,
54+ [ 'visitors' , 'events' ] ,
5755 [
5856 {
5957 date_range : DashboardPeriod . realtime_30m ,
@@ -70,10 +68,7 @@ const cases: TestCase[] = [
7068 [
7169 'realtime' ,
7270 { period : DashboardPeriod . realtime , filters : [ ] } ,
73- [
74- { key : 'visitors' , label : 'Unique visitors (last 30 min)' } ,
75- { key : 'pageviews' , label : 'Pageviews (last 30 min)' }
76- ] ,
71+ [ 'visitors' , 'pageviews' ] ,
7772 [
7873 {
7974 date_range : DashboardPeriod . realtime_30m ,
@@ -100,11 +95,11 @@ const cases: TestCase[] = [
10095 }
10196 } ,
10297 [
103- { key : 'visitors' , label : 'Unique conversions' } ,
104- { key : 'events' , label : 'Total conversions' } ,
105- { key : 'total_revenue' , label : 'Total revenue' } ,
106- { key : 'average_revenue' , label : 'Average revenue' } ,
107- { key : 'conversion_rate' , label : 'Conversion rate' }
98+ 'visitors' ,
99+ 'events' ,
100+ 'total_revenue' ,
101+ 'average_revenue' ,
102+ 'conversion_rate'
108103 ] ,
109104 [
110105 {
@@ -128,11 +123,7 @@ const cases: TestCase[] = [
128123 [
129124 'goal filter' ,
130125 { period : aPeriodNotRealtime , filters : [ aGoalFilter ] } ,
131- [
132- { key : 'visitors' , label : 'Unique conversions' } ,
133- { key : 'events' , label : 'Total conversions' } ,
134- { key : 'conversion_rate' , label : 'Conversion rate' }
135- ] ,
126+ [ 'visitors' , 'events' , 'conversion_rate' ] ,
136127 [
137128 {
138129 date_range : aPeriodNotRealtime ,
@@ -153,12 +144,12 @@ const cases: TestCase[] = [
153144 filters : [ aPageFilter ]
154145 } ,
155146 [
156- { key : 'visitors' , label : 'Unique visitors' } ,
157- { key : 'visits' , label : 'Total visits' } ,
158- { key : 'pageviews' , label : 'Total pageviews' } ,
159- { key : 'bounce_rate' , label : 'Bounce rate' } ,
160- { key : 'scroll_depth' , label : 'Scroll depth' } ,
161- { key : 'time_on_page' , label : 'Time on page' }
147+ 'visitors' ,
148+ 'visits' ,
149+ 'pageviews' ,
150+ 'bounce_rate' ,
151+ 'scroll_depth' ,
152+ 'time_on_page'
162153 ] ,
163154
164155 [
@@ -185,12 +176,12 @@ const cases: TestCase[] = [
185176 'default' ,
186177 { period : aPeriodNotRealtime , filters : [ ] } ,
187178 [
188- { key : 'visitors' , label : 'Unique visitors' } ,
189- { key : 'visits' , label : 'Total visits' } ,
190- { key : 'pageviews' , label : 'Total pageviews' } ,
191- { key : 'views_per_visit' , label : 'Views per visit' } ,
192- { key : 'bounce_rate' , label : 'Bounce rate' } ,
193- { key : 'visit_duration' , label : 'Visit duration' }
179+ 'visitors' ,
180+ 'visits' ,
181+ 'pageviews' ,
182+ 'views_per_visit' ,
183+ 'bounce_rate' ,
184+ 'visit_duration'
194185 ] ,
195186 [
196187 {
0 commit comments