From 54dbfe1ca9f7963d6af96d8f9bdd3a08eb1e762d Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Wed, 25 Mar 2026 09:19:08 -0700 Subject: [PATCH] Support wildcard for goals report Closes #4086 --- src/queries/sql/reports/getGoal.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/queries/sql/reports/getGoal.ts b/src/queries/sql/reports/getGoal.ts index 4901bb28c..e6f425519 100644 --- a/src/queries/sql/reports/getGoal.ts +++ b/src/queries/sql/reports/getGoal.ts @@ -29,10 +29,18 @@ async function relationalQuery( const { rawQuery, parseFilters } = prisma; const eventType = type === 'path' ? EVENT_TYPE.pageView : EVENT_TYPE.customEvent; const column = type === 'path' ? 'url_path' : 'event_name'; + + let operator = '='; + let paramValue = value; + if (value.startsWith('*') || value.endsWith('*')) { + operator = 'like'; + paramValue = value.replace(/^\*|\*$/g, '%'); + } + const { filterQuery, dateQuery, joinSessionQuery, cohortQuery, queryParams } = parseFilters({ ...filters, websiteId, - value, + value: paramValue, startDate, endDate, eventType, @@ -60,7 +68,7 @@ async function relationalQuery( ${cohortQuery} ${joinSessionQuery} where website_event.website_id = {{websiteId::uuid}} - and ${column} = {{value}} + and ${column} ${operator} {{value}} ${dateQuery} ${filterQuery} `, @@ -77,10 +85,18 @@ async function clickhouseQuery( const { rawQuery, parseFilters } = clickhouse; const eventType = type === 'path' ? EVENT_TYPE.pageView : EVENT_TYPE.customEvent; const column = type === 'path' ? 'url_path' : 'event_name'; + + let operator = '='; + let paramValue = value; + if (value.startsWith('*') || value.endsWith('*')) { + operator = 'like'; + paramValue = value.replace(/^\*|\*$/g, '%'); + } + const { filterQuery, dateQuery, cohortQuery, queryParams } = parseFilters({ ...filters, websiteId, - value, + value: paramValue, startDate, endDate, eventType, @@ -106,7 +122,7 @@ async function clickhouseQuery( from website_event ${cohortQuery} where website_id = {websiteId:UUID} - and ${column} = {value:String} + and ${column} ${operator} {value:String} ${dateQuery} ${filterQuery} `,