π Open source, privacy-first web analytics β a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Documentation & validation fixes
Blue Mouse087550983ff3
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.tsindex eb748644c..c70e4b190 100644--- a/backend/apps/cloud/src/analytics/analytics.service.ts+++ b/backend/apps/cloud/src/analytics/analytics.service.ts@@ -142,6 +142,12 @@ const LIVE_SESSION_THRESHOLD_SECONDS = 120const MAX_CONCURRENCY_WINDOW_MINUTES = 366 * 24 * 60const MAX_FILTERS = 100const MAX_FILTER_VALUES = 100+// Journeys keep only the first {steps} distinct pages of a session, but the+// dedupe happens after aggregation, so the cap has to sit far above {steps}:+// a session that reloads one page N times still needs its later, different+// pages to survive. 1000 raw pageviews is orders of magnitude beyond any real+// session while keeping a bot's session array bounded.+const MAX_JOURNEY_PAGEVIEWS_PER_SESSION = 1000// Event types that can be targeted by the data-deletion tool.const DELETABLE_EVENT_TYPES = [...DATA_DELETION_EVENT_TYPES]@@ -1167,7 +1173,12 @@ export class AnalyticsService {SELECTpsid,arraySlice(- arrayCompact(arrayMap(x -> x.2, arraySort(groupArray((created, pg))))),+ arrayCompact(+ arrayMap(+ x -> x.2,+ groupArraySorted({maxPageviews:UInt32})((created, pg))+ )+ ),1,{steps:UInt32}) AS path@@ -1208,7 +1219,12 @@ export class AnalyticsService {const { data } = await clickhouse.query({query,- query_params: { ...params, steps, journeys },+ query_params: {+ ...params,+ steps,+ journeys,+ maxPageviews: MAX_JOURNEY_PAGEVIEWS_PER_SESSION,+ },}).then((res) =>res.json<{ path: string[]; value: string; totalSessions: string }>(),diff --git a/backend/apps/cloud/src/project/dto/create-project-view.dto.ts b/backend/apps/cloud/src/project/dto/create-project-view.dto.tsindex 8e903cb5b..0c773d5b6 100644--- a/backend/apps/cloud/src/project/dto/create-project-view.dto.ts+++ b/backend/apps/cloud/src/project/dto/create-project-view.dto.ts@@ -73,7 +73,7 @@ export class CreateProjectViewDto {@ApiProperty({description:- 'An array of properties to filter [{ column, filter, isExclusive, isContains }]',+ 'An array of properties to filter [{ dimension, operator, value, key? }]',required: false,isArray: true,})diff --git a/backend/apps/community/src/analytics/analytics.service.ts b/backend/apps/community/src/analytics/analytics.service.tsindex 37bfabe62..e6c43c064 100644--- a/backend/apps/community/src/analytics/analytics.service.ts+++ b/backend/apps/community/src/analytics/analytics.service.ts@@ -125,6 +125,12 @@ const LIVE_SESSION_THRESHOLD_SECONDS = 120const MAX_CONCURRENCY_WINDOW_MINUTES = 366 * 24 * 60const MAX_FILTERS = 100const MAX_FILTER_VALUES = 100+// Journeys keep only the first {steps} distinct pages of a session, but the+// dedupe happens after aggregation, so the cap has to sit far above {steps}:+// a session that reloads one page N times still needs its later, different+// pages to survive. 1000 raw pageviews is orders of magnitude beyond any real+// session while keeping a bot's session array bounded.+const MAX_JOURNEY_PAGEVIEWS_PER_SESSION = 1000// Event types that can be targeted by the data-deletion tool.const DELETABLE_EVENT_TYPES = [...DATA_DELETION_EVENT_TYPES]@@ -970,7 +976,12 @@ export class AnalyticsService {SELECTpsid,arraySlice(- arrayCompact(arrayMap(x -> x.2, arraySort(groupArray((created, pg))))),+ arrayCompact(+ arrayMap(+ x -> x.2,+ groupArraySorted({maxPageviews:UInt32})((created, pg))+ )+ ),1,{steps:UInt32}) AS path@@ -1011,7 +1022,12 @@ export class AnalyticsService {const { data } = await clickhouse.query({query,- query_params: { ...params, steps, journeys },+ query_params: {+ ...params,+ steps,+ journeys,+ maxPageviews: MAX_JOURNEY_PAGEVIEWS_PER_SESSION,+ },}).then((res) =>res.json<{ path: string[]; value: string; totalSessions: string }>(),diff --git a/backend/apps/community/src/project/dto/create-project-view.dto.ts b/backend/apps/community/src/project/dto/create-project-view.dto.tsindex 8e903cb5b..0c773d5b6 100644--- a/backend/apps/community/src/project/dto/create-project-view.dto.ts+++ b/backend/apps/community/src/project/dto/create-project-view.dto.ts@@ -73,7 +73,7 @@ export class CreateProjectViewDto {@ApiProperty({description:- 'An array of properties to filter [{ column, filter, isExclusive, isContains }]',+ 'An array of properties to filter [{ dimension, operator, value, key? }]',required: false,isArray: true,})diff --git a/docs/content/docs/api/stats-v2.mdx b/docs/content/docs/api/stats-v2.mdxindex de46bf774..46240fd58 100644--- a/docs/content/docs/api/stats-v2.mdx+++ b/docs/content/docs/api/stats-v2.mdx@@ -57,13 +57,13 @@ Every endpoint returns the same envelope:`metrics` is a comma-separated list of metric names, validated per data type. Each endpoint has sensible defaults. Discover all metrics for a data type via the [dimensions endpoint](#get-v2projectspiddimensions).-| Data type | Metrics |-| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| traffic | `visitors` (unique sessions), `pageviews`, `users` (unique profiles; breakdown/summary only), `session_duration` (timeseries/summary only), `bounce_rate` (timeseries/summary only), `concurrency` (live visitors over time; timeseries only, ignores filters) |-| performance | `load_time`, `ttfb`, `dns`, `tls`, `connection`, `response`, `render`, `dom_load` β all in seconds, aggregated by `measure` |-| errors | `occurrences`, `affected_users` |-| captcha | `events` (breakdown), `generated`, `passed`, `failed`, `validation_failed`, `replayed` (timeseries/summary) |-| seo | `clicks`, `impressions`, `ctr` (percentage), `position` (average search position) β all four returned by default |+| Data type | Metrics |+| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| traffic | `visitors` (unique sessions), `pageviews`, `users` (unique profiles; breakdown/summary only), `session_duration` (timeseries/summary only), `bounce_rate` (timeseries/summary only), `concurrency` (live visitors over time; timeseries only, zero-filled when filters are applied) |+| performance | `load_time`, `ttfb`, `dns`, `tls`, `connection`, `response`, `render`, `dom_load` β all in seconds, aggregated by `measure` |+| errors | `occurrences`, `affected_users` |+| captcha | `events` (breakdown), `generated`, `passed`, `failed`, `validation_failed`, `replayed` (timeseries/summary) |+| seo | `clicks`, `impressions`, `ctr` (percentage), `position` (average search position) β all four returned by default |### Dimensionsdiff --git a/web/app/hooks/v2/useV2Queries.ts b/web/app/hooks/v2/useV2Queries.tsindex fe3113a8f..a1580dbdb 100644--- a/web/app/hooks/v2/useV2Queries.ts+++ b/web/app/hooks/v2/useV2Queries.ts@@ -216,6 +216,12 @@ export const useBreakdownDetailsQuery = (),initialPageParam: 0,getNextPageParam: (lastPage, pages) => {+ // An empty page cannot advance the offset, so honouring `total` here+ // would hand back the offset we just fetched and loop forever.+ if (lastPage.data.length === 0) {+ return undefined+ }+const loaded = pages.reduce((acc, page) => acc + page.data.length, 0)const total = lastPage.meta.totaldiff --git a/web/app/pages/Project/View/utils/projectViewSegments.ts b/web/app/pages/Project/View/utils/projectViewSegments.tsindex c19b5fb8c..17ae0adf4 100644--- a/web/app/pages/Project/View/utils/projectViewSegments.ts+++ b/web/app/pages/Project/View/utils/projectViewSegments.ts@@ -36,7 +36,7 @@ const ERRORS_FILTER_COLUMNS = VALID_DIMENSIONS_BY_TYPE.errorsconst CAPTCHA_FILTER_COLUMNS = VALID_DIMENSIONS_BY_TYPE.captcha-const SEO_FILTER_COLUMNS = ['page', 'keywords', 'country', 'device']+const SEO_FILTER_COLUMNS = VALID_DIMENSIONS_BY_TYPE.seoconst ANALYTICS_TABS = new Set<ProjectTab>([PROJECT_TABS.traffic,@@ -51,7 +51,7 @@ const ANALYTICS_TABS = new Set<ProjectTab>([const FILTER_OPTIONS_BY_TAB: Partial<Record<ProjectTab, string[]>> = {[PROJECT_TABS.traffic]: TRAFFIC_FILTER_OPTIONS,[PROJECT_TABS.performance]: PERFORMANCE_FILTER_COLUMNS,- [PROJECT_TABS.seo]: ['page', 'country', 'device'],+ [PROJECT_TABS.seo]: SEO_FILTER_COLUMNS,[PROJECT_TABS.sessions]: TRAFFIC_FILTER_OPTIONS,[PROJECT_TABS.replays]: TRAFFIC_FILTER_OPTIONS,[PROJECT_TABS.profiles]: TRAFFIC_FILTER_OPTIONS,