: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
chore(replay): rename dataclasses to domain-concept names (#76165)
Arno Hillen08667318f91d
diff --git a/posthog/temporal/session_replay/count_playlist_items/activities.py b/posthog/temporal/session_replay/count_playlist_items/activities.pyindex 55f1a06d811c..0e1dce3af739 100644--- a/posthog/temporal/session_replay/count_playlist_items/activities.py+++ b/posthog/temporal/session_replay/count_playlist_items/activities.py@@ -7,13 +7,13 @@ from posthog.temporal.session_replay.count_playlist_items.counting_logic importcount_recordings_that_match_playlist_filters,fetch_playlists_to_count as fetch_playlists_to_count_sync,)-from posthog.temporal.session_replay.count_playlist_items.types import CountPlaylistInput, PlaylistInfo+from posthog.temporal.session_replay.count_playlist_items.types import CountPlaylistInput, PlaylistToCountLOGGER = get_write_only_logger()@activity.defn(name="fetch-playlists-to-count")-async def fetch_playlists_to_count() -> list[PlaylistInfo]:+async def fetch_playlists_to_count() -> list[PlaylistToCount]:logger = LOGGER.bind(activity="fetch-playlists-to-count")logger.info("Fetching playlists to count")@@ -21,7 +21,7 @@ async def fetch_playlists_to_count() -> list[PlaylistInfo]:logger.info("Found playlists to count", to_count=len(playlist_ids))- return [PlaylistInfo(playlist_id=pid) for pid in playlist_ids]+ return [PlaylistToCount(playlist_id=pid) for pid in playlist_ids]@activity.defn(name="count-recordings-for-playlist")diff --git a/posthog/temporal/session_replay/count_playlist_items/types.py b/posthog/temporal/session_replay/count_playlist_items/types.pyindex 6b3e55f394a1..d7a6025fa324 100644--- a/posthog/temporal/session_replay/count_playlist_items/types.py+++ b/posthog/temporal/session_replay/count_playlist_items/types.py@@ -2,7 +2,7 @@ from dataclasses import dataclass@dataclass(frozen=True)-class PlaylistInfo:+class PlaylistToCount:playlist_id: intdiff --git a/posthog/temporal/session_replay/count_playlist_items/workflow.py b/posthog/temporal/session_replay/count_playlist_items/workflow.pyindex 77bc9d186494..e4c90f24df60 100644--- a/posthog/temporal/session_replay/count_playlist_items/workflow.py+++ b/posthog/temporal/session_replay/count_playlist_items/workflow.py@@ -10,7 +10,7 @@ from posthog.temporal.session_replay.count_playlist_items.activities import (count_recordings_for_playlist,fetch_playlists_to_count,)-from posthog.temporal.session_replay.count_playlist_items.types import CountPlaylistInput, PlaylistInfo+from posthog.temporal.session_replay.count_playlist_items.types import CountPlaylistInput, PlaylistToCount@temporalio.workflow.defn(name="count-all-playlists")@@ -19,7 +19,7 @@ class CountAllPlaylistsWorkflow(PostHogWorkflow):@temporalio.workflow.runasync def run(self, input: None = None) -> None:- playlist_infos: list[PlaylistInfo] = await temporalio.workflow.execute_activity(+ playlist_infos: list[PlaylistToCount] = await temporalio.workflow.execute_activity(fetch_playlists_to_count,start_to_close_timeout=timedelta(minutes=5),retry_policy=temporalio.common.RetryPolicy(diff --git a/posthog/temporal/tests/session_replay/count_playlist_items/test_workflow.py b/posthog/temporal/tests/session_replay/count_playlist_items/test_workflow.pyindex 45eb0d3eea3d..b4cf8d6f6f2f 100644--- a/posthog/temporal/tests/session_replay/count_playlist_items/test_workflow.py+++ b/posthog/temporal/tests/session_replay/count_playlist_items/test_workflow.py@@ -9,7 +9,7 @@ from temporalio.exceptions import ApplicationErrorfrom temporalio.testing import WorkflowEnvironmentfrom temporalio.worker import Worker-from posthog.temporal.session_replay.count_playlist_items.types import CountPlaylistInput, PlaylistInfo+from posthog.temporal.session_replay.count_playlist_items.types import CountPlaylistInput, PlaylistToCountfrom posthog.temporal.session_replay.count_playlist_items.workflow import (CountAllPlaylistsWorkflow,CountPlaylistWorkflow,@@ -18,11 +18,11 @@ from posthog.temporal.session_replay.count_playlist_items.workflow import (@pytest.mark.asyncioasync def test_fans_out_child_workflows():- playlists = [PlaylistInfo(playlist_id=1), PlaylistInfo(playlist_id=2), PlaylistInfo(playlist_id=3)]+ playlists = [PlaylistToCount(playlist_id=1), PlaylistToCount(playlist_id=2), PlaylistToCount(playlist_id=3)]counted_ids: list[int] = []@activity.defn(name="fetch-playlists-to-count")- async def mock_fetch() -> list[PlaylistInfo]:+ async def mock_fetch() -> list[PlaylistToCount]:return playlists@activity.defn(name="count-recordings-for-playlist")@@ -51,7 +51,7 @@ async def test_fans_out_child_workflows():@pytest.mark.asyncioasync def test_no_playlists_completes_immediately():@activity.defn(name="fetch-playlists-to-count")- async def mock_fetch() -> list[PlaylistInfo]:+ async def mock_fetch() -> list[PlaylistToCount]:return []@activity.defn(name="count-recordings-for-playlist")@@ -77,10 +77,10 @@ async def test_no_playlists_completes_immediately():@pytest.mark.asyncioasync def test_partial_failure_raises_application_error():- playlists = [PlaylistInfo(playlist_id=1), PlaylistInfo(playlist_id=2)]+ playlists = [PlaylistToCount(playlist_id=1), PlaylistToCount(playlist_id=2)]@activity.defn(name="fetch-playlists-to-count")- async def mock_fetch() -> list[PlaylistInfo]:+ async def mock_fetch() -> list[PlaylistToCount]:return playlists@activity.defn(name="count-recordings-for-playlist")@@ -137,11 +137,11 @@ async def test_count_playlist_workflow_calls_activity():@pytest.mark.asyncioasync def test_large_playlist_set_is_batched():- playlists = [PlaylistInfo(playlist_id=i) for i in range(1200)]+ playlists = [PlaylistToCount(playlist_id=i) for i in range(1200)]counted_ids: list[int] = []@activity.defn(name="fetch-playlists-to-count")- async def mock_fetch() -> list[PlaylistInfo]:+ async def mock_fetch() -> list[PlaylistToCount]:return playlists@activity.defn(name="count-recordings-for-playlist")diff --git a/products/replay_vision/backend/billing.py b/products/replay_vision/backend/billing.pyindex bc8c0d62f75a..1bce53f8c133 100644--- a/products/replay_vision/backend/billing.py+++ b/products/replay_vision/backend/billing.py@@ -30,7 +30,7 @@ GeminiTier = Literal["flash lite", "flash", "pro"]@dataclass(frozen=True)-class GeminiModelInfo:+class GeminiModelPricing:tier: GeminiTierinput_usd_per_1m: float # Google list price per 1M input tokensoutput_usd_per_1m: float # Google list price per 1M output tokens@@ -54,23 +54,23 @@ class GeminiModelInfo:## Credit prices are hand-set. The two flash prices (5 and 15) reproduce via `suggested_observation_credits`# at TARGET_MARGIN; the budget tier is pinned below its suggestion to keep the 2-credit price users know.-GEMINI_MODELS: dict[str, GeminiModelInfo] = {- ScannerModel.GEMINI_3_5_FLASH_LITE: GeminiModelInfo(+GEMINI_MODELS: dict[str, GeminiModelPricing] = {+ ScannerModel.GEMINI_3_5_FLASH_LITE: GeminiModelPricing(tier="flash lite", input_usd_per_1m=0.30, output_usd_per_1m=2.50, credits_per_observation=2),- ScannerModel.GEMINI_3_FLASH_PREVIEW: GeminiModelInfo(+ ScannerModel.GEMINI_3_FLASH_PREVIEW: GeminiModelPricing(tier="flash", input_usd_per_1m=0.50, output_usd_per_1m=3.00, credits_per_observation=5),- ScannerModel.GEMINI_3_6_FLASH: GeminiModelInfo(+ ScannerModel.GEMINI_3_6_FLASH: GeminiModelPricing(tier="flash", input_usd_per_1m=1.50, output_usd_per_1m=7.50, credits_per_observation=15),- "gemini-2.5-flash": GeminiModelInfo(+ "gemini-2.5-flash": GeminiModelPricing(tier="flash", input_usd_per_1m=0.30, output_usd_per_1m=2.50, credits_per_observation=2, retired=True),- "gemini-3.5-flash": GeminiModelInfo(+ "gemini-3.5-flash": GeminiModelPricing(tier="flash", input_usd_per_1m=1.50, output_usd_per_1m=9.00, credits_per_observation=15, retired=True),- "gemini-3.1-flash-lite-preview": GeminiModelInfo(+ "gemini-3.1-flash-lite-preview": GeminiModelPricing(tier="flash lite", input_usd_per_1m=0.25, output_usd_per_1m=1.50, credits_per_observation=2, retired=True),}@@ -89,7 +89,7 @@ TARGET_MARGIN = 3.75FREE_TIER_MONTHLY_CREDITS = 2500-def suggested_observation_credits(info: GeminiModelInfo, margin: float = TARGET_MARGIN) -> int:+def suggested_observation_credits(info: GeminiModelPricing, margin: float = TARGET_MARGIN) -> int:"""Suggested credits per observation for a model, derived from its token prices and a target margin."""input_cost_usd = AVG_INPUT_TOKENS_PER_OBSERVATION * info.input_usd_per_1m / 1_000_000output_cost_usd = AVG_OUTPUT_TOKENS_PER_OBSERVATION * info.output_usd_per_1m / 1_000_000