:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(actions): widen selector regex to traverse any class characters (#83169)
Thomas Obermüller1b114bf0652f
diff --git a/posthog/hogql/test/test_action_to_expr.py b/posthog/hogql/test/test_action_to_expr.pyindex 001a385adc55..c46579cf819a 100644--- a/posthog/hogql/test/test_action_to_expr.py+++ b/posthog/hogql/test/test_action_to_expr.py@@ -42,7 +42,7 @@ class TestActionToExpr(BaseTest):"elements_chain =~ {regex}",{"regex": ast.Constant(- value='(^|;)a.*?\\.active\\..*?nav\\-link([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'+ value="(^|;)a.*?\\.active\\..*?nav\\-link[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))")},),diff --git a/posthog/hogql/test/test_property.py b/posthog/hogql/test/test_property.pyindex 7a326882c0d6..cab992258314 100644--- a/posthog/hogql/test/test_property.py+++ b/posthog/hogql/test/test_property.py@@ -835,16 +835,12 @@ class TestProperty(BaseTest):def test_selector_to_expr(self):self.assertEqual(self._selector_to_expr("div"),- clear_locations(- elements_chain_match('(^|;)div([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))')- ),+ clear_locations(elements_chain_match("(^|;)div[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))")),)self.assertEqual(self._selector_to_expr("div > div"),clear_locations(- elements_chain_match(- '(^|;)div([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))div([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s))).*'- )+ elements_chain_match("(^|;)div[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))div[^;]*?($|;|:([^;^\\s]*(;|$|\\s))).*")),)self.assertEqual(@@ -852,32 +848,20 @@ class TestProperty(BaseTest):clear_locations(parse_expr("{regex} and arrayCount(x -> x IN ['a'], elements_chain_elements) > 0",- {- "regex": elements_chain_match(- '(^|;)a.*?href="boo".*?([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'- )- },+ {"regex": elements_chain_match('(^|;)a.*?href="boo".*?[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))')},)),)self.assertEqual(self._selector_to_expr(".class"),- clear_locations(- elements_chain_match(- '(^|;).*?\\.class([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'- )- ),+ clear_locations(elements_chain_match("(^|;).*?\\.class[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))")),)self.assertEqual(self._selector_to_expr("a#withid"),clear_locations(parse_expr("""{regex} and indexOf(elements_chain_ids, 'withid') > 0 and arrayCount(x -> x IN ['a'], elements_chain_elements) > 0""",- {- "regex": elements_chain_match(- '(^|;)a.*?attr_id="withid".*?([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'- )- },+ {"regex": elements_chain_match('(^|;)a.*?attr_id="withid".*?[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))')},)),)@@ -889,7 +873,7 @@ class TestProperty(BaseTest):"""{regex} and indexOf(elements_chain_ids, 'with-dashed-id') > 0 and arrayCount(x -> x IN ['a'], elements_chain_elements) > 0""",{"regex": elements_chain_match(- '(^|;)a.*?attr_id="with\\-dashed\\-id".*?([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'+ '(^|;)a.*?attr_id="with\\-dashed\\-id".*?[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))')},)@@ -919,9 +903,7 @@ class TestProperty(BaseTest):self.assertEqual(self._selector_to_expr(".sm:[max-width:640px]"),clear_locations(- elements_chain_match(- '(^|;).*?\\.sm:\\[max\\-width:640px\\]([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'- )+ elements_chain_match("(^|;).*?\\.sm:\\[max\\-width:640px\\][^;]*?($|;|:([^;^\\s]*(;|$|\\s)))")),)@@ -929,9 +911,7 @@ class TestProperty(BaseTest):self.assertEqual(self._selector_to_expr(".w-[calc(100%-2rem)]"),clear_locations(- elements_chain_match(- '(^|;).*?\\.w\\-\\[calc\\(100%\\-2rem\\)\\]([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'- )+ elements_chain_match("(^|;).*?\\.w\\-\\[calc\\(100%\\-2rem\\)\\][^;]*?($|;|:([^;^\\s]*(;|$|\\s)))")),)@@ -940,11 +920,17 @@ class TestProperty(BaseTest):self._selector_to_expr(".shadow-[0_4px_6px_rgba(0,0,0,0.1)]"),clear_locations(elements_chain_match(- '(^|;).*?\\.shadow\\-\\[0_4px_6px_rgba\\(0,0,0,0\\.1\\)\\]([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'+ "(^|;).*?\\.shadow\\-\\[0_4px_6px_rgba\\(0,0,0,0\\.1\\)\\][^;]*?($|;|:([^;^\\s]*(;|$|\\s)))")),)+ # Test Tailwind fraction/opacity class with a slash+ self.assertEqual(+ self._selector_to_expr(".bg-yellow/50"),+ clear_locations(elements_chain_match("(^|;).*?\\.bg\\-yellow/50[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))")),+ )+def test_cohort_filter_static(self):cohort = Cohort.objects.create(team=self.team,diff --git a/posthog/models/property/util.py b/posthog/models/property/util.pyindex 82fa42383f07..9a0d60cbb41b 100644--- a/posthog/models/property/util.py+++ b/posthog/models/property/util.py@@ -931,6 +931,14 @@ def process_ok_values(ok_values: Any, operator: OperatorType) -> list[str]:return [re.escape(text) for text in ok_values]+def _chain_escaped_value(value: str) -> str:+ # A quoted value in the chain escapes double quotes as \" (_escape in+ # posthog/models/element/element.py). A selector can write the quote either+ # pre-escaped ([title="say \"hi\""]) or bare inside single quotes+ # ([title='say "hi"']), so normalize to the chain's form to match both.+ return value.replace(r"\"", '"').replace('"', r"\"")++def build_selector_regex(selector: Selector) -> str:regex = r""for tag in selector.parts:@@ -942,8 +950,11 @@ def build_selector_regex(selector: Selector) -> str:if tag.ch_attributes:regex += r".*?"for key, value in sorted(tag.ch_attributes.items()):- regex += rf'{re.escape(key)}="{re.escape(str(value))}".*?'- regex += r'([-_a-zA-Z0-9\.:"= \[\]\(\),]*?)?($|;|:([^;^\s]*(;|$|\s)))'+ regex += rf'{re.escape(key)}="{re.escape(_chain_escaped_value(str(value)))}".*?'+ # The rest of the element can carry characters an allowlist cannot+ # anticipate (classes like w-1/2 or !mt-0), so skip anything up to the+ # `;` element separator.+ regex += r"[^;]*?($|;|:([^;^\s]*(;|$|\s)))"if tag.direct_descendant:regex += r".*"if regex:diff --git a/posthog/models/test/test_event_model.py b/posthog/models/test/test_event_model.pyindex d8d67297fd1b..335d477c365b 100644--- a/posthog/models/test/test_event_model.py+++ b/posthog/models/test/test_event_model.py@@ -1,7 +1,15 @@+import re+from posthog.test.base import BaseTest+from django.test import SimpleTestCase++from parameterized import parameterized+from posthog.models import Element, Organization+from posthog.models.element.element import elements_to_stringfrom posthog.models.event import Selector+from posthog.models.property.util import build_selector_regexfrom products.actions.backend.models.action import Action@@ -803,3 +811,160 @@ class TestSelectors(BaseTest):# Make sure we strip these for full text search to work in the databaseselector1 = Selector("div#root\\:id")self.assertEqual(selector1.parts[0].data, {"tag_name": "div", "attr_id": "root:id"})+++class TestSelectorRegexMatching(SimpleTestCase):+ @parameterized.expand(+ [+ (+ "a sibling class the selector does not name can carry any character",+ ".flex",+ [Element(tag_name="div", attr_class=["flex", "w-1/2", "!mt-0", "hover:bg-blue-500/75"])],+ True,+ ),+ (+ "a target class can carry slashes and bangs",+ ".bg-yellow/50",+ [Element(tag_name="div", attr_class=["bg-yellow/50"])],+ True,+ ),+ (+ "a tailwind arbitrary-value target class",+ ".max-w-[1045px]",+ [Element(tag_name="div", attr_class=["max-w-[1045px]"])],+ True,+ ),+ (+ "an attribute value with a pre-escaped quote",+ 'div[title="say \\"hi\\""]',+ [Element(tag_name="div", attributes={"attr__title": 'say "hi"'})],+ True,+ ),+ (+ "a single-quoted attribute value containing double quotes",+ "div[title='say \"hi\"']",+ [Element(tag_name="div", attributes={"attr__title": 'say "hi"'})],+ True,+ ),+ (+ "a neighboring attribute value containing a quote",+ 'div[title="hi"]',+ [Element(tag_name="div", attributes={"attr__data-x": 'a"b', "attr__title": "hi"})],+ True,+ ),+ (+ "a semicolon inside an attribute value stays inside the element",+ 'input[type="text"]',+ [+ Element(+ tag_name="input", attributes={"attr__style": "display: flex; gap: 4px", "attr__type": "text"}+ )+ ],+ True,+ ),+ (+ "attribute value mismatch",+ 'div[title="hi"]',+ [Element(tag_name="div", attributes={"attr__title": "bye"})],+ False,+ ),+ (+ "class not on the element",+ ".flex",+ [Element(tag_name="div", attr_class=["lex"])],+ False,+ ),+ (+ "direct child combinator still matches parent and child",+ "a > b",+ [Element(tag_name="b"), Element(tag_name="a")],+ True,+ ),+ (+ "descendant combinator still matches parent and child",+ "a b",+ [Element(tag_name="b"), Element(tag_name="a")],+ True,+ ),+ (+ "direct child combinator does not match the reversed order",+ "a > b",+ [Element(tag_name="a"), Element(tag_name="b")],+ False,+ ),+ ]+ )+ def test_selector_matches_elements_chain(self, _name, selector, elements, expected):+ regex = build_selector_regex(Selector(selector, escape_slashes=False))+ self.assertEqual(bool(re.search(regex, elements_to_string(elements))), expected)+++class TestSelectorRegexMonotonicity(SimpleTestCase):+ SELECTORS = [+ ".flex",+ ".class",+ ".bg-yellow/50",+ ".!ml-auto",+ ".max-w-[1045px]",+ "div",+ "a > b",+ "a b",+ 'div[title="say \\"hi\\""]',+ "div[title='say \"hi\"']",+ 'a[href="/pricing"]',+ '[id="submit"]',+ "button.btn:nth-child(3)",+ ]++ ELEMENT_CHAINS = [+ [Element(tag_name="div", attr_class=["flex", "w-1/2"])],+ [Element(tag_name="div", attr_class=["bg-yellow/50", "!ml-auto"])],+ [Element(tag_name="div", attr_class=["max-w-[1045px]", "shadow-[0_4px_6px_rgba(0,0,0,0.1)]"])],+ [Element(tag_name="div", attr_class=["class"], attributes={"attr__title": 'say "hi"'})],+ [Element(tag_name="input", attributes={"attr__style": "display: flex; gap: 4px", "attr__type": "text"})],+ [Element(tag_name="b"), Element(tag_name="a")],+ [Element(tag_name="b"), Element(tag_name="div"), Element(tag_name="a")],+ [Element(tag_name="a", href="/pricing", attr_class=["px-2", "hover:underline"])],+ [Element(tag_name="button", attr_class=["btn"], nth_child=3), Element(tag_name="form")],+ [Element(tag_name="button", attr_id="submit", attributes={"attr__type": "button"})],+ # an attribute value that itself looks like a class followed by more text,+ # which the old tail could wander into+ [Element(tag_name="span", attributes={"attr__title": "x.class y"})],+ ]++ @staticmethod+ def _pre_fix_build_selector_regex(selector: Selector) -> str:+ # Frozen copy of build_selector_regex from before the tail and+ # quote-escaping fix, kept to prove the fix only widens matching.+ regex = r""+ for tag in selector.parts:+ if tag.data.get("tag_name") and isinstance(tag.data["tag_name"], str) and tag.data["tag_name"] != "*":+ regex += re.escape(tag.data["tag_name"])+ if tag.data.get("attr_class__contains"):+ regex += r".*?\." + r"\..*?".join([re.escape(s) for s in sorted(tag.data["attr_class__contains"])])+ if tag.ch_attributes:+ regex += r".*?"+ for key, value in sorted(tag.ch_attributes.items()):+ regex += rf'{re.escape(key)}="{re.escape(str(value))}".*?'+ regex += r'([-_a-zA-Z0-9\.:"= \[\]\(\),]*?)?($|;|:([^;^\s]*(;|$|\s)))'+ if tag.direct_descendant:+ regex += r".*"+ return r"(^|;)" + regex if regex else r""++ def test_fix_only_widens_matching(self):+ chains = [elements_to_string(elements) for elements in self.ELEMENT_CHAINS]+ newly_matching_pairs = 0+ for selector_string in self.SELECTORS:+ selector = Selector(selector_string, escape_slashes=False)+ old_regex = self._pre_fix_build_selector_regex(selector)+ new_regex = build_selector_regex(selector)+ for chain in chains:+ old_match = bool(re.search(old_regex, chain))+ new_match = bool(re.search(new_regex, chain))+ with self.subTest(selector=selector_string, chain=chain):+ if old_match:+ self.assertTrue(new_match)+ if new_match and not old_match:+ newly_matching_pairs += 1+ # the corpus has to exercise the widening, or the superset check is vacuous+ self.assertGreater(newly_matching_pairs, 0)diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.ambrindex 8f539aae7de2..25f2aee305ac 100644--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.ambr+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_goals.ambr@@ -24,12 +24,12 @@FROM(SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS web_goals_person_id,min(events__session.`$start_timestamp`) AS start_timestamp,- countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?data\\-node\\-key="interactions".*?([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),- (SELECT cohortpeople.person_id AS person_id- FROM cohortpeople- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))- GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version- HAVING greater(sum(cohortpeople.sign), 0)))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_0,+ countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?data\\-node\\-key="interactions".*?[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),+ (SELECT cohortpeople.person_id AS person_id+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))+ GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version+ HAVING greater(sum(cohortpeople.sign), 0)))), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_0,countIf(0) AS action_previous_count_0,if(greater(action_current_count_0, 0), web_goals_person_id, NULL) AS action_current_person_id_0,if(greater(action_previous_count_0, 0), web_goals_person_id, NULL) AS action_previous_person_id_0,@@ -37,15 +37,15 @@countIf(0) AS action_previous_count_1,if(greater(action_current_count_1, 0), web_goals_person_id, NULL) AS action_current_person_id_1,if(greater(action_previous_count_1, 0), web_goals_person_id, NULL) AS action_previous_person_id_1,- countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-input([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_2,+ countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-input[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_2,countIf(0) AS action_previous_count_2,if(greater(action_current_count_2, 0), web_goals_person_id, NULL) AS action_current_person_id_2,if(greater(action_previous_count_2, 0), web_goals_person_id, NULL) AS action_previous_person_id_2,- countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-btn\\..*?text\\-white([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), arrayExists(x -> ifNull(equals(x, 'text page'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_3,+ countIf(and(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-btn\\..*?text\\-white[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), arrayExists(x -> ifNull(equals(x, 'text page'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_3,countIf(0) AS action_previous_count_3,if(greater(action_current_count_3, 0), web_goals_person_id, NULL) AS action_current_person_id_3,if(greater(action_previous_count_3, 0), web_goals_person_id, NULL) AS action_previous_person_id_3,- countIf(and(and(equals(events.event, '$autocapture'), and(match(events.elements_chain, '(^|;)a([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s))).*?\\.ant\\-btn([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), greater(arrayCount(x -> in(x, ['a']), events.elements_chain_elements), 0)), arrayExists(x -> ifNull(equals(x, 'text'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_4,+ countIf(and(and(equals(events.event, '$autocapture'), and(match(events.elements_chain, '(^|;)a[^;]*?($|;|:([^;^\\s]*(;|$|\\s))).*?\\.ant\\-btn[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), greater(arrayCount(x -> in(x, ['a']), events.elements_chain_elements), 0)), arrayExists(x -> ifNull(equals(x, 'text'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))))) AS action_current_count_4,countIf(0) AS action_previous_count_4,if(greater(action_current_count_4, 0), web_goals_person_id, NULL) AS action_current_person_id_4,if(greater(action_previous_count_4, 0), web_goals_person_id, NULL) AS action_previous_person_id_4@@ -63,12 +63,12 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(isNotNull(events.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?data\\-node\\-key="interactions".*?([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),- (SELECT cohortpeople.person_id AS person_id- FROM cohortpeople- WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))- GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version- HAVING greater(sum(cohortpeople.sign), 0)))), and(equals(events.event, '$pageview'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-input([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-btn\\..*?text\\-white([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), arrayExists(x -> ifNull(equals(x, 'text page'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)), and(equals(events.event, '$autocapture'), and(match(events.elements_chain, '(^|;)a([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s))).*?\\.ant\\-btn([-_a-zA-Z0-9\\.:"= \\[\\]\\(\\),]*?)?($|;|:([^;^\\s]*(;|$|\\s)))'), greater(arrayCount(x -> in(x, ['a']), events.elements_chain_elements), 0)), arrayExists(x -> ifNull(equals(x, 'text'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'mat_$host'), ''), 'null'), '^"|"$', ''), 'teest.com'), 0), ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'mat_$current_url'), ''), 'null'), '^"|"$', '')), '%https://teest.com%'), 0)), 1))+ WHERE and(equals(events.team_id, 99999), and(isNotNull(events.`$session_id`), or(equals(events.event, '$pageview'), equals(events.event, '$screen'), or(and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?data\\-node\\-key="interactions".*?[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0), in(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id),+ (SELECT cohortpeople.person_id AS person_id+ FROM cohortpeople+ WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, 99999))+ GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version+ HAVING greater(sum(cohortpeople.sign), 0)))), and(equals(events.event, '$pageview'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-input[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), ifNull(like(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), '%https://teest.com%'), 0)), and(equals(events.event, '$autocapture'), match(events.elements_chain, '(^|;).*?\\.ant\\-btn\\..*?text\\-white[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), arrayExists(x -> ifNull(equals(x, 'text page'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)), and(equals(events.event, '$autocapture'), and(match(events.elements_chain, '(^|;)a[^;]*?($|;|:([^;^\\s]*(;|$|\\s))).*?\\.ant\\-btn[^;]*?($|;|:([^;^\\s]*(;|$|\\s)))'), greater(arrayCount(x -> in(x, ['a']), events.elements_chain_elements), 0)), arrayExists(x -> ifNull(equals(x, 'text'), 0), events.elements_chain_texts), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$current_url'), ''), 'null'), '^"|"$', ''), 'https://teest.com'), 0)))), or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'mat_$host'), ''), 'null'), '^"|"$', ''), 'teest.com'), 0), ifNull(ilike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'mat_$current_url'), ''), 'null'), '^"|"$', '')), '%https://teest.com%'), 0)), 1))GROUP BY events.`$session_id`)WHERE or(and(greaterOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-28 00:00:00', 'UTC'))), lessOrEquals(start_timestamp, assumeNotNull(toDateTime('2025-01-29 23:59:59', 'UTC')))), 0)LIMIT 100 SETTINGS readonly=2,