From 708a58ef15107f4c05bb427f1b54b2921503c194 Mon Sep 17 00:00:00 2001 From: David Newell Date: Fri, 26 Jul 2024 16:14:47 +0100 Subject: [PATCH] fix tests --- .../test_error_tracking_query_runner.ambr | 10 +++++++-- .../test/test_error_tracking_query_runner.py | 22 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr b/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr index ea4a62a503a93..5063b17d2a1c5 100644 --- a/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr +++ b/posthog/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr @@ -7,6 +7,7 @@ max(toTimeZone(events.timestamp, 'UTC')) AS last_seen, min(toTimeZone(events.timestamp, 'UTC')) AS first_seen, any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description, + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_type'), ''), 'null'), '^"|"$', '')) AS exception_type, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '') AS fingerprint FROM events INNER JOIN @@ -47,7 +48,8 @@ count(DISTINCT events.distinct_id) AS users, max(toTimeZone(events.timestamp, 'UTC')) AS last_seen, min(toTimeZone(events.timestamp, 'UTC')) AS first_seen, - any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description, + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_type'), ''), 'null'), '^"|"$', '')) AS exception_type FROM events INNER JOIN (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS events__pdi___person_id, @@ -87,6 +89,7 @@ max(toTimeZone(events.timestamp, 'UTC')) AS last_seen, min(toTimeZone(events.timestamp, 'UTC')) AS first_seen, any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description, + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_type'), ''), 'null'), '^"|"$', '')) AS exception_type, groupArray(tuple(events.uuid, events.distinct_id, events.distinct_id)) AS events FROM events INNER JOIN @@ -126,7 +129,8 @@ count(DISTINCT events.distinct_id) AS users, max(toTimeZone(events.timestamp, 'UTC')) AS last_seen, min(toTimeZone(events.timestamp, 'UTC')) AS first_seen, - any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description, + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_type'), ''), 'null'), '^"|"$', '')) AS exception_type FROM events WHERE and(equals(events.team_id, 2), equals(events.event, '$exception'), 1, ifNull(in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', ''), ['SyntaxError']), 0)) LIMIT 101 @@ -148,6 +152,7 @@ max(toTimeZone(events.timestamp, 'UTC')) AS last_seen, min(toTimeZone(events.timestamp, 'UTC')) AS first_seen, any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description, + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_type'), ''), 'null'), '^"|"$', '')) AS exception_type, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '') AS fingerprint FROM events INNER JOIN @@ -189,6 +194,7 @@ max(toTimeZone(events.timestamp, 'UTC')) AS last_seen, min(toTimeZone(events.timestamp, 'UTC')) AS first_seen, any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_message'), ''), 'null'), '^"|"$', '')) AS description, + any(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$exception_type'), ''), 'null'), '^"|"$', '')) AS exception_type, groupArray(tuple(events.uuid, events.distinct_id, events.distinct_id)) AS events FROM events INNER JOIN diff --git a/posthog/hogql_queries/test/test_error_tracking_query_runner.py b/posthog/hogql_queries/test/test_error_tracking_query_runner.py index 7521a611b0a8a..1d2b171d8c368 100644 --- a/posthog/hogql_queries/test/test_error_tracking_query_runner.py +++ b/posthog/hogql_queries/test/test_error_tracking_query_runner.py @@ -53,6 +53,7 @@ def setUp(self): team=self.team, properties={ "$exception_fingerprint": "SyntaxError", + "$exception_type": "SyntaxError", "$exception_message": "this is the same error message", }, ) @@ -62,6 +63,7 @@ def setUp(self): team=self.team, properties={ "$exception_fingerprint": "TypeError", + "$exception_type": "TypeError", }, ) _create_event( @@ -70,6 +72,7 @@ def setUp(self): team=self.team, properties={ "$exception_fingerprint": "SyntaxError", + "$exception_type": "SyntaxError", "$exception_message": "this is the same error message", }, ) @@ -79,6 +82,7 @@ def setUp(self): team=self.team, properties={ "$exception_fingerprint": "custom_fingerprint", + "$exception_type": "SyntaxError", "$exception_message": "this is the same error message", }, ) @@ -102,7 +106,17 @@ def test_column_names(self): columns = self._calculate(runner)["columns"] self.assertEqual( - columns, ["occurrences", "sessions", "users", "last_seen", "first_seen", "description", "fingerprint"] + columns, + [ + "occurrences", + "sessions", + "users", + "last_seen", + "first_seen", + "description", + "exception_type", + "fingerprint", + ], ) runner = ErrorTrackingQueryRunner( @@ -125,6 +139,7 @@ def test_column_names(self): "last_seen", "first_seen", "description", + "exception_type", ], ) @@ -143,7 +158,8 @@ def test_column_names(self): columns = result["columns"] # only adds the events column when fields are specificed in `eventColumns` self.assertEqual( - columns, ["occurrences", "sessions", "users", "last_seen", "first_seen", "description", "events"] + columns, + ["occurrences", "sessions", "users", "last_seen", "first_seen", "description", "exception_type", "events"], ) @snapshot_clickhouse_queries @@ -279,6 +295,7 @@ def test_merges_and_defaults_groups(self): { "assignee": self.user.id, "description": "this is the same error message", + "exception_type": "SyntaxError", "events": None, "fingerprint": "SyntaxError", "first_seen": datetime(2020, 1, 10, 12, 11, tzinfo=ZoneInfo("UTC")), @@ -294,6 +311,7 @@ def test_merges_and_defaults_groups(self): { "assignee": None, "description": None, + "exception_type": "TypeError", "events": None, "fingerprint": "TypeError", "first_seen": datetime(2020, 1, 10, 12, 11, tzinfo=ZoneInfo("UTC")),