Skip to content

📈 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!

Merge branch 'main' into feature/network-intelligence-panel

Blue Mouseae6031a9a2e6
diff --cc backend/apps/cloud/src/analytics/analytics.controller.ts
index 6b705d480,8c64d4ba0..ea5e6b89a
--- a/backend/apps/cloud/src/analytics/analytics.controller.ts
+++ b/backend/apps/cloud/src/analytics/analytics.controller.ts
@@@ -1183,16 -1464,7 +1464,16 @@@ export class AnalyticsController
profileId,
)
- const { city, region, regionCode, country } = getIPDetails(ip, errorDTO.tz)
+ const {
+ city,
+ region,
+ regionCode,
+ country,
+ isp,
+ organization,
+ userType,
+ connectionType,
- } = getGeoDetails(ip, errorDTO.tz)
++ } = getIPDetails(ip, errorDTO.tz)
this.analyticsService.checkCountryBlacklist(project, country)
@@@ -1311,16 -1587,7 +1600,16 @@@
}
}
- const { city, region, regionCode, country } = getIPDetails(ip, eventsDTO.tz)
+ const {
+ city,
+ region,
+ regionCode,
+ country,
+ isp,
+ organization,
+ userType,
+ connectionType,
- } = getGeoDetails(ip, eventsDTO.tz)
++ } = getIPDetails(ip, eventsDTO.tz)
this.analyticsService.checkCountryBlacklist(project, country)
@@@ -1486,16 -1767,7 +1793,16 @@@
)
}
- const { city, region, regionCode, country } = getIPDetails(ip, logDTO.tz)
+ const {
+ city,
+ region,
+ regionCode,
+ country,
+ isp,
+ organization,
+ userType,
+ connectionType,
- } = getGeoDetails(ip, logDTO.tz)
++ } = getIPDetails(ip, logDTO.tz)
this.analyticsService.checkCountryBlacklist(project, country)
@@@ -1644,16 -1918,7 +1961,16 @@@
profileId,
)
- const { city, region, regionCode, country } = getIPDetails(ip)
+ const {
+ city,
+ region,
+ regionCode,
+ country,
+ isp,
+ organization,
+ userType,
+ connectionType,
- } = getGeoDetails(ip)
++ } = getIPDetails(ip)
this.analyticsService.checkCountryBlacklist(project, country)
diff --cc backend/apps/cloud/src/common/utils.ts
index 152de2212,e9868336d..c155558d8
--- a/backend/apps/cloud/src/common/utils.ts
+++ b/backend/apps/cloud/src/common/utils.ts
@@@ -260,17 -265,26 +265,28 @@@ interface IPDetails
region: string | null
regionCode: string | null
city: string | null
+ isp: string | null
+ organization: string | null
+ userType: string | null
+ connectionType: string | null
+ isHosting: boolean
}
- export const getGeoDetails = (ip: string, tz?: string): IPGeoDetails => {
- const data = lookup.get(ip)
+ export const getIPDetails = (ip: string, tz?: string): IPDetails => {
+ let data
+ try {
+ data = ip ? lookup.get(ip) : null
+ } catch {
+ data = null
+ }
+
+ const traits = data?.traits ?? {}
+ const isHosting =
+ traits.is_hosting_provider === true || traits.user_type === 'hosting'
+ // Stage 1: Using IP address based geo lookup
const country = data?.country?.iso_code || null
- // TODO: Add city overrides, for example, Colinton -> Edinburgh, etc.
const city = data?.city?.names?.en || null
- // TODO: Store ISO code, not region name
const region = data?.subdivisions?.[0]?.names?.en || null
const regionCode = data?.subdivisions?.[0]?.iso_code || null
@@@ -285,10 -294,7 +301,11 @@@
city,
region,
regionCode,
+ isp,
+ organization,
+ userType,
+ connectionType,
+ isHosting,
}
}
@@@ -299,10 -306,7 +316,11 @@@
city: null,
region: null,
regionCode: null,
+ isp: null,
+ organization: null,
+ userType: null,
+ connectionType: null,
+ isHosting,
}
}
diff --cc backend/migrations/clickhouse/initialise_database.js
index 5a196fe62,8fe55897a..fc35a9640
--- a/backend/migrations/clickhouse/initialise_database.js
+++ b/backend/migrations/clickhouse/initialise_database.js
@@@ -28,12 -28,9 +28,13 @@@ const CLICKHOUSE_INIT_QUERIES =
rg LowCardinality(Nullable(String)),
rgc LowCardinality(Nullable(String)),
ct Nullable(String) CODEC(ZSTD(3)),
+ isp LowCardinality(Nullable(String)),
+ og Nullable(String) CODEC(ZSTD(3)),
+ ut LowCardinality(Nullable(String)),
+ ctp LowCardinality(Nullable(String)),
\`meta.key\` Array(String) CODEC(ZSTD(3)),
\`meta.value\` Array(String) CODEC(ZSTD(3)),
+ importID Nullable(UInt8),
created DateTime('UTC') CODEC(Delta(4), LZ4)
)
ENGINE = MergeTree()
@@@ -65,12 -62,9 +66,13 @@@
rg LowCardinality(Nullable(String)),
rgc LowCardinality(Nullable(String)),
ct Nullable(String) CODEC(ZSTD(3)),
+ isp LowCardinality(Nullable(String)),
+ og Nullable(String) CODEC(ZSTD(3)),
+ ut LowCardinality(Nullable(String)),
+ ctp LowCardinality(Nullable(String)),
\`meta.key\` Array(String) CODEC(ZSTD(3)),
\`meta.value\` Array(String) CODEC(ZSTD(3)),
+ importID Nullable(UInt8),
created DateTime('UTC') CODEC(Delta(4), LZ4)
)
ENGINE = MergeTree()
diff --cc web/app/pages/Project/View/utils/filters.tsx
index 5a7f6c858,03a277208..1d258d833
--- a/web/app/pages/Project/View/utils/filters.tsx
+++ b/web/app/pages/Project/View/utils/filters.tsx
@@@ -38,11 -38,8 +38,12 @@@ const validFilters =
'ca',
'te',
'co',
+ 'isp',
+ 'og',
+ 'ut',
+ 'ctp',
'ev',
+ 'keywords',
'tag:key',
'tag:value',
'ev:key',
diff --cc web/app/pages/Project/tabs/Traffic/TrafficView.tsx
index 7e114bb71,e963f4590..2c4f70c40
--- a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
+++ b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
@@@ -415,8 -485,7 +485,8 @@@ const TrafficViewInner = (
location: 'cc' | 'rg' | 'ct' | 'lc' | 'map'
page: 'pg' | 'host' | 'userFlow' | 'entryPage' | 'exitPage'
device: 'br' | 'os' | 'dv'
+ network: 'isp' | 'og' | 'ut' | 'ctp'
- source: 'ref' | 'so' | 'me' | 'ca' | 'te' | 'co' | 'keywords'
+ source: 'ref' | 'so' | 'me' | 'ca' | 'te' | 'co'
customEvMetadata: string
pageviewMetadata: string
}>({
diff --cc web/public/locales/en.json
index de5216c98,161b6e183..e2fb9ff93
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@@ -1577,10 -1760,8 +1760,12 @@@
"exitPage": "Exit page",
"keywords": "Keywords",
"keyword": "Keyword",
+ "isp": "ISP",
+ "og": "Organisation",
+ "ut": "Usage type",
- "ctp": "Connection type"
++ "ctp": "Connection type",
+ "searchEngine": "Search engine",
+ "aiReferral": "AI referral"
},
"connectGsc": "Connect Google Search Console to see keywords for this project.",
"gscConnectionRequired": "Google Search Console connection is required to view keywords for this project. Ask the project administrator to connect it first.",