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(finops): temporal workflow labeling by replay product (#63815)

aly fultona8bb8caed865
diff --git a/posthog/temporal/session_replay/rasterize_recording/types.py b/posthog/temporal/session_replay/rasterize_recording/types.py
index 84543ca18b41..3cbb402ed407 100644
--- a/posthog/temporal/session_replay/rasterize_recording/types.py
+++ b/posthog/temporal/session_replay/rasterize_recording/types.py
@@ -8,6 +8,7 @@ class RasterizeRecordingInputs(BaseModel, frozen=True):
"""Input to the RasterizeRecordingWorkflow."""
exported_asset_id: int
+ product: Literal["session_replay", "replay_vision"] = "session_replay"
class RasterizationActivityInput(BaseModel, frozen=True):
diff --git a/posthog/temporal/session_replay/rasterize_recording/workflow.py b/posthog/temporal/session_replay/rasterize_recording/workflow.py
index 4e023297f265..35d5fdcc65c6 100644
--- a/posthog/temporal/session_replay/rasterize_recording/workflow.py
+++ b/posthog/temporal/session_replay/rasterize_recording/workflow.py
@@ -10,6 +10,14 @@ from posthog.temporal.common.search_attributes import POSTHOG_SESSION_RECORDING_
with wf.unsafe.imports_passed_through():
from django.conf import settings
+ from prometheus_client import Counter
+
+ RASTERIZATION_COMPLETED_COUNTER = Counter(
+ "posthog_rasterization_completed",
+ "Rasterization completions by product and task queue",
+ ["product", "task_queue"],
+ )
+
from .activities import (
BumpStuckCounterInput,
build_rasterization_input,
@@ -45,6 +53,7 @@ class RasterizeRecordingWorkflow(PostHogWorkflow):
await self._maybe_bump_stuck_counter()
raise
await self._maybe_clear_stuck_counter()
+ RASTERIZATION_COMPLETED_COUNTER.labels(product=inputs.product, task_queue=wf.info().task_queue).inc()
return result
async def _maybe_bump_stuck_counter(self) -> None:
diff --git a/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.py b/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.py
index 7d73c3644b10..ded9112397e2 100644
--- a/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.py
+++ b/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.py
@@ -135,6 +135,103 @@ async def test_intermediate_failure_does_not_bump():
assert bump_calls == []
+def _counter_value(product: str, task_queue: str) -> float:
+ from prometheus_client import REGISTRY
+
+ return (
+ REGISTRY.get_sample_value(
+ "posthog_rasterization_completed_total",
+ {"product": product, "task_queue": task_queue},
+ )
+ or 0.0
+ )
+
+
[email protected]("product", ["session_replay", "replay_vision"])
+async def test_success_increments_rasterization_counter(product: str):
+ @activity.defn(name="build_rasterization_input")
+ async def build_cached(_exported_asset_id: int) -> BuildRasterizationResult:
+ return BuildRasterizationResult(
+ cached_output=RasterizationActivityOutput(
+ s3_uri="s3://bucket/key",
+ video_duration_s=1.0,
+ playback_speed=1.0,
+ ),
+ render_fingerprint="abc",
+ )
+
+ @activity.defn(name="finalize_rasterization")
+ async def finalize_noop(_inputs: FinalizeRasterizationInput) -> None:
+ pass
+
+ @activity.defn(name="clear_stuck_counter_activity")
+ async def clear_noop(_inputs: BumpStuckCounterInput) -> None:
+ pass
+
+ task_queue = str(uuid.uuid4())
+ before = _counter_value(product, task_queue)
+
+ async with await WorkflowEnvironment.start_time_skipping() as env:
+ await _register_search_attributes(env)
+ async with Worker(
+ env.client,
+ task_queue=task_queue,
+ workflows=[RasterizeRecordingWorkflow],
+ activities=[build_cached, finalize_noop, clear_noop],
+ workflow_runner=temporalio.worker.UnsandboxedWorkflowRunner(),
+ ):
+ await env.client.execute_workflow(
+ RasterizeRecordingWorkflow.run,
+ RasterizeRecordingInputs(exported_asset_id=42, product=product),
+ id=str(uuid.uuid4()),
+ task_queue=task_queue,
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ search_attributes=_search_attributes(),
+ )
+
+ assert _counter_value(product, task_queue) == before + 1
+
+
+async def test_failure_does_not_increment_rasterization_counter():
+ @activity.defn(name="build_rasterization_input")
+ async def build_failing(_exported_asset_id: int) -> BuildRasterizationResult:
+ raise RuntimeError("synthetic prep failure")
+
+ @activity.defn(name="finalize_rasterization")
+ async def finalize_unused(_inputs: FinalizeRasterizationInput) -> None:
+ pass
+
+ @activity.defn(name="bump_stuck_counter_activity")
+ async def bump_noop(_inputs: BumpStuckCounterInput) -> None:
+ pass
+
+ task_queue = str(uuid.uuid4())
+ before = _counter_value("session_replay", task_queue)
+
+ async with await WorkflowEnvironment.start_time_skipping() as env:
+ await _register_search_attributes(env)
+ async with Worker(
+ env.client,
+ task_queue=task_queue,
+ workflows=[RasterizeRecordingWorkflow],
+ activities=[build_failing, finalize_unused, bump_noop],
+ workflow_runner=temporalio.worker.UnsandboxedWorkflowRunner(),
+ ):
+ with pytest.raises(Exception):
+ await env.client.execute_workflow(
+ RasterizeRecordingWorkflow.run,
+ RasterizeRecordingInputs(exported_asset_id=42),
+ id=str(uuid.uuid4()),
+ task_queue=task_queue,
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ search_attributes=_search_attributes(),
+ )
+
+ assert _counter_value("session_replay", task_queue) == before
+
+
@pytest.mark.asyncio
async def test_bump_failure_does_not_break_workflow_failure():
@activity.defn(name="build_rasterization_input")
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.ambr
index 2d50b51324d2..806cfa5e8103 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
@@ -3510,570 +3510,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,
diff --git a/products/replay_vision/backend/temporal/workflow.py b/products/replay_vision/backend/temporal/workflow.py
index 6d143b6bc81c..b97f8ae15d77 100644
--- a/products/replay_vision/backend/temporal/workflow.py
+++ b/products/replay_vision/backend/temporal/workflow.py
@@ -291,7 +291,7 @@ class ApplyScannerWorkflow(PostHogWorkflow):
try:
await wf.execute_child_workflow(
"rasterize-recording",
- RasterizeRecordingInputs(exported_asset_id=asset_id),
+ RasterizeRecordingInputs(exported_asset_id=asset_id, product="replay_vision"),
id=_rasterizer_workflow_id(inputs),
task_queue=settings.SESSION_REPLAY_TASK_QUEUE,
retry_policy=common.RetryPolicy(maximum_attempts=int(settings.TEMPORAL_WORKFLOW_MAX_ATTEMPTS)),