Skip to content

Commit d7ec52f

Browse files
committed
Merge branch 'staging' of https://github.com/databuddy-analytics/Databuddy into staging
2 parents 7e868e3 + ad95fae commit d7ec52f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/api/src/query/builders/devices.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
179179
label: 'Visitors',
180180
description: 'Unique visitors with this connection type',
181181
},
182+
{
183+
name: 'percentage',
184+
type: 'number',
185+
label: 'Usage %',
186+
description: 'Percentage of total connection type usage',
187+
unit: '%',
188+
},
182189
],
183190
default_visualization: 'table',
184191
supports_granularity: ['hour', 'day'],
@@ -189,6 +196,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
189196
'connection_type as name',
190197
'COUNT(*) as pageviews',
191198
'COUNT(DISTINCT anonymous_id) as visitors',
199+
'ROUND((COUNT(*) / SUM(COUNT(*)) OVER()) * 100, 2) as percentage',
192200
],
193201
where: ["connection_type != ''", "event_name = 'screen_view'"],
194202
groupBy: ['connection_type'],

0 commit comments

Comments
 (0)