: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): parse selectors with nth-child text and no colon (#98559)
Thomas Obermüller811206ea88f6
diff --git a/posthog/models/event/event.py b/posthog/models/event/event.pyindex 316988a89428..b69cbc125b2a 100644--- a/posthog/models/event/event.py+++ b/posthog/models/event/event.py@@ -39,7 +39,7 @@ class SelectorPart:self.data[f"attributes__attr__{result[2]}"] = result[3]self.ch_attributes[result[2]] = result[3]tag = result[1]- if "nth-child(" in tag:+ if ":nth-child(" in tag:parts = tag.split(":nth-child(")self.data["nth_child"] = parts[1].replace(")", "")self.ch_attributes["nth-child"] = self.data["nth_child"]diff --git a/posthog/models/test/test_event_model.py b/posthog/models/test/test_event_model.pyindex 7209bdb615d5..b2b6dc1916d3 100644--- a/posthog/models/test/test_event_model.py+++ b/posthog/models/test/test_event_model.py@@ -107,6 +107,19 @@ class TestSelectors(BaseTest):self.assertEqual(selector1.parts[1].direct_descendant, True)self.assertEqual(selector1.parts[1].unique_order, 0)+ @parameterized.expand(+ [+ (+ "a class name that contains the pseudo-class text",+ "div.foo-nth-child(2)",+ [{"tag_name": "div", "attr_class__contains": ["foo-nth-child(2)"]}],+ ),+ ("the pseudo-class text with no colon", "nth-child(2)", [{"tag_name": "nth-child(2)"}]),+ ]+ )+ def test_nth_child_without_a_colon_is_not_a_positional_selector(self, _name, selector, expected):+ self.assertEqual([part.data for part in Selector(selector).parts], expected)+def test_unique_order(self):selector1 = Selector("div > div")self.assertEqual(selector1.parts[0].data, {"tag_name": "div"})