@ -10,9 +10,7 @@ export const FILTER_GROUPS = {
'props' : [ 'prop_key' , 'prop_value' ]
}
export const ALLOW _FREE _CHOICE = new Set (
FILTER _GROUPS [ 'page' ] . concat ( FILTER _GROUPS [ 'utm' ] ) . concat ( [ 'prop_value' ] )
)
export const NO _CONTAINS _OPERATOR = new Set ( [ 'goal' , 'screen' ] . concat ( FILTER _GROUPS [ 'location' ] ) )
export const FILTER _OPERATIONS = {
isNot : 'is not' ,
@ -31,7 +29,7 @@ export function supportsIsNot(filterName) {
}
export function isFreeChoiceFilter ( filterName ) {
return ALLOW _FREE _CHOICE . has ( filterName )
return ! NO _CONTAINS _OPERATOR . has ( filterName )
}
// As of March 2023, Safari does not support negative lookbehind regexes. In case it throws an error, falls back to plain | matching. This means
@ -102,6 +100,11 @@ export function parseQueryFilter(query, filter) {
return { type , clauses }
}
export function isFilteringOnFixedValue ( query , filter ) {
const { type , clauses } = parseQueryFilter ( query , filter )
return type == FILTER _OPERATIONS . is && clauses . length == 1
}
export function formatFilterGroup ( filterGroup ) {
if ( filterGroup === 'utm' ) {
return 'UTM tags'