: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
feat(error-tracking): route weekly digest queries through the error_tracking ClickHouse user (#76573)
Aleksander Błaszkiewicz0b1687690627
diff --git a/products/error_tracking/backend/temporal/weekly_digest/workflow.py b/products/error_tracking/backend/temporal/weekly_digest/workflow.pyindex fbb4623f3f83..411b84408f1c 100644--- a/products/error_tracking/backend/temporal/weekly_digest/workflow.py+++ b/products/error_tracking/backend/temporal/weekly_digest/workflow.py@@ -29,8 +29,8 @@ GET_ORGS_TIMEOUT = timedelta(minutes=5)SEND_ORG_START_TO_CLOSE_TIMEOUT = timedelta(minutes=30)SEND_ORG_HEARTBEAT_TIMEOUT = timedelta(minutes=5)-SEND_ORG_INITIAL_RETRY_INTERVAL = timedelta(seconds=30)-SEND_ORG_MAXIMUM_RETRY_INTERVAL = timedelta(minutes=5)+SEND_ORG_INITIAL_RETRY_INTERVAL = timedelta(seconds=1)+SEND_ORG_MAXIMUM_RETRY_INTERVAL = timedelta(seconds=30)def _sent_from_error(error: BaseException) -> int:diff --git a/products/error_tracking/backend/weekly_digest.py b/products/error_tracking/backend/weekly_digest.pyindex 5692c59bd085..1bc66fbf3ad2 100644--- a/products/error_tracking/backend/weekly_digest.py+++ b/products/error_tracking/backend/weekly_digest.py@@ -42,6 +42,7 @@ def query_daily_rows(team: Team) -> list:"""from posthog.hogql.query import execute_hogql_query+ from posthog.clickhouse.client.connection import ClickHouseUserfrom posthog.clickhouse.workload import Workloadtag_queries(product=ProductKey.ERROR_TRACKING, team_id=team.pk, name="weekly_digest:daily_rows")@@ -65,6 +66,7 @@ def query_daily_rows(team: Team) -> list:filters=HogQLFilters(filterTestAccounts=True),# Weekly batch job: Celery pinned this to the offline cluster process-wide, Temporal does not.workload=Workload.OFFLINE,+ ch_user=ClickHouseUser.ERROR_TRACKING,)return response.results or []@@ -152,6 +154,7 @@ def get_exception_counts(team_ids: list[int] | None = None) -> list:busiest project without needing a per-team build."""from posthog.clickhouse.client import sync_execute+ from posthog.clickhouse.client.connection import ClickHouseUserfrom posthog.clickhouse.workload import Workloadtag_queries(product=ProductKey.ERROR_TRACKING, name="weekly_digest:exception_counts")@@ -174,7 +177,7 @@ def get_exception_counts(team_ids: list[int] | None = None) -> list:"""# Cross-team scan for a weekly batch job — keep it off the online cluster.- results = sync_execute(query, query_params, workload=Workload.OFFLINE)+ results = sync_execute(query, query_params, workload=Workload.OFFLINE, ch_user=ClickHouseUser.ERROR_TRACKING)return results if isinstance(results, list) else []@@ -182,6 +185,7 @@ def get_crash_free_sessions(team: Team) -> dict:"""Calculate crash free sessions rate for the last 7 days with previous week comparison."""from posthog.hogql.query import execute_hogql_query+ from posthog.clickhouse.client.connection import ClickHouseUserfrom posthog.clickhouse.workload import Workload# posthog.tasks.__init__ eagerly imports every task module (celery autoimport);@@ -209,6 +213,7 @@ def get_crash_free_sessions(team: Team) -> dict:filters=HogQLFilters(filterTestAccounts=True),# Unfiltered 14-day session scan — the heaviest query here. Must stay off the online cluster.workload=Workload.OFFLINE,+ ch_user=ClickHouseUser.ERROR_TRACKING,)if not response.results or not response.results[0]:@@ -278,6 +283,7 @@ def _query_issue_rows(team: Team) -> list:"""from posthog.hogql.query import execute_hogql_query+ from posthog.clickhouse.client.connection import ClickHouseUserfrom posthog.clickhouse.workload import Workloadtag_queries(product=ProductKey.ERROR_TRACKING, team_id=team.pk, name="weekly_digest:issue_rows")@@ -312,6 +318,7 @@ def _query_issue_rows(team: Team) -> list:filters=HogQLFilters(filterTestAccounts=True),# Weekly batch job: Celery pinned this to the offline cluster process-wide, Temporal does not.workload=Workload.OFFLINE,+ ch_user=ClickHouseUser.ERROR_TRACKING,)return response.results or []