Skip to content

Commit cf79b43

Browse files
committed
update: use viewport instead of resolution
1 parent 6b80df6 commit cf79b43

File tree

1 file changed

+47
-60
lines changed

1 file changed

+47
-60
lines changed

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

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -110,29 +110,29 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
110110

111111
screen_resolution: {
112112
meta: {
113-
title: "Screen Resolutions",
113+
title: "Viewport Sizes",
114114
description:
115-
"Distribution of visitor screen resolutions to optimize design for the most common display sizes.",
115+
"Distribution of visitor viewport sizes to optimize design for the most common browser dimensions.",
116116
category: "Technology",
117-
tags: ["screen resolution", "display", "design", "responsive"],
117+
tags: ["viewport", "display", "design", "responsive"],
118118
output_fields: [
119119
{
120120
name: "name",
121121
type: "string",
122-
label: "Screen Resolution",
123-
description: "Screen resolution (width x height)",
122+
label: "Viewport Size",
123+
description: "Viewport size (width x height)",
124124
},
125125
{
126126
name: "pageviews",
127127
type: "number",
128128
label: "Pageviews",
129-
description: "Total pageviews from this resolution",
129+
description: "Total pageviews from this viewport",
130130
},
131131
{
132132
name: "visitors",
133133
type: "number",
134134
label: "Visitors",
135-
description: "Unique visitors with this resolution",
135+
description: "Unique visitors with this viewport",
136136
},
137137
{
138138
name: "percentage",
@@ -148,13 +148,13 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
148148
},
149149
table: Analytics.events,
150150
fields: [
151-
"screen_resolution as name",
151+
"viewport_size as name",
152152
"COUNT(*) as pageviews",
153153
"COUNT(DISTINCT anonymous_id) as visitors",
154154
"ROUND((COUNT(DISTINCT anonymous_id) / SUM(COUNT(DISTINCT anonymous_id)) OVER()) * 100, 2) as percentage",
155155
],
156-
where: ["screen_resolution != ''", "event_name = 'screen_view'"],
157-
groupBy: ["screen_resolution"],
156+
where: ["viewport_size != ''", "event_name = 'screen_view'"],
157+
groupBy: ["viewport_size"],
158158
orderBy: "visitors DESC",
159159
limit: 100,
160160
timeField: "time",
@@ -289,27 +289,27 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
289289
meta: {
290290
title: "Device Categories",
291291
description:
292-
"Traffic breakdown by device category (Desktop, Mobile, Tablet) based on screen resolution analysis.",
292+
"Traffic breakdown by device category (Desktop, Mobile, Tablet) based on viewport size analysis.",
293293
category: "Technology",
294294
tags: ["device types", "mobile", "desktop", "tablet", "responsive"],
295295
output_fields: [
296296
{
297297
name: "name",
298298
type: "string",
299-
label: "Screen Resolution",
300-
description: "The actual screen resolution",
299+
label: "Viewport Size",
300+
description: "The actual viewport size",
301301
},
302302
{
303303
name: "pageviews",
304304
type: "number",
305305
label: "Pageviews",
306-
description: "Total pageviews from this resolution",
306+
description: "Total pageviews from this viewport",
307307
},
308308
{
309309
name: "visitors",
310310
type: "number",
311311
label: "Visitors",
312-
description: "Unique visitors with this resolution",
312+
description: "Unique visitors with this viewport",
313313
},
314314
{
315315
name: "device_type",
@@ -324,13 +324,13 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
324324
},
325325
table: Analytics.events,
326326
fields: [
327-
"screen_resolution as name",
327+
"viewport_size as name",
328328
"COUNT(*) as pageviews",
329329
"COUNT(DISTINCT anonymous_id) as visitors",
330330
"ROUND((COUNT(DISTINCT anonymous_id) / SUM(COUNT(DISTINCT anonymous_id)) OVER()) * 100, 2) as percentage",
331331
],
332-
where: ["screen_resolution != ''", "event_name = 'screen_view'"],
333-
groupBy: ["screen_resolution", "device_type"],
332+
where: ["viewport_size != ''", "event_name = 'screen_view'"],
333+
groupBy: ["viewport_size", "device_type"],
334334
orderBy: "visitors DESC",
335335
limit: 100,
336336
timeField: "time",
@@ -409,12 +409,12 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
409409
screen_resolutions: {
410410
table: Analytics.events,
411411
fields: [
412-
"screen_resolution as name",
412+
"viewport_size as name",
413413
"COUNT(*) as pageviews",
414414
"COUNT(DISTINCT anonymous_id) as visitors",
415415
],
416-
where: ["screen_resolution != ''", "event_name = 'screen_view'"],
417-
groupBy: ["screen_resolution"],
416+
where: ["viewport_size != ''", "event_name = 'screen_view'"],
417+
groupBy: ["viewport_size"],
418418
orderBy: "visitors DESC",
419419
limit: 100,
420420
timeField: "time",
@@ -423,18 +423,12 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
423423

424424
viewport_vs_resolution: {
425425
meta: {
426-
title: "Viewport vs Screen Resolution",
426+
title: "Viewport Sizes by Device",
427427
description:
428-
"Comparison between actual screen resolution and browser viewport size, showing how users browse your site.",
428+
"Distribution of browser viewport sizes across different device types.",
429429
category: "Technology",
430-
tags: ["viewport", "resolution", "browser", "responsive"],
430+
tags: ["viewport", "browser", "responsive", "devices"],
431431
output_fields: [
432-
{
433-
name: "screen_resolution",
434-
type: "string",
435-
label: "Screen Resolution",
436-
description: "Physical screen resolution",
437-
},
438432
{
439433
name: "viewport_size",
440434
type: "string",
@@ -445,46 +439,38 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
445439
name: "visitors",
446440
type: "number",
447441
label: "Visitors",
448-
description: "Unique visitors with this combination",
442+
description: "Unique visitors with this viewport",
443+
},
444+
{
445+
name: "pageviews",
446+
type: "number",
447+
label: "Pageviews",
448+
description: "Total pageviews from this viewport",
449449
},
450450
{
451451
name: "device_type",
452452
type: "string",
453453
label: "Device Type",
454454
description: "Device category",
455455
},
456-
{
457-
name: "usage_pattern",
458-
type: "string",
459-
label: "Usage Pattern",
460-
description: "Browsing behavior pattern",
461-
},
462456
],
463457
default_visualization: "table",
464458
supports_granularity: ["hour", "day"],
465459
version: "1.0",
466460
},
467461
table: Analytics.events,
468462
fields: [
469-
"screen_resolution",
470463
"viewport_size",
471464
"COUNT(DISTINCT anonymous_id) as visitors",
472465
"COUNT(*) as pageviews",
473466
"any(device_type) as device_type",
474-
"CASE " +
475-
'WHEN screen_resolution = viewport_size THEN "Full Screen" ' +
476-
'WHEN screen_resolution != viewport_size THEN "Windowed" ' +
477-
'ELSE "Unknown" ' +
478-
"END as usage_pattern",
479467
],
480468
where: [
481469
"event_name = 'screen_view'",
482-
"screen_resolution != ''",
483470
"viewport_size != ''",
484-
"screen_resolution IS NOT NULL",
485471
"viewport_size IS NOT NULL",
486472
],
487-
groupBy: ["screen_resolution", "viewport_size", "device_type"],
473+
groupBy: ["viewport_size", "device_type"],
488474
orderBy: "visitors DESC",
489475
limit: 200,
490476
timeField: "time",
@@ -494,23 +480,29 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
494480

495481
viewport_patterns: {
496482
meta: {
497-
title: "Viewport Usage Patterns",
483+
title: "Common Viewport Sizes",
498484
description:
499-
"Analysis of how users browse - full screen vs windowed, and common viewport sizes.",
485+
"Analysis of the most common viewport sizes used by visitors.",
500486
category: "Technology",
501487
tags: ["viewport", "browsing patterns", "user behavior"],
502488
output_fields: [
503489
{
504-
name: "usage_pattern",
490+
name: "viewport_size",
505491
type: "string",
506-
label: "Usage Pattern",
507-
description: "How users browse (full screen vs windowed)",
492+
label: "Viewport Size",
493+
description: "Browser viewport dimensions",
508494
},
509495
{
510496
name: "visitors",
511497
type: "number",
512498
label: "Visitors",
513-
description: "Unique visitors using this pattern",
499+
description: "Unique visitors with this viewport",
500+
},
501+
{
502+
name: "sessions",
503+
type: "number",
504+
label: "Sessions",
505+
description: "Total sessions with this viewport",
514506
},
515507
{
516508
name: "percentage",
@@ -526,24 +518,19 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
526518
},
527519
table: Analytics.events,
528520
fields: [
529-
"CASE " +
530-
'WHEN screen_resolution = viewport_size THEN "Full Screen Browsing" ' +
531-
'WHEN screen_resolution != viewport_size THEN "Windowed Browsing" ' +
532-
'ELSE "Unknown Pattern" ' +
533-
"END as usage_pattern",
521+
"viewport_size",
534522
"COUNT(DISTINCT anonymous_id) as visitors",
535523
"COUNT(DISTINCT session_id) as sessions",
536524
"ROUND((COUNT(DISTINCT anonymous_id) / SUM(COUNT(DISTINCT anonymous_id)) OVER()) * 100, 2) as percentage",
537525
],
538526
where: [
539527
"event_name = 'screen_view'",
540-
"screen_resolution != ''",
541528
"viewport_size != ''",
542-
"screen_resolution IS NOT NULL",
543529
"viewport_size IS NOT NULL",
544530
],
545-
groupBy: ["usage_pattern"],
531+
groupBy: ["viewport_size"],
546532
orderBy: "visitors DESC",
533+
limit: 50,
547534
timeField: "time",
548535
customizable: true,
549536
},

0 commit comments

Comments
 (0)