Skip to content

: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.

chore(temporal): share the digest fan-out helpers from posthog/temporal/common (#103981)

Thiago Salvatore43a3e65ea41a
diff --git a/products/web_analytics/backend/temporal/digest_common.py b/posthog/temporal/common/digest.py
similarity index 100%
rename from products/web_analytics/backend/temporal/digest_common.py
rename to posthog/temporal/common/digest.py
diff --git a/products/web_analytics/backend/temporal/digest_notification/activities.py b/products/web_analytics/backend/temporal/digest_notification/activities.py
index ba2448673774..fe672e4440c9 100644
--- a/products/web_analytics/backend/temporal/digest_notification/activities.py
+++ b/products/web_analytics/backend/temporal/digest_notification/activities.py
@@ -17,6 +17,7 @@ from posthog.models.organization import Organization, OrganizationMembership
from posthog.models.user import User
from posthog.ph_client import ph_scoped_capture
from posthog.sync import database_sync_to_async
+from posthog.temporal.common.digest import OrgBatchPageResult, paginate_index, paginate_keyset
from posthog.temporal.common.heartbeat import Heartbeater
from posthog.user_permissions import UserPermissions
@@ -28,7 +29,6 @@ from products.notifications.backend.facade.api import (
create_notification,
)
from products.web_analytics.backend import weekly_digest
-from products.web_analytics.backend.temporal.digest_common import OrgBatchPageResult, paginate_index, paginate_keyset
from products.web_analytics.backend.temporal.digest_notification.types import (
DigestBatchInput,
DigestBatchResult,
diff --git a/products/web_analytics/backend/temporal/digest_notification/types.py b/products/web_analytics/backend/temporal/digest_notification/types.py
index f47599758a45..2071d11bf1ba 100644
--- a/products/web_analytics/backend/temporal/digest_notification/types.py
+++ b/products/web_analytics/backend/temporal/digest_notification/types.py
@@ -1,7 +1,7 @@
import dataclasses
from enum import StrEnum
-from products.web_analytics.backend.temporal.digest_common import DigestBatchTotals
+from posthog.temporal.common.digest import DigestBatchTotals
class NotificationDigestOutcome(StrEnum):
diff --git a/products/web_analytics/backend/temporal/digest_notification/workflows.py b/products/web_analytics/backend/temporal/digest_notification/workflows.py
index 71ed9e00b2b9..0b6030ea9b57 100644
--- a/products/web_analytics/backend/temporal/digest_notification/workflows.py
+++ b/products/web_analytics/backend/temporal/digest_notification/workflows.py
@@ -9,7 +9,8 @@ from temporalio.exceptions import ApplicationError
from posthog.temporal.common.base import PostHogWorkflow
with workflow.unsafe.imports_passed_through():
- from products.web_analytics.backend.temporal.digest_common import ACTIVITY_RETRY_POLICY
+ from posthog.temporal.common.digest import ACTIVITY_RETRY_POLICY
+
from products.web_analytics.backend.temporal.digest_notification.activities import (
get_org_batch_page,
run_wa_digest_notification_batch,
diff --git a/products/web_analytics/backend/temporal/weekly_digest/activities.py b/products/web_analytics/backend/temporal/weekly_digest/activities.py
index 0663e624ea95..cb1dd40c8e17 100644
--- a/products/web_analytics/backend/temporal/weekly_digest/activities.py
+++ b/products/web_analytics/backend/temporal/weekly_digest/activities.py
@@ -24,12 +24,12 @@ from posthog.models.organization import Organization, OrganizationMembership
from posthog.models.user import User
from posthog.sync import database_sync_to_async
from posthog.tasks.email import NotificationSetting, should_send_notification
+from posthog.temporal.common.digest import OrgBatchPageResult, paginate_index, paginate_keyset
from posthog.temporal.common.heartbeat import Heartbeater
from posthog.user_permissions import UserPermissions
from products.web_analytics.backend import weekly_digest
from products.web_analytics.backend.recap import recap_url_for_team
-from products.web_analytics.backend.temporal.digest_common import OrgBatchPageResult, paginate_index, paginate_keyset
from products.web_analytics.backend.temporal.weekly_digest.types import (
WA_DIGEST_EMAIL_UNAVAILABLE_TYPE,
DigestBatchInput,
diff --git a/products/web_analytics/backend/temporal/weekly_digest/types.py b/products/web_analytics/backend/temporal/weekly_digest/types.py
index b2d56027758c..d673decab9e3 100644
--- a/products/web_analytics/backend/temporal/weekly_digest/types.py
+++ b/products/web_analytics/backend/temporal/weekly_digest/types.py
@@ -1,7 +1,7 @@
import dataclasses
from enum import StrEnum
-from products.web_analytics.backend.temporal.digest_common import DigestBatchTotals
+from posthog.temporal.common.digest import DigestBatchTotals
class DigestOutcome(StrEnum):
diff --git a/products/web_analytics/backend/temporal/weekly_digest/workflows.py b/products/web_analytics/backend/temporal/weekly_digest/workflows.py
index 9a66df2875c6..b9d6f506eecc 100644
--- a/products/web_analytics/backend/temporal/weekly_digest/workflows.py
+++ b/products/web_analytics/backend/temporal/weekly_digest/workflows.py
@@ -9,7 +9,8 @@ from temporalio.exceptions import ApplicationError
from posthog.temporal.common.base import PostHogWorkflow
with workflow.unsafe.imports_passed_through():
- from products.web_analytics.backend.temporal.digest_common import ACTIVITY_RETRY_POLICY
+ from posthog.temporal.common.digest import ACTIVITY_RETRY_POLICY
+
from products.web_analytics.backend.temporal.weekly_digest.activities import (
get_org_batch_page,
push_wa_digest_metrics_activity,
diff --git a/products/web_analytics/backend/test/test_digest_notification_workflows.py b/products/web_analytics/backend/test/test_digest_notification_workflows.py
index df6689c3d741..b8400dc62d0e 100644
--- a/products/web_analytics/backend/test/test_digest_notification_workflows.py
+++ b/products/web_analytics/backend/test/test_digest_notification_workflows.py
@@ -9,7 +9,8 @@ from temporalio import activity
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
-from products.web_analytics.backend.temporal.digest_common import OrgBatchPageResult
+from posthog.temporal.common.digest import OrgBatchPageResult
+
from products.web_analytics.backend.temporal.digest_notification.types import (
WA_DIGEST_NOTIF_THRESHOLD_EXCEEDED_TYPE,
DigestBatchInput,
diff --git a/products/web_analytics/backend/test/test_weekly_digest_workflows.py b/products/web_analytics/backend/test/test_weekly_digest_workflows.py
index 2871e3c9a78b..37feb825a912 100644
--- a/products/web_analytics/backend/test/test_weekly_digest_workflows.py
+++ b/products/web_analytics/backend/test/test_weekly_digest_workflows.py
@@ -9,7 +9,8 @@ from temporalio import activity
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
-from products.web_analytics.backend.temporal.digest_common import OrgBatchPageResult
+from posthog.temporal.common.digest import OrgBatchPageResult
+
from products.web_analytics.backend.temporal.weekly_digest.types import (
WA_DIGEST_THRESHOLD_EXCEEDED_TYPE,
DigestBatchInput,