diff --git a/src/app/(main)/websites/[websiteId]/WebsiteControls.tsx b/src/app/(main)/websites/[websiteId]/WebsiteControls.tsx index 80b9024f8..bab23bc5b 100644 --- a/src/app/(main)/websites/[websiteId]/WebsiteControls.tsx +++ b/src/app/(main)/websites/[websiteId]/WebsiteControls.tsx @@ -8,6 +8,7 @@ import { WebsiteFilterButton } from '@/components/input/WebsiteFilterButton'; export function WebsiteControls({ websiteId, allowFilter = true, + allowBounceFilter = false, allowDateFilter = true, allowMonthFilter, allowDownload = false, @@ -25,7 +26,7 @@ export function WebsiteControls({ - {allowFilter && } + {allowFilter && } {allowDateFilter && ( diff --git a/src/app/share/[slug]/[[...path]]/ShareNav.tsx b/src/app/share/[slug]/[[...path]]/ShareNav.tsx index 3dd743444..1ad22926e 100644 --- a/src/app/share/[slug]/[[...path]]/ShareNav.tsx +++ b/src/app/share/[slug]/[[...path]]/ShareNav.tsx @@ -4,6 +4,7 @@ import { AlignEndHorizontal, Clock, Eye, PanelLeft, Sheet, Tag, User } from '@/c import { LanguageButton } from '@/components/input/LanguageButton'; import { PreferencesButton } from '@/components/input/PreferencesButton'; import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg'; +import { buildPath } from '@/lib/url'; import { Button, Column, @@ -29,10 +30,18 @@ export function ShareNav({ }) { const share = useShare(); const { t, labels } = useMessages(); - const { pathname } = useNavigation(); + const { pathname, query } = useNavigation(); const { slug, parameters } = share; - const renderPath = (path: string) => `/share/${slug}${path}`; + const renderPath = (path: string) => + buildPath(`/share/${slug}${path}`, { + ...query, + event: undefined, + compare: undefined, + view: undefined, + unit: undefined, + excludeBounce: undefined, + }); const allItems = [ { diff --git a/src/components/input/WebsiteFilterButton.tsx b/src/components/input/WebsiteFilterButton.tsx index ef6f54361..95bb0ba2f 100644 --- a/src/components/input/WebsiteFilterButton.tsx +++ b/src/components/input/WebsiteFilterButton.tsx @@ -8,8 +8,10 @@ import { filtersArrayToObject } from '@/lib/params'; export function WebsiteFilterButton({ websiteId, + allowBounceFilter, }: { websiteId?: string; + allowBounceFilter?: boolean; position?: 'bottom' | 'top' | 'left' | 'right'; alignment?: 'end' | 'center' | 'start'; }) { @@ -41,7 +43,7 @@ export function WebsiteFilterButton({ {({ close }) => { return ( <> - {isOverview && ( + {(isOverview || allowBounceFilter) && ( ) { } function getExcludeBounceQuery(filters: Record) { - if (!filters.excludeBounce === true) { + if (filters.excludeBounce !== true) { return ''; } diff --git a/src/lib/prisma.ts b/src/lib/prisma.ts index 19fd421ec..435ea812a 100644 --- a/src/lib/prisma.ts +++ b/src/lib/prisma.ts @@ -97,9 +97,9 @@ function mapFilter( case OPERATORS.doesNotContain: return `${table}.${column} not ilike ${value}`; case OPERATORS.regex: - return `${table}.${column} ~ ${value}`; + return `${table}.${column} ~* ${value}`; case OPERATORS.notRegex: - return `${table}.${column} !~ ${value}`; + return `${table}.${column} !~* ${value}`; default: return ''; } @@ -173,7 +173,7 @@ function getCohortQuery(filters: QueryFilters = {}) { } function getExcludeBounceQuery(filters: Record) { - if (!filters.excludeBounce === true) { + if (filters.excludeBounce !== true) { return ''; } @@ -278,7 +278,7 @@ async function rawQuery(sql: string, data: Record, name?: string): if (process.env.DATABASE_REPLICA_URL && '$replica' in client) { return client.$replica().$queryRawUnsafe(query, ...params); } - + console.log(query, params); return client.$queryRawUnsafe(query, ...params); } diff --git a/src/queries/sql/pageviews/getPageviewMetrics.ts b/src/queries/sql/pageviews/getPageviewMetrics.ts index 3edb25282..a7a705f1d 100644 --- a/src/queries/sql/pageviews/getPageviewMetrics.ts +++ b/src/queries/sql/pageviews/getPageviewMetrics.ts @@ -82,6 +82,7 @@ async function relationalQuery( where website_event.website_id = {{websiteId::uuid}} and website_event.created_at between {{startDate}} and {{endDate}} and website_event.event_type NOT IN (2, 5) + and ${column} != '' ${excludeDomain} ${filterQuery} group by 1 @@ -142,6 +143,7 @@ async function clickhouseQuery( where website_id = {websiteId:UUID} and created_at between {startDate:DateTime64} and {endDate:DateTime64} and event_type NOT IN (2, 5) + and ${column} != '' ${excludeDomain} ${filterQuery} group by x diff --git a/src/queries/sql/replays/getSessionReplays.ts b/src/queries/sql/replays/getSessionReplays.ts index ee9775b62..d7e1535b6 100644 --- a/src/queries/sql/replays/getSessionReplays.ts +++ b/src/queries/sql/replays/getSessionReplays.ts @@ -25,11 +25,11 @@ async function relationalQuery(websiteId: string, filters: QueryFilters, session const joinQuery = filterQuery || cohortQuery - ? `join (select distinct website_id, session_id, visit_id + ? `join (select distinct website_event.website_id, website_event.session_id, website_event.visit_id from website_event ${cohortQuery} - where website_id = {{websiteId::uuid}} - and created_at between {{startDate}} and {{endDate}} + where website_event.website_id = {{websiteId::uuid}} + and website_event.created_at between {{startDate}} and {{endDate}} ${filterQuery}) website_event on website_event.website_id = sr.website_id and website_event.session_id = sr.session_id diff --git a/src/queries/sql/sessions/getSessionMetrics.ts b/src/queries/sql/sessions/getSessionMetrics.ts index 59b2ebf82..2a5716bc1 100644 --- a/src/queries/sql/sessions/getSessionMetrics.ts +++ b/src/queries/sql/sessions/getSessionMetrics.ts @@ -58,8 +58,9 @@ async function relationalQuery( where website_event.website_id = {{websiteId::uuid}} and website_event.created_at between {{startDate}} and {{endDate}} and website_event.event_type NOT IN (2, 5) + and ${column} != '' ${filterQuery} - group by 1 + group by 1 ${includeCountry ? ', 3' : ''} order by 2 desc limit ${limit} @@ -102,8 +103,9 @@ async function clickhouseQuery( where website_id = {websiteId:UUID} and created_at between {startDate:DateTime64} and {endDate:DateTime64} and event_type NOT IN (2, 5) + and ${column} != '' ${filterQuery} - group by x + group by x ${includeCountry ? ', country' : ''} order by y desc limit ${limit} @@ -121,6 +123,7 @@ async function clickhouseQuery( where website_id = {websiteId:UUID} and created_at between {startDate:DateTime64} and {endDate:DateTime64} and event_type NOT IN (2, 5) + and ${column} != '' ${filterQuery} group by x ${includeCountry ? ', country' : ''}