Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ node_modules
.env.development.local
.env.test.local
.env.production.local

.vscode
# Rules
Rules

Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
14 changes: 11 additions & 3 deletions apps/api/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@
},
"files": {
"ignoreUnknown": false,
"includes": ["**"]
"includes": [
"**"
]
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"assist": {
"actions": {
"source": {
"organizeImports": "off"
}
}
},
"linter": {
"enabled": true,
"rules": {
Expand All @@ -26,4 +34,4 @@
"quoteStyle": "double"
}
}
}
}
23 changes: 12 additions & 11 deletions apps/api/src/query/builders/devices.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Analytics } from "../../types/tables";
import type { SimpleQueryConfig } from "../types";

export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
browser_name: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'browser_name as name',
'COUNT(*) as pageviews',
Expand All @@ -19,7 +20,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

os_name: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'os_name as name',
'COUNT(*) as pageviews',
Expand All @@ -36,7 +37,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

screen_resolution: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'screen_resolution as name',
'COUNT(*) as pageviews',
Expand All @@ -52,7 +53,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

connection_type: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'connection_type as name',
'COUNT(*) as pageviews',
Expand All @@ -68,7 +69,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

browsers_grouped: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'CONCAT(browser_name, \' \', browser_version) as name',
'browser_name',
Expand All @@ -92,7 +93,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

device_types: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'screen_resolution as name',
'COUNT(*) as pageviews',
Expand All @@ -110,7 +111,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

browsers: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'browser_name as name',
'COUNT(*) as pageviews',
Expand All @@ -127,7 +128,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

browser_versions: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'CONCAT(browser_name, \' \', browser_version) as name',
'COUNT(*) as pageviews',
Expand All @@ -143,7 +144,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

operating_systems: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'os_name as name',
'COUNT(*) as pageviews',
Expand All @@ -160,7 +161,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

os_versions: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'CONCAT(os_name, \' \', os_version) as name',
'COUNT(*) as pageviews',
Expand All @@ -176,7 +177,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
},

screen_resolutions: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'screen_resolution as name',
'COUNT(*) as pageviews',
Expand Down
13 changes: 7 additions & 6 deletions apps/api/src/query/builders/errors.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { SimpleQueryConfig } from "../types";
import { Analytics } from "../../types/tables";

export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
export const ErrorsBuilders: Record<string, SimpleQueryConfig<typeof Analytics.errors>> = {
recent_errors: {
table: 'analytics.errors',
table: Analytics.errors,
fields: [
'message as error_message',
'stack as error_stack',
Expand All @@ -23,7 +24,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
},

error_types: {
table: 'analytics.errors',
table: Analytics.errors,
fields: [
'message as name',
'COUNT(*) as count',
Expand All @@ -40,7 +41,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
},

error_trends: {
table: 'analytics.errors',
table: Analytics.errors,
fields: [
'toDate(timestamp) as date',
'COUNT(*) as errors',
Expand All @@ -54,7 +55,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
},

errors_by_page: {
table: 'analytics.errors',
table: Analytics.errors,
fields: [
'path as name',
'COUNT(*) as errors',
Expand All @@ -70,7 +71,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
},

error_frequency: {
table: 'analytics.errors',
table: Analytics.errors,
fields: [
'toDate(timestamp) as date',
'COUNT(*) as count'
Expand Down
13 changes: 7 additions & 6 deletions apps/api/src/query/builders/geo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { SimpleQueryConfig } from "../types";
import { Analytics } from "../../types/tables";

export const GeoBuilders: Record<string, SimpleQueryConfig> = {
export const GeoBuilders: Record<string, SimpleQueryConfig<typeof Analytics.events>> = {
country: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'country as name',
'COUNT(*) as pageviews',
Expand All @@ -20,7 +21,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
},

region: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'region as name',
'COUNT(*) as pageviews',
Expand All @@ -37,7 +38,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
},

timezone: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'timezone as name',
'COUNT(*) as pageviews',
Expand All @@ -54,7 +55,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
},

language: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'language as name',
'COUNT(*) as pageviews',
Expand All @@ -71,7 +72,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
},

city: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'city as name',
'COUNT(*) as pageviews',
Expand Down
11 changes: 6 additions & 5 deletions apps/api/src/query/builders/pages.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { SimpleQueryConfig } from "../types";
import { Analytics } from "../../types/tables";

export const PagesBuilders: Record<string, SimpleQueryConfig> = {
export const PagesBuilders: Record<string, SimpleQueryConfig<typeof Analytics.events>> = {
top_pages: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'path(path) as name',
'COUNT(*) as pageviews',
Expand All @@ -19,7 +20,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
},

entry_pages: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'entry_page as name',
'COUNT(*) as pageviews',
Expand Down Expand Up @@ -79,7 +80,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
},

exit_pages: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'path as name',
'COUNT(DISTINCT session_id) as pageviews',
Expand Down Expand Up @@ -149,7 +150,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
},

page_performance: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'path(path) as name',
'COUNT(*) as pageviews',
Expand Down
17 changes: 9 additions & 8 deletions apps/api/src/query/builders/performance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Analytics } from "../../types/tables";
import type { SimpleQueryConfig } from "../types";

export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
performance_metrics: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
Expand All @@ -20,7 +21,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
},

slow_pages: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'path(path) as name',
'COUNT(DISTINCT anonymous_id) as visitors',
Expand All @@ -43,7 +44,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
},

performance_by_device: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'device_type as name',
'COUNT(DISTINCT anonymous_id) as visitors',
Expand All @@ -66,7 +67,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
},

performance_by_browser: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'CONCAT(browser_name, \' \', browser_version) as name',
'COUNT(DISTINCT anonymous_id) as visitors',
Expand Down Expand Up @@ -95,7 +96,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
},

performance_by_country: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'country as name',
'COUNT(DISTINCT anonymous_id) as visitors',
Expand All @@ -119,7 +120,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
},

performance_by_os: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'os_name as name',
'COUNT(DISTINCT anonymous_id) as visitors',
Expand All @@ -142,7 +143,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
},

performance_by_region: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'CONCAT(region, \', \', country) as name',
'COUNT(DISTINCT anonymous_id) as visitors',
Expand All @@ -165,7 +166,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
},

performance_time_series: {
table: 'analytics.events',
table: Analytics.events,
fields: [
'toDate(time) as date',
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
Expand Down
Loading
Loading