@@ -21,11 +21,12 @@ export function WebsiteMetricsBar({
21
21
const { ref, isSticky } = useSticky ( { enabled : sticky } ) ;
22
22
const { data, isLoading, isFetched, error } = useWebsiteStats ( websiteId ) ;
23
23
24
- const { pageviews , uniques , bounces, totaltime } = data || { } ;
25
- const num = Math . min ( data && uniques . value , data && bounces . value ) ;
24
+ const { views , visitors , visits , bounces, totaltime } = data || { } ;
25
+ const num = Math . min ( data && visitors . value , data && bounces . value ) ;
26
26
const diffs = data && {
27
- pageviews : pageviews . value - pageviews . change ,
28
- uniques : uniques . value - uniques . change ,
27
+ views : views . value - views . change ,
28
+ visitors : visitors . value - visitors . change ,
29
+ visits : visits . value - visits . change ,
29
30
bounces : bounces . value - bounces . change ,
30
31
totaltime : totaltime . value - totaltime . change ,
31
32
} ;
@@ -39,25 +40,39 @@ export function WebsiteMetricsBar({
39
40
} ) }
40
41
>
41
42
< MetricsBar isLoading = { isLoading } isFetched = { isFetched } error = { error } >
42
- { pageviews && uniques && (
43
+ { views && visitors && (
43
44
< >
44
45
< MetricCard
45
46
label = { formatMessage ( labels . views ) }
46
- value = { pageviews . value }
47
- change = { pageviews . change }
47
+ value = { views . value }
48
+ change = { views . change }
48
49
/>
49
50
< MetricCard
50
51
label = { formatMessage ( labels . visitors ) }
51
- value = { uniques . value }
52
- change = { uniques . change }
52
+ value = { visitors . value }
53
+ change = { visitors . change }
54
+ />
55
+ < MetricCard
56
+ label = { formatMessage ( labels . visits ) }
57
+ value = { visits . value }
58
+ change = { visits . change }
59
+ />
60
+ < MetricCard
61
+ label = { formatMessage ( labels . viewsPerVisit ) }
62
+ value = { visits . value ? views . value / visits . value : 0 }
63
+ change = {
64
+ visits . value && visits . change
65
+ ? views . value / visits . value - diffs . views / diffs . visits
66
+ : 0
67
+ }
53
68
/>
54
69
< MetricCard
55
70
label = { formatMessage ( labels . bounceRate ) }
56
- value = { uniques . value ? ( num / uniques . value ) * 100 : 0 }
71
+ value = { visitors . value ? ( num / visitors . value ) * 100 : 0 }
57
72
change = {
58
- uniques . value && uniques . change
59
- ? ( num / uniques . value ) * 100 -
60
- ( Math . min ( diffs . uniques , diffs . bounces ) / diffs . uniques ) * 100 || 0
73
+ visitors . value && visitors . change
74
+ ? ( num / visitors . value ) * 100 -
75
+ ( Math . min ( diffs . visitors , diffs . bounces ) / diffs . visitors ) * 100 || 0
61
76
: 0
62
77
}
63
78
format = { n => Number ( n ) . toFixed ( 0 ) + '%' }
@@ -66,14 +81,12 @@ export function WebsiteMetricsBar({
66
81
< MetricCard
67
82
label = { formatMessage ( labels . averageVisitTime ) }
68
83
value = {
69
- totaltime . value && pageviews . value
70
- ? totaltime . value / ( pageviews . value - bounces . value )
71
- : 0
84
+ totaltime . value && views . value ? totaltime . value / ( views . value - bounces . value ) : 0
72
85
}
73
86
change = {
74
- totaltime . value && pageviews . value
75
- ? ( diffs . totaltime / ( diffs . pageviews - diffs . bounces ) -
76
- totaltime . value / ( pageviews . value - bounces . value ) ) *
87
+ totaltime . value && views . value
88
+ ? ( diffs . totaltime / ( diffs . views - diffs . bounces ) -
89
+ totaltime . value / ( views . value - bounces . value ) ) *
77
90
- 1 || 0
78
91
: 0
79
92
}
0 commit comments