Add distinct ID to filters/expanded metrics. Closes #3861

This commit is contained in:
Francis Cao 2026-01-26 11:05:20 -08:00
parent 7f43a0d41a
commit 7bb30443a8
9 changed files with 24 additions and 1 deletions

View file

@ -169,6 +169,12 @@ export function WebsiteExpandedMenu({
path: updateParams({ view: 'hostname' }), path: updateParams({ view: 'hostname' }),
icon: <Network />, icon: <Network />,
}, },
{
id: 'distinctId',
label: formatMessage(labels.distinctId),
path: updateParams({ view: 'distinctId' }),
icon: <Tag />,
},
{ {
id: 'tag', id: 'tag',
label: formatMessage(labels.tag), label: formatMessage(labels.tag),

View file

@ -93,6 +93,11 @@ export function CompareTables({ websiteId }: { websiteId: string }) {
label: formatMessage(labels.hostname), label: formatMessage(labels.hostname),
path: renderPath('hostname'), path: renderPath('hostname'),
}, },
{
id: 'distinctId',
label: formatMessage(labels.distinctId),
path: renderPath('distinctId'),
},
{ {
id: 'tag', id: 'tag',
label: formatMessage(labels.tags), label: formatMessage(labels.tags),

View file

@ -15,6 +15,7 @@ export function useFields() {
{ name: 'region', type: 'string', label: formatMessage(labels.region) }, { name: 'region', type: 'string', label: formatMessage(labels.region) },
{ name: 'city', type: 'string', label: formatMessage(labels.city) }, { name: 'city', type: 'string', label: formatMessage(labels.city) },
{ name: 'hostname', type: 'string', label: formatMessage(labels.hostname) }, { name: 'hostname', type: 'string', label: formatMessage(labels.hostname) },
{ name: 'distinctId', type: 'string', label: formatMessage(labels.distinctId) },
{ name: 'tag', type: 'string', label: formatMessage(labels.tag) }, { name: 'tag', type: 'string', label: formatMessage(labels.tag) },
{ name: 'event', type: 'string', label: formatMessage(labels.event) }, { name: 'event', type: 'string', label: formatMessage(labels.event) },
]; ];

View file

@ -18,6 +18,7 @@ export function useFilterParameters() {
event, event,
tag, tag,
hostname, hostname,
distinctId,
page, page,
pageSize, pageSize,
search, search,
@ -42,6 +43,7 @@ export function useFilterParameters() {
event, event,
tag, tag,
hostname, hostname,
distinctId,
search, search,
segment, segment,
cohort, cohort,
@ -61,6 +63,7 @@ export function useFilterParameters() {
event, event,
tag, tag,
hostname, hostname,
distinctId,
page, page,
pageSize, pageSize,
search, search,

View file

@ -61,7 +61,9 @@ export function FilterEditForm({ websiteId, onChange, onClose }: FilterEditFormP
websiteId={websiteId} websiteId={websiteId}
value={currentFilters} value={currentFilters}
onChange={setCurrentFilters} onChange={setCurrentFilters}
exclude={excludeFilters ? ['path', 'title', 'hostname', 'tag', 'event'] : []} exclude={
excludeFilters ? ['path', 'title', 'hostname', 'distinctId', 'tag', 'event'] : []
}
/> />
</TabPanel> </TabPanel>
<TabPanel id="segments"> <TabPanel id="segments">

View file

@ -55,6 +55,7 @@ export const SESSION_COLUMNS = [
'country', 'country',
'city', 'city',
'region', 'region',
'distinctId',
]; ];
export const SEGMENT_TYPES = { export const SEGMENT_TYPES = {
@ -69,6 +70,7 @@ export const FILTER_COLUMNS = {
referrer: 'referrer_domain', referrer: 'referrer_domain',
domain: 'referrer_domain', domain: 'referrer_domain',
hostname: 'hostname', hostname: 'hostname',
distinctId: 'distinct_id',
title: 'page_title', title: 'page_title',
query: 'url_query', query: 'url_query',
os: 'os', os: 'os',

View file

@ -36,6 +36,7 @@ export const filterParams = {
city: z.string().optional(), city: z.string().optional(),
tag: z.string().optional(), tag: z.string().optional(),
hostname: z.string().optional(), hostname: z.string().optional(),
distinctId: z.string().optional(),
language: z.string().optional(), language: z.string().optional(),
event: z.string().optional(), event: z.string().optional(),
segment: z.uuid().optional(), segment: z.uuid().optional(),
@ -89,6 +90,7 @@ export const fieldsParam = z.enum([
'city', 'city',
'tag', 'tag',
'hostname', 'hostname',
'distinctId',
'language', 'language',
'event', 'event',
]); ]);

View file

@ -72,6 +72,7 @@ async function relationalQuery(
${filterQuery} ${filterQuery}
group by name, website_event.session_id, website_event.visit_id group by name, website_event.session_id, website_event.visit_id
) as t ) as t
where name != ''
group by name group by name
order by visitors desc, visits desc order by visitors desc, visits desc
limit ${limit} limit ${limit}

View file

@ -82,6 +82,7 @@ async function relationalQuery(
group by name, website_event.session_id, website_event.visit_id group by name, website_event.session_id, website_event.visit_id
${includeCountry ? ', country' : ''} ${includeCountry ? ', country' : ''}
) as t ) as t
where name != ''
group by name group by name
${includeCountry ? ', country' : ''} ${includeCountry ? ', country' : ''}
order by visitors desc, visits desc order by visitors desc, visits desc