📈 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
Support network intelligence in Swetrix CE, improve the UI/UX
Blue Mousea1d94d5cb1be
diff --git a/README.md b/README.mdindex 30d1c40b9..df67d2423 100644--- a/README.md+++ b/README.md@@ -47,6 +47,7 @@ We've been building Swetrix since 2021 with a goal to make web analytics simple- **Privacy‑first and cookieless**: GDPR‑compliant by design. We don't use cookies, cross-device tracking, all the data is stored anonymised. Read more in our [Data Policy](https://swetrix.com/data-policy) page.- **Lightweight and fast**: a small tracking script and a snappy, real‑time dashboard.- **Core insights that matter**: top pages, geolocation, map visualisation, devices, traffic sources and UTM campaigns.+- **Network intelligence**: break traffic down by ISP, organisation, usage type (residential, business, hosting, cellular...) and connection type to spot bot/datacenter traffic and understand who your audience really is.- **Custom events and properties**: track conversions, sales, or key user actions with your own semantics.- **Session analytics and user flows**: understand journeys and behaviour across your site.- **Funnels**: visualise drop‑offs and improve conversion rates.@@ -88,7 +89,7 @@ Cloud vs Community Edition| **Teams & sharing** | ✅ Organisations to manage multiple projects and users with permissions setup; invite people to your projects directly, or share a public or password protected link with people. | ⚠️ Only direct project invites, password protected links and public projects are supported. || **Alerts & notifications** | ✅ Yes (Email, Slack, Telegram, Discord, webhook, web push) | ⚠️ Not included || **Email reports** | ✅ Yes (weekly/monthly/quarterly) | ⚠️ Not included |-| **Geo analytics** | ✅ Swetrix Cloud uses premium GeoIP database to provide consistent and accurate country and city level geolocation data. | ⚠️ Less accurate, DB-IP City Lite Database; you need to pay for the full database if you want better accuracy. |+| **Geo & network analytics** | ✅ Swetrix Cloud uses a premium GeoIP database to provide consistent and accurate country / region / city geolocation, plus ISP, organisation, usage type and connection type. | ⚠️ Less accurate, DB-IP City Lite Database (country / region / city only); you need a paid MaxMind or DB-IP database for ISP and network-intelligence breakdowns. || **Release schedule** | ✅ Continuously developed with updates deployed as soon as they are ready | ℹ️ Periodic open‑source releases, latest features are not available immediately. || **Support** | ✅ Premium support from the people who build and maintain Swetrix | ⚠️ Official support is not included. Community‑driven support on Discord or other forums only. || **Costs** | ✅ We're an independent and bootstrapped business, your money directly supports Swetrix development. | ⚠️ You pay for the server costs and maintenance, backups, domains and other selfhosting costs, with money going to 3rd party services with no connection to us. |diff --git a/backend/apps/community/src/analytics/analytics.controller.ts b/backend/apps/community/src/analytics/analytics.controller.tsindex ef8fbab4f..077127e9a 100644--- a/backend/apps/community/src/analytics/analytics.controller.ts+++ b/backend/apps/community/src/analytics/analytics.controller.ts@@ -1103,7 +1103,16 @@ export class AnalyticsController {}}- const { city, region, regionCode, country } = getIPDetails(ip, eventsDTO.tz)+ const {+ city,+ region,+ regionCode,+ country,+ isp,+ organization,+ userType,+ connectionType,+ } = getIPDetails(ip, eventsDTO.tz)this.analyticsService.checkCountryBlacklist(project, country)@@ -1159,6 +1168,10 @@ export class AnalyticsController {region,regionCode,city,+ isp,+ organization,+ userType,+ connectionType,eventsDTO.meta,)@@ -1282,7 +1295,16 @@ export class AnalyticsController {)}- const { city, region, regionCode, country } = getIPDetails(ip, logDTO.tz)+ const {+ city,+ region,+ regionCode,+ country,+ isp,+ organization,+ userType,+ connectionType,+ } = getIPDetails(ip, logDTO.tz)this.analyticsService.checkCountryBlacklist(project, country)@@ -1315,6 +1337,10 @@ export class AnalyticsController {region,regionCode,city,+ isp,+ organization,+ userType,+ connectionType,logDTO.meta,)@@ -1343,6 +1369,10 @@ export class AnalyticsController {region,regionCode,city,+ isp,+ organization,+ userType,+ connectionType,dns,tls,conn,@@ -1435,7 +1465,16 @@ export class AnalyticsController {profileId,)- const { city, region, regionCode, country } = getIPDetails(ip, null)+ const {+ city,+ region,+ regionCode,+ country,+ isp,+ organization,+ userType,+ connectionType,+ } = getIPDetails(ip, null)this.analyticsService.checkCountryBlacklist(project, country)@@ -1466,6 +1505,10 @@ export class AnalyticsController {region,regionCode,city,+ isp,+ organization,+ userType,+ connectionType,null,)@@ -1796,7 +1839,16 @@ export class AnalyticsController {profileId,)- const { city, region, regionCode, country } = getIPDetails(ip, errorDTO.tz)+ const {+ city,+ region,+ regionCode,+ country,+ isp,+ organization,+ userType,+ connectionType,+ } = getIPDetails(ip, errorDTO.tz)this.analyticsService.checkCountryBlacklist(project, country)@@ -1828,6 +1880,10 @@ export class AnalyticsController {region,regionCode,city,+ isp,+ organization,+ userType,+ connectionType,name,message,lineno,diff --git a/backend/apps/community/src/analytics/analytics.service.ts b/backend/apps/community/src/analytics/analytics.service.tsindex a7a80c1c9..3ee04d2ba 100644--- a/backend/apps/community/src/analytics/analytics.service.ts+++ b/backend/apps/community/src/analytics/analytics.service.ts@@ -256,7 +256,19 @@ const checkIfTBAllowed = (}}-const EXCLUDE_NULL_FOR = ['so', 'me', 'ca', 'te', 'co', 'rg', 'ct']+const EXCLUDE_NULL_FOR = [+ 'so',+ 'me',+ 'ca',+ 'te',+ 'co',+ 'rg',+ 'ct',+ 'isp',+ 'og',+ 'ut',+ 'ctp',+]const generateParamsQuery = (col: string,diff --git a/backend/apps/community/src/analytics/utils/transformers.ts b/backend/apps/community/src/analytics/utils/transformers.tsindex 68c1a8cc0..1bcdf93c1 100644--- a/backend/apps/community/src/analytics/utils/transformers.ts+++ b/backend/apps/community/src/analytics/utils/transformers.ts@@ -45,6 +45,10 @@ export const trafficTransformer = (rg: string | null,rgc: string | null,ct: string | null,+ isp: string | null,+ og: string | null,+ ut: string | null,+ ctp: string | null,meta: Record<string, string> | null,) => {return {@@ -69,6 +73,10 @@ export const trafficTransformer = (rg: rg || null,rgc: rgc || null,ct: ct || null,+ isp: isp || null,+ og: og || null,+ ut: ut || null,+ ctp: ctp || null,...processMetaKV(meta),created: dayjs.utc().format('YYYY-MM-DD HH:mm:ss'),}@@ -97,6 +105,10 @@ export const customEventTransformer = (rg: string | null,rgc: string | null,ct: string | null,+ isp: string | null,+ og: string | null,+ ut: string | null,+ ctp: string | null,meta: Record<string, string> | null,) => {return {@@ -122,6 +134,10 @@ export const customEventTransformer = (rg: rg || null,rgc: rgc || null,ct: ct || null,+ isp: isp || null,+ og: og || null,+ ut: ut || null,+ ctp: ctp || null,...processMetaKV(meta),created: dayjs.utc().format('YYYY-MM-DD HH:mm:ss'),}@@ -144,6 +160,10 @@ export const errorEventTransformer = (rg: string | null,rgc: string | null,ct: string | null,+ isp: string | null,+ og: string | null,+ ut: string | null,+ ctp: string | null,name: string | null,message: string | null,lineno: number | null,@@ -169,6 +189,10 @@ export const errorEventTransformer = (rg: rg || null,rgc: rgc || null,ct: ct || null,+ isp: isp || null,+ og: og || null,+ ut: ut || null,+ ctp: ctp || null,name: name || null,message: message || null,lineno: lineno || null,@@ -191,6 +215,10 @@ export const performanceTransformer = (rg: string | null,rgc: string | null,ct: string | null,+ isp: string | null,+ og: string | null,+ ut: string | null,+ ctp: string | null,dns: number,tls: number,conn: number,@@ -211,6 +239,10 @@ export const performanceTransformer = (rg: rg || null,rgc: rgc || null,ct: ct || null,+ isp: isp || null,+ og: og || null,+ ut: ut || null,+ ctp: ctp || null,dns: _round(dns),tls: _round(tls),conn: _round(conn),diff --git a/backend/apps/community/src/common/constants.ts b/backend/apps/community/src/common/constants.tsindex 15f694db6..96e924132 100644--- a/backend/apps/community/src/common/constants.ts+++ b/backend/apps/community/src/common/constants.ts@@ -82,6 +82,10 @@ const TRAFFIC_COLUMNS = ['cc','rg','ct',+ 'isp',+ 'og',+ 'ut',+ 'ctp','host','pg','lc',@@ -112,11 +116,28 @@ const ERROR_COLUMNS = ['cc','rg','ct',+ 'isp',+ 'og',+ 'ut',+ 'ctp',]const ALL_COLUMNS = [...TRAFFIC_COLUMNS, 'ev', 'entryPage', 'exitPage']-const PERFORMANCE_COLUMNS = ['cc', 'rg', 'ct', 'host', 'pg', 'dv', 'br', 'brv']+const PERFORMANCE_COLUMNS = [+ 'cc',+ 'rg',+ 'ct',+ 'isp',+ 'og',+ 'ut',+ 'ctp',+ 'host',+ 'pg',+ 'dv',+ 'br',+ 'brv',+]const NUMBER_JWT_REFRESH_TOKEN_LIFETIME = Number(JWT_REFRESH_TOKEN_LIFETIME)const NUMBER_JWT_ACCESS_TOKEN_LIFETIME = Number(JWT_ACCESS_TOKEN_LIFETIME)diff --git a/backend/apps/community/src/common/utils.ts b/backend/apps/community/src/common/utils.tsindex 0157f17d6..3689ee731 100644--- a/backend/apps/community/src/common/utils.ts+++ b/backend/apps/community/src/common/utils.ts@@ -1128,6 +1128,10 @@ interface IPDetails {region: string | nullregionCode: string | nullcity: string | null+ isp: string | null+ organization: string | null+ userType: string | null+ connectionType: string | nullisHosting: boolean}@@ -1151,12 +1155,21 @@ const getIPDetails = (ip: string, tz?: string): IPDetails => {const region = data?.subdivisions?.[0]?.names?.en || nullconst regionCode = data?.subdivisions?.[0]?.iso_code || null+ const isp = data?.traits?.isp || null+ const organization = data?.traits?.organization || null+ const userType = data?.traits?.user_type || null+ const connectionType = data?.traits?.connection_type || null+if (country) {return {country,city,region,regionCode,+ isp,+ organization,+ userType,+ connectionType,isHosting,}}@@ -1169,6 +1182,10 @@ const getIPDetails = (ip: string, tz?: string): IPDetails => {city: null,region: null,regionCode: null,+ isp: null,+ organization: null,+ userType: null,+ connectionType: null,isHosting,}}diff --git a/docs/content/docs/analytics-dashboard/performance.mdx b/docs/content/docs/analytics-dashboard/performance.mdxindex 00300f129..a3947b651 100644--- a/docs/content/docs/analytics-dashboard/performance.mdx+++ b/docs/content/docs/analytics-dashboard/performance.mdx@@ -66,3 +66,16 @@ Identify which parts of your site are the slowest.- **Pages**: Performance metrics for individual page paths (e.g., `/pricing`, `/blog`).- **Hosts**: If you track multiple subdomains or domains, this shows performance per host.++### Network intelligence++Slice load times by the network the visitor is connecting from. Helpful for spotting whether a slowdown is concentrated on a specific ISP or connection technology rather than your own infrastructure.++- **ISP**: Compare load times across providers (e.g., is Comcast slower than AT&T?).+- **Organisation**: Drill down to the registered network owner.+- **Usage type**: See how `residential` users compare to `cellular` or `business` ones.+- **Connection type**: Spot differences between `Cable/DSL`, `Cellular`, `Satellite`, etc.++:::info+Like the Traffic dashboard, Network intelligence is populated by your IP geolocation database. Self-hosted instances using the bundled DB-IP City Lite database will see the panel but with no data — point `IP_GEOLOCATION_DB_PATH` at a paid MaxMind GeoIP2 ISP / Insights database or a paid DB-IP database that includes ISP and usage-type information to enable it. See [Self-hosting → Configuring](/selfhosting/configuring).+:::diff --git a/docs/content/docs/analytics-dashboard/traffic.mdx b/docs/content/docs/analytics-dashboard/traffic.mdxindex 00f727ca1..7768eec3d 100644--- a/docs/content/docs/analytics-dashboard/traffic.mdx+++ b/docs/content/docs/analytics-dashboard/traffic.mdx@@ -78,6 +78,19 @@ Identify how visitors find your website:Looking for search keywords, top pages, and other SEO data? Check out the dedicated **[SEO dashboard](/analytics-dashboard/seo)**, powered by your Google Search Console integration.:::+### Network intelligence++The Network intelligence panel breaks down traffic by the network the visitor is coming from. It's particularly useful for spotting bot or hosting-provider traffic, distinguishing residential users from corporate ones, and understanding how your audience connects.++- **ISP**: The Internet Service Provider serving the visitor (e.g., `Comcast`, `Vodafone`, `Hetzner`).+- **Organisation**: The registered owner of the IP block (often the same as the ISP, but can also be a specific company, university, or hosting tenant).+- **Usage type**: How the IP block is classified — for example `residential`, `business`, `hosting`, `cellular`, `government`, `school`, or `search_engine_spider`. This is one of the easiest ways to surface unwanted hosting / datacenter traffic at a glance.+- **Connection type**: The connection technology behind the IP — typically `Cable/DSL`, `Cellular`, `Corporate`, `Satellite`, or `Dialup`.++:::info+Network intelligence is powered by your IP geolocation database. Swetrix Cloud ships with a premium GeoIP database, so all four breakdowns are populated out of the box. Self-hosted instances using the bundled DB-IP City Lite database will see the panel but with empty data — to populate ISP, organisation, usage type, and connection type, point `IP_GEOLOCATION_DB_PATH` at a paid MaxMind GeoIP2 ISP / Insights database or a paid DB-IP database that includes those fields. See [Self-hosting → Configuring](/selfhosting/configuring) for details.+:::+## Custom Events & MetadataSwetrix allows you to track specific interactions beyond standard pageviews.diff --git a/docs/content/docs/api/stats.mdx b/docs/content/docs/api/stats.mdxindex 75ddfda07..605761b21 100644--- a/docs/content/docs/api/stats.mdx+++ b/docs/content/docs/api/stats.mdx@@ -71,7 +71,7 @@ Filters are used to aggregate data by specific parameters. For example, you can}```-- **column** - the column to filter by. Possible values are: `cc` (country code), `host` (hostname), `pg` (page), `lc` (locale), `br` (browser), `brv` (browser version), `os` (operating system), `osv` (OS version), `dv` (device), `ref` (referrer), `so` (source), `me` (medium), `ca` (campaign).+- **column** - the column to filter by. Possible values are: `cc` (country code), `rg` (region), `ct` (city), `host` (hostname), `pg` (page), `lc` (locale), `br` (browser), `brv` (browser version), `os` (operating system), `osv` (OS version), `dv` (device), `ref` (referrer), `so` (source), `me` (medium), `ca` (campaign), `te` (UTM term), `co` (UTM content), `isp` (ISP), `og` (organisation), `ut` (usage type), `ctp` (connection type).- **filter** - the value to filter by. For example, if you want to filter by country, the value should be a country code (e.g. `GB` for Great Britain).- **isExclusive** - whether to include or exclude the specified value. If `isExclusive` is `true`, the data will be filtered by the specified value. If `isExclusive` is `false`, the data will be filtered by all values except the specified one.- **isContains** - whether the value should be matches exactly, or if it should be a substring. If `isContains` is `true`, the data will be filtered by the specified value (for example, searching for "rain" will return "Ukraine" because it contains "rain"). If `isContains` is `false`, the data will be filtered by the specified value exactly.@@ -217,7 +217,35 @@ curl 'https://api.swetrix.com/v1/log?pid=YOUR_PROJECT_ID&timeBucket=day&period=7"me": [],"ca": [],"te": [],- "co": []+ "co": [],+ "isp": [+ {+ "name": "Comcast Cable",+ "count": 18+ }+ ],+ "og": [+ {+ "name": "Comcast Cable Communications, LLC",+ "count": 18+ }+ ],+ "ut": [+ {+ "name": "residential",+ "count": 25+ },+ {+ "name": "hosting",+ "count": 5+ }+ ],+ "ctp": [+ {+ "name": "Cable/DSL",+ "count": 25+ }+ ]},"chart": {"x": [diff --git a/docs/content/docs/selfhosting/configuring.mdx b/docs/content/docs/selfhosting/configuring.mdxindex e9d25d9d2..e2dbbf1ab 100644--- a/docs/content/docs/selfhosting/configuring.mdx+++ b/docs/content/docs/selfhosting/configuring.mdx@@ -25,14 +25,14 @@ The `BASE_URL` must be publicly reachable from your users' browsers. Do not set### Basic configuration-| Variable | Default | Description |-| ------------------------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |-| `SECRET_KEY_BASE` | _auto-generated by `configure.sh`_ | Secret used for auth keys and login sessions. Must be set. |-| `CLIENT_IP_HEADER` | `null` | Defines what header should be used to get IP address (e.g. cf-connecting-ip, x-real-ip, etc.). If not set, Swetrix will use `x-forwarded-for` header. |-| `DISABLE_REGISTRATION` | `true` | When set to `true` - Swetrix will disable user registration, except for the initial user. |-| `IP_GEOLOCATION_DB_PATH` | `` | Path to the `.mmdb` file for IP geolocation database. By default Swetrix uses IP to City Lite database by DB-IP. |-| `IS_PRIMARY_NODE` | `true` | You should not touch this variable unless you know what you are doing. It's used to spin off multiple API instances in a cluster, where only one of them will be primary. If changed to `false`, things like cron task manager will be disabled for this instance. |-| `TWO_FACTOR_AUTHENTICATION_APP_NAME` | `Swetrix CE` | The app name shown in authenticator apps when users set up 2FA. |+| Variable | Default | Description |+| ------------------------------------ | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `SECRET_KEY_BASE` | _auto-generated by `configure.sh`_ | Secret used for auth keys and login sessions. Must be set. |+| `CLIENT_IP_HEADER` | `null` | Defines what header should be used to get IP address (e.g. cf-connecting-ip, x-real-ip, etc.). If not set, Swetrix will use `x-forwarded-for` header. |+| `DISABLE_REGISTRATION` | `true` | When set to `true` - Swetrix will disable user registration, except for the initial user. |+| `IP_GEOLOCATION_DB_PATH` | `` | Path to the `.mmdb` file for IP geolocation database. By default Swetrix uses the IP to City Lite database by DB-IP, which provides country / region / city only. To populate the **Network intelligence** panel (ISP, organisation, usage type, connection type), point this at a paid MaxMind GeoIP2 ISP / Insights database or a paid DB-IP database that includes those fields. |+| `IS_PRIMARY_NODE` | `true` | You should not touch this variable unless you know what you are doing. It's used to spin off multiple API instances in a cluster, where only one of them will be primary. If changed to `false`, things like cron task manager will be disabled for this instance. |+| `TWO_FACTOR_AUTHENTICATION_APP_NAME` | `Swetrix CE` | The app name shown in authenticator apps when users set up 2FA. |### Email configuration (SMTP)diff --git a/web/app/lib/constants/index.ts b/web/app/lib/constants/index.tsindex cef438a42..5460f46d7 100644--- a/web/app/lib/constants/index.ts+++ b/web/app/lib/constants/index.ts@@ -230,8 +230,8 @@ export const TRAFFIC_PANELS_ORDER = ['location','pg','devices',- 'network','traffic-sources',+ 'network',]export const PERFORMANCE_PANELS_ORDER = ['location', 'pg', 'devices', 'network']export const ERROR_PANELS_ORDER = ['location', 'pg', 'devices', 'network']diff --git a/web/app/pages/Project/View/Panels.tsx b/web/app/pages/Project/View/Panels.tsxindex ec746d777..c9e1ccd6b 100644--- a/web/app/pages/Project/View/Panels.tsx+++ b/web/app/pages/Project/View/Panels.tsx@@ -1022,23 +1022,31 @@ interface MetadataKeyPanelProps {mode: 'property' | 'customEvent'}-const MetadataKeyPanel = ({+interface MetadataKeyBodyProps extends Omit<+ MetadataKeyPanelProps,+ 'onKeyChange' | 'metadataKeys'+> {+ hasMetadataKeys: boolean+ onShowDetailsChange?: (canShowDetails: boolean) => void+ detailsTrigger?: number+}++const MetadataKeyBody = ({title,- metadataKeys,+ hasMetadataKeys,getMetadataValues,getFilterLink,chartData,filters,activeKey,- onKeyChange,filterPrefix,mode,-}: MetadataKeyPanelProps) => {+ onShowDetailsChange,+ detailsTrigger,+}: MetadataKeyBodyProps) => {const { t } = useTranslation('common')const navigate = useNavigate()const [loading, setLoading] = useState(false)- // For property mode: simple value/count pairs- // For customEvent mode: raw data with key/value/count (grouped by metadata key)const [valuesData, setValuesData] = useState<Array<{ value: string; count: number }>>([])@@ -1049,7 +1057,6 @@ const MetadataKeyPanel = ({const uniques = _sum(chartData.uniques)- // Load values when activeKey changesuseEffect(() => {if (!activeKey) {setValuesData([])@@ -1062,15 +1069,12 @@ const MetadataKeyPanel = ({try {const { result } = await getMetadataValues(activeKey)if (mode === 'property') {- // For properties: filter by the selected key and extract valuesconst values = result.filter((item) => item.key === activeKey).map((item) => ({ value: item.value, count: item.count }))setValuesData(values)} else {- // For custom events: show all metadata (result is already for this event)setRawMetadata(result)- // Flatten for display purposesconst values = result.map((item) => ({value: `${item.key}: ${item.value}`,count: item.count,@@ -1079,7 +1083,7 @@ const MetadataKeyPanel = ({}} catch (error) {console.error(- `[ERROR](MetadataKeyPanel) Failed to load values for key ${activeKey}`,+ `[ERROR](MetadataKeyBody) Failed to load values for key ${activeKey}`,error,)setValuesData([])@@ -1092,7 +1096,6 @@ const MetadataKeyPanel = ({loadValues()}, [activeKey, getMetadataValues, mode])- // Reload values when filters changeuseEffect(() => {if (activeKey) {const loadValues = async () => {@@ -1114,7 +1117,7 @@ const MetadataKeyPanel = ({}} catch (error) {console.error(- `[ERROR](MetadataKeyPanel) Failed to reload values for key ${activeKey}`,+ `[ERROR](MetadataKeyBody) Failed to reload values for key ${activeKey}`,error,)setValuesData([])@@ -1147,10 +1150,6 @@ const MetadataKeyPanel = ({return getFilterLink(`${filterPrefix}:${activeKey}`, value)}- const dropdownItems = useMemo(() => {- return metadataKeys.map((key) => ({ id: key, label: key }))- }, [metadataKeys])-const sortedRawMetadata = useMemo(() => _orderBy(rawMetadata, 'count', 'desc'),[rawMetadata],@@ -1264,8 +1263,23 @@ const MetadataKeyPanel = ({const hasExistingData =mode === 'customEvent' ? !_isEmpty(rawMetadata) : !_isEmpty(valuesData)+ const hasOverflowData =+ mode === 'customEvent'+ ? _size(rawMetadata) > ENTRIES_PER_PANEL+ : _size(valuesData) > ENTRIES_PER_PANEL++ useEffect(() => {+ onShowDetailsChange?.(hasOverflowData)+ }, [hasOverflowData, onShowDetailsChange])++ useEffect(() => {+ if (detailsTrigger && detailsTrigger > 0) {+ setDetailsOpened(true)+ }+ }, [detailsTrigger])+const renderContent = () => {- if (_isEmpty(metadataKeys)) {+ if (!hasMetadataKeys) {return <PanelEmptyState message={t('project.noParamData')} />}@@ -1468,27 +1482,174 @@ const MetadataKeyPanel = ({)}- const hasData =- mode === 'customEvent'- ? _size(rawMetadata) > ENTRIES_PER_PANEL- : _size(valuesData) > ENTRIES_PER_PANEL+ return <>{renderContent()}</>+}- return (- <PanelContainer- name={title}- type='metadataKey'- tabs={_isEmpty(dropdownItems) ? undefined : [dropdownItems]}- onTabChange={onKeyChange}- activeTabId={activeKey}- onDetailsClick={hasData ? () => setDetailsOpened(true) : undefined}- dropdownPlaceholder={- mode === 'customEvent'- ? t('project.selectEvent')- : t('project.selectProperty')+interface CombinedMetadataPanelProps {+ title: string+ property: {+ metadataKeys: string[]+ getMetadataValues: (key: string) => Promise<{+ result: Array<{ key: string; value: string; count: number }>+ }>+ activeKey: string+ onKeyChange: (key: string) => void+ }+ customEvent: {+ metadataKeys: string[]+ getMetadataValues: (key: string) => Promise<{+ result: Array<{ key: string; value: string; count: number }>+ }>+ activeKey: string+ onKeyChange: (key: string) => void+ }+ getFilterLink: (column: string, value: string | null) => LinkProps['to']+ chartData: any+ filters: Filter[]+}++const CombinedMetadataPanel = ({+ title,+ property,+ customEvent,+ getFilterLink,+ chartData,+ filters,+}: CombinedMetadataPanelProps) => {+ const { t } = useTranslation('common')+ const hasProperty = !_isEmpty(property.metadataKeys)+ const hasCustomEvent = !_isEmpty(customEvent.metadataKeys)++ const [activeMode, setActiveMode] = useState<'property' | 'customEvent'>(+ () => {+ if (hasProperty) return 'property'+ if (hasCustomEvent) return 'customEvent'+ return 'property'+ },+ )++ useEffect(() => {+ if (activeMode === 'property' && !hasProperty && hasCustomEvent) {+ setActiveMode('customEvent')+ } else if (activeMode === 'customEvent' && !hasCustomEvent && hasProperty) {+ setActiveMode('property')+ }+ }, [activeMode, hasProperty, hasCustomEvent])++ const activeSection = activeMode === 'property' ? property : customEvent+ const activeFilterPrefix: 'ev:key' | 'tag:key' =+ activeMode === 'property' ? 'tag:key' : 'ev:key'++ const dropdownItems = useMemo(+ () => activeSection.metadataKeys.map((key) => ({ id: key, label: key })),+ [activeSection.metadataKeys],+ )++ const modeTabs: Array<{ id: 'property' | 'customEvent'; label: string }> =+ useMemo(() => {+ const tabs: Array<{ id: 'property' | 'customEvent'; label: string }> = []+ if (hasProperty) {+ tabs.push({ id: 'property', label: t('project.pageviewMetadata') })}- >- {renderContent()}- </PanelContainer>+ if (hasCustomEvent) {+ tabs.push({ id: 'customEvent', label: t('project.customEvMetadata') })+ }+ return tabs+ }, [hasProperty, hasCustomEvent, t])++ const [canShowDetails, setCanShowDetails] = useState(false)+ const [detailsTrigger, setDetailsTrigger] = useState(0)++ const activeDropdownTab = dropdownItems.find(+ (item) => item.id === activeSection.activeKey,+ )+ const dropdownTitle = activeDropdownTab+ ? activeDropdownTab.label+ : activeMode === 'customEvent'+ ? t('project.selectEvent')+ : t('project.selectProperty')++ return (+ <div className='isolate overflow-hidden rounded-lg border border-gray-200 bg-white px-4 pt-5 pb-3 dark:border-slate-800/60 dark:bg-slate-900/25'>+ <div className='mb-2 flex items-center justify-between gap-4'>+ <Text+ as='h3'+ size='lg'+ weight='semibold'+ className='flex items-center leading-6 whitespace-nowrap'+ >+ {title}+ </Text>+ <div className='scrollbar-thin flex items-center gap-2.5 overflow-x-auto'>+ {modeTabs.map((tab) => (+ <button+ key={tab.id}+ type='button'+ onClick={() => setActiveMode(tab.id)}+ className={cx(+ 'relative border-b-2 py-1 text-sm font-bold whitespace-nowrap transition-all duration-200',+ {+ 'border-slate-900 text-slate-900 dark:border-gray-50 dark:text-gray-50':+ activeMode === tab.id,+ 'border-transparent text-gray-500 hover:border-gray-200 hover:text-gray-700 dark:text-gray-400 dark:hover:border-gray-200 dark:hover:text-gray-300':+ activeMode !== tab.id,+ },+ )}+ >+ {tab.label}+ </button>+ ))}+ {!_isEmpty(dropdownItems) ? (+ <Dropdown+ title={dropdownTitle}+ items={dropdownItems}+ labelExtractor={(item) => item.label}+ keyExtractor={(item) => item.id}+ onSelect={(item) => activeSection.onKeyChange(item.id)}+ buttonClassName={cx(+ 'relative border-b-2 px-0 py-1 text-sm font-bold whitespace-nowrap transition-all duration-200 md:px-0',+ {+ 'border-slate-900 text-slate-900 dark:border-gray-50 dark:text-gray-50':+ !!activeDropdownTab,+ 'border-transparent text-gray-500 hover:border-gray-200 hover:text-gray-700 dark:text-gray-400 dark:hover:border-gray-200 dark:hover:text-gray-300':+ !activeDropdownTab,+ },+ )}+ headless+ chevron='mini'+ />+ ) : null}+ </div>+ </div>+ <div className='relative flex h-[19.6rem] flex-col overflow-hidden'>+ <MetadataKeyBody+ key={activeMode}+ title={title}+ hasMetadataKeys={!_isEmpty(activeSection.metadataKeys)}+ getMetadataValues={activeSection.getMetadataValues}+ getFilterLink={getFilterLink}+ chartData={chartData}+ filters={filters}+ activeKey={activeSection.activeKey}+ filterPrefix={activeFilterPrefix}+ mode={activeMode}+ onShowDetailsChange={setCanShowDetails}+ detailsTrigger={detailsTrigger}+ />+ </div>+ {canShowDetails ? (+ <div className='mt-2 flex items-center justify-center'>+ <Button+ className='max-w-max border border-transparent bg-transparent px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-200 hover:bg-gray-50 dark:text-gray-200 hover:dark:border-slate-700/80 hover:dark:bg-slate-950'+ type='button'+ onClick={() => setDetailsTrigger((n) => n + 1)}+ >+ <ScanIcon className='mr-1.5 size-4' />+ <span>{t('common.details')}</span>+ </Button>+ </div>+ ) : null}+ </div>)}@@ -2641,13 +2802,15 @@ const MetadataPanel = ({ metadata }: MetadataPanelProps) => {const PanelMemo = memo(Panel) as typeof Panelconst CustomEventsMemo = memo(CustomEvents) as typeof CustomEvents-const MetadataKeyPanelMemo = memo(MetadataKeyPanel) as typeof MetadataKeyPanel+const CombinedMetadataPanelMemo = memo(+ CombinedMetadataPanel,+) as typeof CombinedMetadataPanelconst MetadataPanelMemo = memo(MetadataPanel) as typeof MetadataPanelexport {PanelContainer,PanelMemo as Panel,CustomEventsMemo as CustomEvents,- MetadataKeyPanelMemo as MetadataKeyPanel,+ CombinedMetadataPanelMemo as CombinedMetadataPanel,MetadataPanelMemo as MetadataPanel,}diff --git a/web/app/pages/Project/View/ViewProject.helpers.tsx b/web/app/pages/Project/View/ViewProject.helpers.tsxindex b0b8d36f5..64b474e76 100644--- a/web/app/pages/Project/View/ViewProject.helpers.tsx+++ b/web/app/pages/Project/View/ViewProject.helpers.tsx@@ -2548,6 +2548,22 @@ export const getDeviceRowMapper = (return undefined}+const sanitiseNetworkKey = (value: string) =>+ value.toLowerCase().replace(/[\s/]+/g, '_')++export const getUsageTypeLabel = (value: string, t: typeof i18next.t): string =>+ t(`project.usageTypeMapping.${sanitiseNetworkKey(value)}`, {+ defaultValue: value,+ }) as string++export const getConnectionTypeLabel = (+ value: string,+ t: typeof i18next.t,+): string =>+ t(`project.connectionTypeMapping.${sanitiseNetworkKey(value)}`, {+ defaultValue: value,+ }) as string+const getSettingsCaptcha = (chart: { x: string[]; results: number[] },timeBucket: string,diff --git a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx b/web/app/pages/Project/tabs/Errors/ErrorsView.tsxindex ca20e9a6a..301668220 100644--- a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx+++ b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx@@ -77,6 +77,8 @@ import {typeNameMapping,panelIconMapping,getDeviceRowMapper,+ getUsageTypeLabel,+ getConnectionTypeLabel,} from '~/pages/Project/View/ViewProject.helpers'import {useCurrentProject,@@ -1140,11 +1142,13 @@ const ErrorsViewInner = ({ deferredData }: ErrorsViewInnerProps) => {{ id: 'ctp', label: t('project.mapping.ctp') },]+ const activeNetworkTab = errorsActiveTabs.network+return (<Panel- key={errorsActiveTabs.network}+ key={activeNetworkTab}icon={panelIconMapping.isp}- id={errorsActiveTabs.network}+ id={activeNetworkTab}getFilterLink={getFilterLink}name={t('project.network')}tabs={networkTabs}@@ -1154,16 +1158,20 @@ const ErrorsViewInner = ({ deferredData }: ErrorsViewInnerProps) => {network: tab as 'isp' | 'og' | 'ut' | 'ctp',})}- activeTabId={errorsActiveTabs.network}- data={- activeError?.params?.[errorsActiveTabs.network] || []- }+ activeTabId={activeNetworkTab}+ data={activeError?.params?.[activeNetworkTab] || []}rowMapper={({ name: entryName }) => {if (!entryName) {return (<span className='italic'>{t('common.notSet')}</span>)}+ if (activeNetworkTab === 'ut') {+ return getUsageTypeLabel(entryName, t)+ }+ if (activeNetworkTab === 'ctp') {+ return getConnectionTypeLabel(entryName, t)+ }return entryName}}valuesHeaderName={t('project.occurrences')}diff --git a/web/app/pages/Project/tabs/Performance/PerformanceView.tsx b/web/app/pages/Project/tabs/Performance/PerformanceView.tsxindex 2d3a868c0..d235d80bc 100644--- a/web/app/pages/Project/tabs/Performance/PerformanceView.tsx+++ b/web/app/pages/Project/tabs/Performance/PerformanceView.tsx@@ -50,6 +50,8 @@ import {CHART_METRICS_MAPPING_PERF,CHART_MEASURES_MAPPING_PERF,getDeviceRowMapper,+ getUsageTypeLabel,+ getConnectionTypeLabel,} from '~/pages/Project/View/ViewProject.helpers'import { useCurrentProject } from '~/providers/CurrentProjectProvider'import { useTheme } from '~/providers/ThemeProvider'@@ -655,11 +657,13 @@ const PerformanceViewInner = ({{ id: 'ctp', label: t('project.mapping.ctp') },]+ const activeNetworkTab = activeTabs.network+return (<Panel- key={activeTabs.network}+ key={activeNetworkTab}icon={panelIconMapping.isp}- id={activeTabs.network}+ id={activeNetworkTab}getFilterLink={getFilterLink}name={t('project.network')}tabs={networkTabs}@@ -669,14 +673,20 @@ const PerformanceViewInner = ({network: tab as 'isp' | 'og' | 'ut' | 'ctp',})}- activeTabId={activeTabs.network}- data={panelsData.data[activeTabs.network]}+ activeTabId={activeNetworkTab}+ data={panelsData.data[activeNetworkTab]}rowMapper={({ name: entryName }) => {if (!entryName) {return (<span className='italic'>{t('common.notSet')}</span>)}+ if (activeNetworkTab === 'ut') {+ return getUsageTypeLabel(entryName, t)+ }+ if (activeNetworkTab === 'ctp') {+ return getConnectionTypeLabel(entryName, t)+ }return entryName}}// @ts-expect-errordiff --git a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx b/web/app/pages/Project/tabs/Traffic/TrafficView.tsxindex 2c4f70c40..23b2b21ec 100644--- a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx+++ b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx@@ -75,7 +75,7 @@ import {import {Panel,CustomEvents,- MetadataKeyPanel,+ CombinedMetadataPanel,} from '~/pages/Project/View/Panels'import { FILTER_CHART_METRICS_MAPPING_FOR_COMPARE } from '~/pages/Project/View/utils/filters'import {@@ -89,6 +89,8 @@ import {CHART_METRICS_MAPPING,getDeviceRowMapper,onCSVExportClick,+ getUsageTypeLabel,+ getConnectionTypeLabel,} from '~/pages/Project/View/ViewProject.helpers'import { useCurrentProject } from '~/providers/CurrentProjectProvider'import { useTheme } from '~/providers/ThemeProvider'@@ -1279,23 +1281,31 @@ const TrafficViewInner = ({{ id: 'ctp', label: t('project.mapping.ctp') },]+ const activeNetworkTab = panelsActiveTabs.network+return (<Panel- key={panelsActiveTabs.network}+ key={activeNetworkTab}icon={panelIconMapping.isp}- id={panelsActiveTabs.network}+ id={activeNetworkTab}getFilterLink={getFilterLink}name={t('project.network')}tabs={networkTabs}onTabChange={(tab) => setPanelTab('network', tab)}- activeTabId={panelsActiveTabs.network}- data={panelsData.data[panelsActiveTabs.network]}+ activeTabId={activeNetworkTab}+ data={panelsData.data[activeNetworkTab]}rowMapper={({ name: entryName }) => {if (!entryName) {return (<span className='italic'>{t('common.notSet')}</span>)}+ if (activeNetworkTab === 'ut') {+ return getUsageTypeLabel(entryName, t)+ }+ if (activeNetworkTab === 'ctp') {+ return getConnectionTypeLabel(entryName, t)+ }return entryName}}/>@@ -1447,44 +1457,35 @@ const TrafficViewInner = ({return null}): null}- {/* Custom Events Panel - Full Width */}- {!_isEmpty(panelsData.customs) ? (- <CustomEvents- customs={panelsData.customs}- filters={filters}+ {/* Combined Metadata Panel - holds both pageview properties and custom event metadata */}+ {!_isEmpty(panelsData.customs) || !_isEmpty(panelsData.properties) ? (+ <CombinedMetadataPanel+ title={t('project.metadata')}+ property={{+ metadataKeys: _keys(panelsData.properties),+ getMetadataValues: _getPropertyMetadata,+ activeKey: panelsActiveTabs.pageviewMetadata,+ onKeyChange: (key) => setPanelTab('pageviewMetadata', key),+ }}+ customEvent={{+ metadataKeys: _keys(panelsData.customs),+ getMetadataValues: getCustomEventMetadata,+ activeKey: panelsActiveTabs.customEvMetadata,+ onKeyChange: (key) => setPanelTab('customEvMetadata', key),+ }}getFilterLink={getFilterLink}chartData={chartData}- getCustomEventMetadata={getCustomEventMetadata}+ filters={filters}/>) : null}- {/* Custom Events Metadata Panel - Left */}+ {/* Custom Events Panel - Full Width */}{!_isEmpty(panelsData.customs) ? (- <MetadataKeyPanel- title={t('project.customEvMetadata')}- metadataKeys={_keys(panelsData.customs)}- getMetadataValues={getCustomEventMetadata}- getFilterLink={getFilterLink}- chartData={chartData}+ <CustomEvents+ customs={panelsData.customs}filters={filters}- activeKey={panelsActiveTabs.customEvMetadata}- onKeyChange={(key) => setPanelTab('customEvMetadata', key)}- filterPrefix='ev:key'- mode='customEvent'- />- ) : null}- {/* Pageview Metadata Panel - Right */}- {!_isEmpty(panelsData.properties) ? (- <MetadataKeyPanel- title={t('project.pageviewMetadata')}- metadataKeys={_keys(panelsData.properties)}- getMetadataValues={_getPropertyMetadata}getFilterLink={getFilterLink}chartData={chartData}- filters={filters}- activeKey={panelsActiveTabs.pageviewMetadata}- onKeyChange={(key) => setPanelTab('pageviewMetadata', key)}- filterPrefix='tag:key'- mode='property'+ getCustomEventMetadata={getCustomEventMetadata}/>) : null}</div>diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex e2fb9ff93..700143cb1 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -1572,6 +1572,7 @@"location": "Location","pages": "Pages","devices": "Devices",+ "network": "Network intelligence","trafficSources": "Traffic sources","metrics": {"xAvg": "\"{{x}}\" average",@@ -1767,6 +1768,42 @@"searchEngine": "Search engine","aiReferral": "AI referral"},+ "usageTypeMapping": {+ "business": "Business",+ "cafe": "Café",+ "cellular": "Cellular",+ "college": "College",+ "consumer_privacy_network": "Consumer privacy network",+ "content_delivery_network": "Content delivery network",+ "dialup": "Dialup",+ "government": "Government",+ "hosting": "Hosting",+ "library": "Library",+ "military": "Military",+ "organization": "Organisation",+ "residential": "Residential",+ "router": "Router",+ "school": "School",+ "search_engine_spider": "Search engine spider",+ "traveler": "Traveler",+ "commercial": "Commercial",+ "isp": "ISP",+ "mobile_isp": "Mobile ISP",+ "fixed_line_isp": "Fixed-line ISP",+ "university": "University",+ "educational": "Educational",+ "cdn": "Content delivery network",+ "reserved": "Reserved"+ },+ "connectionTypeMapping": {+ "cable_dsl": "Cable/DSL",+ "cellular": "Cellular",+ "corporate": "Corporate",+ "satellite": "Satellite",+ "dialup": "Dialup",+ "fiber": "Fiber",+ "wireless": "Wireless"+ },"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.","goToProjectSettings": "Go to Project Settings",