: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(health-checks): remove incorrectly applied grace period for SDK releases (#63368)
Steven Shultsfd026c117361
diff --git a/posthog/api/health_issue.py b/posthog/api/health_issue.pyindex f6d92aa3f75c..9004d867c6ba 100644--- a/posthog/api/health_issue.py+++ b/posthog/api/health_issue.py@@ -22,8 +22,6 @@ from posthog.exceptions_capture import capture_exceptionfrom posthog.models.health_issue import HealthIssuefrom posthog.rate_limit import HealthIssueRefreshThrottle-from products.growth.backend.sdk_health import sdks_within_freshness_grace_period-@extend_schema_field(OpenApiTypes.OBJECT)class HealthIssuePayloadField(serializers.JSONField):@@ -277,9 +275,6 @@ class HealthIssueViewSet(TeamAndOrgViewSetMixin, ListModelMixin, RetrieveModelMi.order_by("severity_order", "-created_at"))- if fresh_sdks := sdks_within_freshness_grace_period():- queryset = queryset.exclude(kind="sdk_outdated", payload__sdk_name__in=fresh_sdks)-if status_filter := self.request.query_params.get("status"):if status_filter not in VALID_STATUSES:raise serializers.ValidationError({"status": f"Invalid status: {status_filter}"})diff --git a/posthog/api/test/test_health_issue.py b/posthog/api/test/test_health_issue.pyindex 2540373f78c9..a3f3ecda912c 100644--- a/posthog/api/test/test_health_issue.py+++ b/posthog/api/test/test_health_issue.py@@ -1,3 +1,6 @@+import json+from datetime import UTC, datetime, timedelta+from posthog.test.base import APIBaseTestfrom unittest.mock import patch@@ -8,6 +11,9 @@ from rest_framework import statusfrom posthog.models.health_issue import HealthIssuefrom posthog.models.team import Team+from posthog.redis import get_client++from products.growth.backend.constants import github_sdk_versions_keyclass TestHealthIssueAPI(APIBaseTest):@@ -261,6 +267,33 @@ class TestHealthIssueAPI(APIBaseTest):self.assertEqual(data["by_severity"], {})self.assertEqual(data["by_kind"], {})+ def test_sdk_issue_visible_even_when_latest_release_is_fresh(self):+ # A fresh upstream release (<7 days old) must not hide sdk_outdated issues — fast-releasing+ # SDKs like posthog-python and posthog-js always have a recent release, so any blanket+ # exclusion keyed on release freshness blacks out their issues permanently. The Redis seed+ # below sets up exactly that condition; the endpoints must ignore it, so don't remove it+ # as unused setup.+ key = github_sdk_versions_key("posthog-python")+ release_date = (datetime.now(UTC) - timedelta(days=1)).strftime("%Y-%m-%dT%H:%M:%SZ")+ get_client().set(key, json.dumps({"latestVersion": "7.18.3", "releaseDates": {"7.18.3": release_date}}))+ self.addCleanup(get_client().delete, key)++ issue = self._create_issue(+ severity=HealthIssue.Severity.CRITICAL,+ payload={"sdk_name": "posthog-python", "current_version": "7.14.1", "latest_version": "7.18.3"},+ unique_hash="fresh_release",+ )++ list_response = self.client.get(self._url(), {"status": "active", "dismissed": "false"})+ self.assertEqual(list_response.status_code, status.HTTP_200_OK)+ self.assertEqual([result["id"] for result in list_response.json()["results"]], [str(issue.id)])++ summary_response = self.client.get(self._url("/summary"))+ self.assertEqual(summary_response.status_code, status.HTTP_200_OK)+ summary = summary_response.json()+ self.assertEqual(summary["total"], 1)+ self.assertEqual(summary["by_kind"], {"sdk_outdated": 1})+def test_resolve_already_resolved_returns_400(self):issue = self._create_issue(status=HealthIssue.Status.RESOLVED)diff --git a/products/growth/backend/sdk_health.py b/products/growth/backend/sdk_health.pyindex b95254ca8ea0..9e9ad98e7b7e 100644--- a/products/growth/backend/sdk_health.py+++ b/products/growth/backend/sdk_health.py@@ -10,11 +10,8 @@ The frontend renders these pre-computed values."""from dataclasses import dataclass, field-from datetime import UTC, datetime, timedelta-from json import (- dumps as json_dumps,- loads as json_loads,-)+from datetime import UTC, datetime+from json import dumps as json_dumpsfrom math import ceilfrom re import (Pattern,@@ -24,12 +21,6 @@ from typing import Any, Literal, Optionalfrom urllib.parse import quoteimport humanize-from redis.exceptions import RedisError--from posthog.cache_utils import cache_for-from posthog.redis import get_client--from products.growth.backend.constants import SDK_TYPES, github_sdk_versions_key# --- SDK classification --------------------@@ -258,48 +249,6 @@ def _calculate_version_age_days(release_date_iso: str, now: Optional[datetime] =return int(seconds // 86400)-def _decode_redis_json(raw: bytes | str) -> dict:- return json_loads(raw.decode("utf-8") if isinstance(raw, bytes) else raw)---def _load_github_sdk_data() -> dict[str, dict]:- """Load latest SDK versions from Redis for all known SDK types."""- redis_client = get_client()- keys = [github_sdk_versions_key(sdk_type) for sdk_type in SDK_TYPES]- values = redis_client.mget(keys)-- data: dict[str, dict] = {}- for sdk_type, raw in zip(SDK_TYPES, values):- if not raw:- continue- parsed = _decode_redis_json(raw)- if "latestVersion" in parsed:- data[sdk_type] = parsed- return data---SDK_FRESHNESS_GRACE_PERIOD_DAYS = 7---@cache_for(timedelta(seconds=60))-def sdks_within_freshness_grace_period() -> set[str]:- """Return SDK names whose latest published version is younger than the grace period."""- try:- github_data = _load_github_sdk_data()- except (RedisError, ValueError, TypeError):- return set()-- fresh: set[str] = set()- for sdk_type, data in github_data.items():- try:- release_date = (data.get("releaseDates") or {}).get(data["latestVersion"])- if release_date and _calculate_version_age_days(release_date) < SDK_FRESHNESS_GRACE_PERIOD_DAYS:- fresh.add(sdk_type)- except (ValueError, TypeError, AttributeError):- continue- return fresh--def _device_context(sdk_type: str) -> Literal["mobile", "desktop", "mixed"]:if sdk_type in MOBILE_SDKS:return "mobile"diff --git a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambrindex 806cfa5e8103..b74d3eaf65cf 100644--- a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr+++ b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr@@ -2946,570 +2946,6 @@use_hive_partitioning=0'''# ----# name: TestClickhousePaths.test_recording_with_start_and_end- '''- SELECT persons.id AS id,- persons.created_at AS created_at,- source.event_count AS event_count,- source.matching_events AS matching_events- FROM (- SELECT person_id AS actor_id,- groupUniqArray(100)(tuple(timestamp, uuid,- session_id,- window_id)) AS matching_events,- count(*) AS event_count- FROM (- SELECT person_id AS person_id,- path AS path,- conversion_time AS conversion_time,- event_in_session_index AS event_in_session_index,- concat(ifNull(toString(event_in_session_index), ''), '_',- ifNull(toString(path), '')) AS path_key,- if(ifNull(greater(event_in_session_index,- 1), 0), concat(ifNull(toString(minus(event_in_session_index,- 1)), ''), '_',- ifNull(toString(prev_path), '')), NULL) AS last_path_key,- path_dropoff_key AS path_dropoff_key,- final_uuid AS uuid,- final_timestamp AS timestamp,- final_session_id AS session_id,- final_window_id AS window_id- FROM (- SELECT person_id AS person_id,- joined_path_tuple.1 AS path,- joined_path_tuple.2 AS conversion_time,- joined_path_tuple.3 AS prev_path,- event_in_session_index,- session_index AS session_index,- arrayPopFront(arrayPushBack(path_basic,- '')) AS path_basic_0,- arrayMap((x,- y) -> if(ifNull(equals(x,- y), isNull(x)- and isNull(y)), 0,- 1), path_basic,- path_basic_0) AS mapping,- arrayFilter((x,- y) -> y,- time,- mapping) AS timings,- arrayFilter((x,- y) -> y,- path_basic,- mapping) AS compact_path,- indexOf(compact_path,- '/3') AS target_index,- joined_path_tuple.4 AS final_uuid,- joined_path_tuple.5 AS final_timestamp,- joined_path_tuple.6 AS final_session_id,- joined_path_tuple.7 AS final_window_id,- arrayFilter((x,- y) -> y,- uuid_items,- mapping) AS uuid,- arrayFilter((x,- y) -> y,- timestamp_items,- mapping) AS timestamp,- arrayFilter((x,- y) -> y,- session_id_items,- mapping) AS session_id,- arrayFilter((x,- y) -> y,- window_id_items,- mapping) AS window_id,- indexOf(compact_path,- '/1') AS start_target_index,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(compact_path,- start_target_index), compact_path) AS start_filtered_path,- indexOf(start_filtered_path,- '/3') AS end_target_index,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_path,- end_target_index), start_filtered_path) AS filtered_path,- if(ifNull(greater(length(filtered_path), 5), 0), arrayConcat(arraySlice(filtered_path,- 1,- intDiv(5,- 2)), ['...'],- arraySlice(filtered_path,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_path) AS limited_path,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(timings,- start_target_index), timings) AS start_filtered_timings,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_timings,- end_target_index), start_filtered_timings) AS filtered_timings,- if(ifNull(greater(length(filtered_timings), 5), 0), arrayConcat(arraySlice(filtered_timings,- 1,- intDiv(5,- 2)), [filtered_timings[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_timings,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_timings) AS limited_timings,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(uuid,- start_target_index), uuid) AS start_filtered_uuid,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_uuid,- end_target_index), start_filtered_uuid) AS filtered_uuid,- if(ifNull(greater(length(filtered_uuid), 5), 0), arrayConcat(arraySlice(filtered_uuid,- 1,- intDiv(5,- 2)), [filtered_uuid[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_uuid,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_uuid) AS limited_uuid,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(timestamp, start_target_index), timestamp) AS start_filtered_timestamp,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_timestamp,- end_target_index), start_filtered_timestamp) AS filtered_timestamp,- if(ifNull(greater(length(filtered_timestamp), 5), 0), arrayConcat(arraySlice(filtered_timestamp,- 1,- intDiv(5,- 2)), [filtered_timestamp[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_timestamp,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_timestamp) AS limited_timestamp,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(session_id,- start_target_index), session_id) AS start_filtered_session_id,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_session_id,- end_target_index), start_filtered_session_id) AS filtered_session_id,- if(ifNull(greater(length(filtered_session_id), 5), 0), arrayConcat(arraySlice(filtered_session_id,- 1,- intDiv(5,- 2)), [filtered_session_id[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_session_id,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_session_id) AS limited_session_id,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(window_id,- start_target_index), window_id) AS start_filtered_window_id,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_window_id,- end_target_index), start_filtered_window_id) AS filtered_window_id,- if(ifNull(greater(length(filtered_window_id), 5), 0), arrayConcat(arraySlice(filtered_window_id,- 1,- intDiv(5,- 2)), [filtered_window_id[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_window_id,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_window_id) AS limited_window_id,- arrayDifference(limited_timings) AS timings_diff,- concat(ifNull(toString(length(limited_path)), ''), '_',- ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key,- arrayZip(limited_path,- timings_diff,- arrayPopBack(arrayPushFront(limited_path,- '')), limited_uuid,- limited_timestamp,- limited_session_id,- limited_window_id) AS limited_path_timings- FROM (- SELECT person_id AS person_id,- path_time_tuple.1 AS path_basic,- path_time_tuple.2 AS time,- session_index,- arrayZip(path_list,- timing_list,- arrayDifference(timing_list), uuid_list,- timestamp_list,- session_id_list,- window_id_list) AS paths_tuple,- arraySplit(x -> if(ifNull(less(x.3,- 1800), 0), 0,- 1), paths_tuple) AS session_paths,- path_time_tuple.4 AS uuid_items,- path_time_tuple.5 AS timestamp_items,- path_time_tuple.6 AS session_id_items,- path_time_tuple.7 AS window_id_items- FROM (- SELECT person_id AS person_id,- groupArray(timestamp) AS timing_list,- groupArray(path_item) AS path_list,- groupArray(uuid) AS uuid_list,- groupArray(timestamp) AS timestamp_list,- groupArray(session_id) AS session_id_list,- groupArray(window_id) AS window_id_list- FROM (- SELECT toTimeZone(events.timestamp,- 'UTC') AS timestamp,- if(not(empty(events__override.distinct_id)), events__override.person_id,- events.person_id) AS person_id,- ifNull(if(equals(events.event,- '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties,- '$current_url'), ''), 'null'), '^"|"$',- ''), ''), '(.)/$',- '\\1'), events.event), '') AS path_item_ungrouped,- events.uuid AS uuid,- toTimeZone(events.timestamp,- 'UTC') AS timestamp,- ifNull(nullIf(nullIf(events.`$session_id`,- ''), 'null'), '') AS session_id,- ifNull(nullIf(nullIf(events.`$window_id`,- ''), 'null'), '') AS window_id,- NULL AS groupings,- multiMatchAnyIndex(path_item_ungrouped,- NULL) AS group_index, (if(ifNull(greater(group_index,- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item- FROM events- LEFT OUTER JOIN (- SELECT tupleElement(argMax(tuple(person_distinct_id_overrides.person_id), person_distinct_id_overrides.version), 1) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides- WHERE equals(person_distinct_id_overrides.team_id,- 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 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(greaterOrEquals(events.timestamp,- toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00',- 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp,- assumeNotNull(toDateTime('2012-01-02 23:59:59',- 'UTC')))), equals(events.event,- '$pageview'))- ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id,- events.person_id) ASC, toTimeZone(events.timestamp,- 'UTC') ASC)- GROUP BY person_id) ARRAY- JOIN session_paths AS path_time_tuple,- arrayEnumerate(session_paths) AS session_index) ARRAY- JOIN limited_path_timings AS joined_path_tuple,- arrayEnumerate(limited_path_timings) AS event_in_session_index- WHERE and(ifNull(greater(start_target_index,- 0), 0), ifNull(greater(end_target_index,- 0), 0)))) WHERE equals(path_key,- '2_/2')- GROUP BY person_id) AS source- INNER JOIN (- SELECT tupleElement(argMax(tuple(toTimeZone(person.created_at,- 'UTC')), person.version), 1) AS created_at,- person.id AS id- FROM person- WHERE and(equals(person.team_id,- 99999), in(id, (- SELECT source.actor_id AS actor_id- FROM (- SELECT person_id AS actor_id,- groupUniqArray(100)(tuple(timestamp, uuid,- session_id,- window_id)) AS matching_events,- count(*) AS event_count- FROM (- SELECT person_id AS person_id,- path AS path,- conversion_time AS conversion_time,- event_in_session_index AS event_in_session_index,- concat(ifNull(toString(event_in_session_index), ''), '_',- ifNull(toString(path), '')) AS path_key,- if(ifNull(greater(event_in_session_index,- 1), 0), concat(ifNull(toString(minus(event_in_session_index,- 1)), ''), '_',- ifNull(toString(prev_path), '')), NULL) AS last_path_key,- path_dropoff_key AS path_dropoff_key,- final_uuid AS uuid,- final_timestamp AS timestamp,- final_session_id AS session_id,- final_window_id AS window_id- FROM (- SELECT person_id AS person_id,- joined_path_tuple.1 AS path,- joined_path_tuple.2 AS conversion_time,- joined_path_tuple.3 AS prev_path,- event_in_session_index,- session_index AS session_index,- arrayPopFront(arrayPushBack(path_basic,- '')) AS path_basic_0,- arrayMap((x,- y) -> if(ifNull(equals(x,- y), isNull(x)- and isNull(y)), 0,- 1), path_basic,- path_basic_0) AS mapping,- arrayFilter((x,- y) -> y,- time,- mapping) AS timings,- arrayFilter((x,- y) -> y,- path_basic,- mapping) AS compact_path,- indexOf(compact_path,- '/3') AS target_index,- joined_path_tuple.4 AS final_uuid,- joined_path_tuple.5 AS final_timestamp,- joined_path_tuple.6 AS final_session_id,- joined_path_tuple.7 AS final_window_id,- arrayFilter((x,- y) -> y,- uuid_items,- mapping) AS uuid,- arrayFilter((x,- y) -> y,- timestamp_items,- mapping) AS timestamp,- arrayFilter((x,- y) -> y,- session_id_items,- mapping) AS session_id,- arrayFilter((x,- y) -> y,- window_id_items,- mapping) AS window_id,- indexOf(compact_path,- '/1') AS start_target_index,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(compact_path,- start_target_index), compact_path) AS start_filtered_path,- indexOf(start_filtered_path,- '/3') AS end_target_index,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_path,- end_target_index), start_filtered_path) AS filtered_path,- if(ifNull(greater(length(filtered_path), 5), 0), arrayConcat(arraySlice(filtered_path,- 1,- intDiv(5,- 2)), ['...'],- arraySlice(filtered_path,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_path) AS limited_path,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(timings,- start_target_index), timings) AS start_filtered_timings,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_timings,- end_target_index), start_filtered_timings) AS filtered_timings,- if(ifNull(greater(length(filtered_timings), 5), 0), arrayConcat(arraySlice(filtered_timings,- 1,- intDiv(5,- 2)), [filtered_timings[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_timings,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_timings) AS limited_timings,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(uuid,- start_target_index), uuid) AS start_filtered_uuid,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_uuid,- end_target_index), start_filtered_uuid) AS filtered_uuid,- if(ifNull(greater(length(filtered_uuid), 5), 0), arrayConcat(arraySlice(filtered_uuid,- 1,- intDiv(5,- 2)), [filtered_uuid[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_uuid,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_uuid) AS limited_uuid,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(timestamp, start_target_index), timestamp) AS start_filtered_timestamp,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_timestamp,- end_target_index), start_filtered_timestamp) AS filtered_timestamp,- if(ifNull(greater(length(filtered_timestamp), 5), 0), arrayConcat(arraySlice(filtered_timestamp,- 1,- intDiv(5,- 2)), [filtered_timestamp[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_timestamp,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_timestamp) AS limited_timestamp,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(session_id,- start_target_index), session_id) AS start_filtered_session_id,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_session_id,- end_target_index), start_filtered_session_id) AS filtered_session_id,- if(ifNull(greater(length(filtered_session_id), 5), 0), arrayConcat(arraySlice(filtered_session_id,- 1,- intDiv(5,- 2)), [filtered_session_id[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_session_id,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_session_id) AS limited_session_id,- if(ifNull(greater(start_target_index,- 0), 0), arraySlice(window_id,- start_target_index), window_id) AS start_filtered_window_id,- if(ifNull(greater(end_target_index,- 0), 0), arrayResize(start_filtered_window_id,- end_target_index), start_filtered_window_id) AS filtered_window_id,- if(ifNull(greater(length(filtered_window_id), 5), 0), arrayConcat(arraySlice(filtered_window_id,- 1,- intDiv(5,- 2)), [filtered_window_id[plus(1,- intDiv(5,- 2))]], arraySlice(filtered_window_id,- multiply(-1,- intDiv(5,- 2)), intDiv(5,- 2))), filtered_window_id) AS limited_window_id,- arrayDifference(limited_timings) AS timings_diff,- concat(ifNull(toString(length(limited_path)), ''), '_',- ifNull(toString(limited_path[-1]), '')) AS path_dropoff_key,- arrayZip(limited_path,- timings_diff,- arrayPopBack(arrayPushFront(limited_path,- '')), limited_uuid,- limited_timestamp,- limited_session_id,- limited_window_id) AS limited_path_timings- FROM (- SELECT person_id AS person_id,- path_time_tuple.1 AS path_basic,- path_time_tuple.2 AS time,- session_index,- arrayZip(path_list,- timing_list,- arrayDifference(timing_list), uuid_list,- timestamp_list,- session_id_list,- window_id_list) AS paths_tuple,- arraySplit(x -> if(ifNull(less(x.3,- 1800), 0), 0,- 1), paths_tuple) AS session_paths,- path_time_tuple.4 AS uuid_items,- path_time_tuple.5 AS timestamp_items,- path_time_tuple.6 AS session_id_items,- path_time_tuple.7 AS window_id_items- FROM (- SELECT person_id AS person_id,- groupArray(timestamp) AS timing_list,- groupArray(path_item) AS path_list,- groupArray(uuid) AS uuid_list,- groupArray(timestamp) AS timestamp_list,- groupArray(session_id) AS session_id_list,- groupArray(window_id) AS window_id_list- FROM (- SELECT toTimeZone(events.timestamp,- 'UTC') AS timestamp,- if(not(empty(events__override.distinct_id)), events__override.person_id,- events.person_id) AS person_id,- ifNull(if(equals(events.event,- '$pageview'), replaceRegexpAll(ifNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties,- '$current_url'), ''), 'null'), '^"|"$',- ''), ''), '(.)/$',- '\\1'), events.event), '') AS path_item_ungrouped,- events.uuid AS uuid,- toTimeZone(events.timestamp,- 'UTC') AS timestamp,- ifNull(nullIf(nullIf(events.`$session_id`,- ''), 'null'), '') AS session_id,- ifNull(nullIf(nullIf(events.`$window_id`,- ''), 'null'), '') AS window_id,- NULL AS groupings,- multiMatchAnyIndex(path_item_ungrouped,- NULL) AS group_index, (if(ifNull(greater(group_index,- 0), 0), groupings[group_index], path_item_ungrouped) AS path_item) AS path_item- FROM events- LEFT OUTER JOIN (- SELECT tupleElement(argMax(tuple(person_distinct_id_overrides.person_id), person_distinct_id_overrides.version), 1) AS person_id,- person_distinct_id_overrides.distinct_id AS distinct_id- FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id,- 99999)- GROUP BY person_distinct_id_overrides.distinct_id- HAVING equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 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(greaterOrEquals(events.timestamp,- toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00',- 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp,- assumeNotNull(toDateTime('2012-01-02 23:59:59',- 'UTC')))), equals(events.event,- '$pageview'))- ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id,- events.person_id) ASC, toTimeZone(events.timestamp,- 'UTC') ASC)- GROUP BY person_id) ARRAY- JOIN session_paths AS path_time_tuple,- arrayEnumerate(session_paths) AS session_index) ARRAY- JOIN limited_path_timings AS joined_path_tuple,- arrayEnumerate(limited_path_timings) AS event_in_session_index- WHERE and(ifNull(greater(start_target_index,- 0), 0), ifNull(greater(end_target_index,- 0), 0)))) WHERE equals(path_key,- '2_/2')- GROUP BY person_id) AS source)))- GROUP BY person.id- HAVING and(equals(tupleElement(argMax(tuple(person.is_deleted), person.version), 1), 0), less(tupleElement(argMax(tuple(toTimeZone(person.created_at,- 'UTC')), person.version), 1), plus(now64(6,- 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id,- source.actor_id)- ORDER BY persons.id ASC- LIMIT 101- OFFSET 0 SETTINGS optimize_aggregation_in_order=1,- join_algorithm='auto',- readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=0,- transform_null_in=1,- optimize_min_equality_disjunction_chain_length=4294967295,- optimize_rewrite_aggregate_function_with_if=0,- optimize_min_inequality_conjunction_chain_length=4294967295,- allow_experimental_join_condition=1,- use_hive_partitioning=0- '''-# ----# name: TestClickhousePaths.test_recording_with_start_and_end.1- '''- SELECT session_replay_events.session_id AS session_id,- min(toTimeZone(session_replay_events.min_first_timestamp, 'UTC')) AS start_time,- max(session_replay_events.retention_period_days) AS retention_period_days,- plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time- FROM session_replay_events- WHERE and(equals(session_replay_events.team_id, 99999), in(session_replay_events.session_id, ['s1']))- GROUP BY session_replay_events.session_id- HAVING and(greaterOrEquals(expiry_time, toDateTime64('2012-01-01 03:21:34.000000', 6, 'UTC')), equals(max(session_replay_events.is_deleted), 0))- LIMIT 100 SETTINGS readonly=2,- max_execution_time=60,- allow_experimental_object_type=1,- max_ast_elements=4000000,- max_expanded_ast_elements=4000000,- max_bytes_before_external_group_by=0,- transform_null_in=1,- optimize_min_equality_disjunction_chain_length=4294967295,- optimize_rewrite_aggregate_function_with_if=0,- optimize_min_inequality_conjunction_chain_length=4294967295,- allow_experimental_join_condition=1,- use_hive_partitioning=0- '''-# ---# name: TestClickhousePaths.test_respect_session_limits'''SELECT last_path_key AS source_event,