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.

feat(dashboards): support loading a collection in the session replay widget (#65874)

Matt Puab94478e22f51
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index b150e4363be4..7dc49fbe747b 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1857,17 +1857,17 @@ snapshots:
dashboards-dashboard-widgets-widget-types-experiments-experiments-widget-settings--default--light:
hash: v1.k794b7964.8715a7b54c54caeceabc7ada435074e73e2b0b3d8bada7d9f7f53e56b305d815.BNfFt-AV0Y6mZeXlQVNA3CZrm_kkfncCe-uU5dvbTg4
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--default--dark:
- hash: v1.k794b7964.1a5baf14a6ff53a6072ebc87ed92ec20014d81c90e9718dd144c869c7c0f1a6d.mntf80pED3WsfNCXd5dto32xdxLBogMzx9mjVP0E4Qk
+ hash: v1.k794b7964.80be8d5bc3bc852e53b6e261dd0baa6056f58f279f47ee47a90d6f1fa532ce3e.80W_kUIy8SCKVA9dBxabCGnYkR338yx0ry-UHYCpaVE
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--default--light:
- hash: v1.k794b7964.174eba9fddf2ca4e75de26df89877be8be3806118de31a51783172d0bb65ef77._au5PQmFg3Hwy24YPtpsX8E-Yduc0ryiTtiwbl9Ph-Y
+ hash: v1.k794b7964.a7c4753a1045bda4c172e6031c16fd0cabe57a94d484c5f0be25398534a9a7a3.-kF5L985fgvegJuWlVafBALa9h7QpVGtmUgKvW01cTU
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--empty--dark:
- hash: v1.k794b7964.592a89356f71503b99b8d0a6f86d0d0fcb8e19dc02a831fb2a2039b6fed6b458.4Odr8Kn6Nr083ssZqxMyogCHqVcXlE1olBFe8iFtdCE
+ hash: v1.k794b7964.a1509091a082125ca549a857c4067d38f84806f40029df75433aa107a872c702.e1gI4U73LRUHqNkoWHIYohsV3HPu_0CuxlaIaDm0bbc
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--empty--light:
- hash: v1.k794b7964.136e47e823367ddde1e45ad2029549d3d54c6c265a0fca15a2e013c10acad739.wzHAAYGHHBJKmNw2wT20CcWdc90sm7rjuyE0U0hahtk
+ hash: v1.k794b7964.6d502d91b7daf856d8a78bae0ad8a3de3174e57b1e472ad19dfd666afe58b005.yrfpzyzHJZ1su7bOLmHvq2CPro2SCikeq2Uv8a1QN_o
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--loading--dark:
- hash: v1.k794b7964.35d12cc442584f42f106f08dad08f7c982cd62456d8b17f339282811181ed433.E7b7wXwG8qjMLhV4ZcBi9wji-LIVO1ziUzXQ2JZMwnA
+ hash: v1.k794b7964.efa640c22bc2bcf9f2c2c75ee52a42a438b3b2065b56491e0a71303c24c36724.8ZMO_ZmtSeWa6AtpRRzgTSUHE5nrG6AoSHUbRrvHxr0
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--loading--light:
- hash: v1.k794b7964.51c40a376b640aee32bc2ab8eb0aa2972fcddae0d716bca64479cdb6be7d4a19.58GccMzkk2kg1UOBSWJLCxMTYffpCnhMrJoulJVe3Xg
+ hash: v1.k794b7964.60c44f77b3a6c43dbb6f8339bddf2e192ab1b74139ad5a1bc9aae3c7dcd70b35.d9XvWO1UtRfKe60HbRswc7bfXTvgnG-dJ6Xilq9-KKc
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--setup-unavailable--dark:
hash: v1.k794b7964.4d843ded3453a2be0dd16f6bb4efe34dd8de634388ed8073cf7c748b6614e186.RKgAGczYSH33uEfBaYGMSlXx7pa4c2QToaJprdtWnKs
dashboards-dashboard-widgets-widget-types-session-replay-recent-recordings--setup-unavailable--light:
diff --git a/products/dashboards/backend/api/test/test_run_widgets.py b/products/dashboards/backend/api/test/test_run_widgets.py
index 002c4f9cf948..c7e6989b4b82 100644
--- a/products/dashboards/backend/api/test/test_run_widgets.py
+++ b/products/dashboards/backend/api/test/test_run_widgets.py
@@ -21,6 +21,7 @@ from posthog.rbac.user_access_control import AccessControlLevel, UserAccessContr
from posthog.scopes import APIScopeObject
from posthog.session_recordings.models.session_recording import SessionRecording
from posthog.session_recordings.models.session_recording_playlist import SessionRecordingPlaylist
+from posthog.session_recordings.models.session_recording_playlist_item import SessionRecordingPlaylistItem
from posthog.slo.types import SloOperation, SloOutcome
from products.dashboards.backend.api import widget_openapi_serializers as widget_openapi_serializers_module
@@ -211,6 +212,15 @@ class TestWidgetRegistry(APIBaseTest):
)
assert validated["orderBy"] == order_by
+ @parameterized.expand(["savedFilterId", "collectionId"])
+ def test_validate_session_replay_list_config_normalizes_empty_source_id(self, field: str) -> None:
+ # The shared short_id validator coerces empty strings to None so they drop out of the config.
+ validated = validate_widget_config(SESSION_REPLAY_LIST_WIDGET_TYPE, {field: ""})
+ assert field not in validated
+
+ validated = validate_widget_config(SESSION_REPLAY_LIST_WIDGET_TYPE, {field: "abc123"})
+ assert validated[field] == "abc123"
+
class TestDashboardRunWidgets(APIBaseTest):
def setUp(self) -> None:
@@ -602,6 +612,174 @@ class TestDashboardRunWidgets(APIBaseTest):
assert query.properties is not None
assert query.properties[0].value == ["Chrome"]
+ @staticmethod
+ def _collection_with_recordings(team: Team, session_ids: list[str]) -> SessionRecordingPlaylist:
+ collection = SessionRecordingPlaylist.objects.create(team=team, name="My collection", type="collection")
+ for session_id in session_ids:
+ recording = SessionRecording.objects.create(team=team, session_id=session_id)
+ SessionRecordingPlaylistItem.objects.create(playlist=collection, recording=recording)
+ return collection
+
+ @patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
+ def test_session_replay_widget_scopes_to_collection(self, mock_list_recordings: MagicMock) -> None:
+ mock_list_recordings.return_value = ([], False, None, None)
+ collection = self._collection_with_recordings(self.team, ["session-a", "session-b"])
+
+ run_session_replay_list_widget(
+ self.team,
+ {
+ "limit": 5,
+ "orderBy": "click_count",
+ "orderDirection": "ASC",
+ "collectionId": collection.short_id,
+ # The widget's date range still narrows within the collection scope.
+ "dateRange": {"date_from": "-7d"},
+ },
+ user=self.user,
+ )
+
+ query = mock_list_recordings.call_args.kwargs["query"]
+ # The collection scopes the result set to its pinned recordings...
+ assert sorted(query.session_ids) == ["session-a", "session-b"]
+ assert query.properties is None
+ assert query.date_from == "-7d"
+ # ...while the widget still layers its own sort and limit on top.
+ assert query.limit == 5
+ assert query.order == RecordingOrder.CLICK_COUNT
+ assert query.order_direction == RecordingOrderDirection.ASC
+
+ @patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
+ def test_session_replay_widget_collection_skips_legacy_null_recording_items(
+ self, mock_list_recordings: MagicMock
+ ) -> None:
+ mock_list_recordings.return_value = ([], False, None, None)
+ collection = self._collection_with_recordings(self.team, ["session-a"])
+ # Legacy items used the deprecated session_id field and have a null recording FK.
+ SessionRecordingPlaylistItem.objects.create(playlist=collection, recording=None, session_id="legacy")
+
+ run_session_replay_list_widget(
+ self.team,
+ {"limit": 5, "collectionId": collection.short_id},
+ user=self.user,
+ )
+
+ query = mock_list_recordings.call_args.kwargs["query"]
+ # No None leaks into session_ids — the legacy null-recording item is skipped.
+ assert query.session_ids == ["session-a"]
+
+ @patch("products.dashboards.backend.widgets.session_replay_list.UserAccessControl")
+ @patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
+ def test_session_replay_widget_skips_collection_without_object_access(
+ self, mock_list_recordings: MagicMock, mock_user_access_control: MagicMock
+ ) -> None:
+ mock_list_recordings.return_value = ([], False, None, None)
+ # The user lacks object-level viewer access to the collection.
+ mock_user_access_control.return_value.check_access_level_for_object.return_value = False
+ collection = self._collection_with_recordings(self.team, ["session-a"])
+
+ run_session_replay_list_widget(
+ self.team,
+ {
+ "limit": 5,
+ "collectionId": collection.short_id,
+ "widgetFilters": self._widget_browser_filter("Chrome"),
+ },
+ user=self.user,
+ )
+
+ query = mock_list_recordings.call_args.kwargs["query"]
+ # An unauthorized collection is treated like a missing one — no session scope, fall back to filters.
+ assert query.session_ids is None
+ assert query.properties is not None
+ assert query.properties[0].value == ["Chrome"]
+
+ @patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
+ def test_session_replay_widget_filters_within_collection(self, mock_list_recordings: MagicMock) -> None:
+ mock_list_recordings.return_value = ([], False, None, None)
+ collection = self._collection_with_recordings(self.team, ["session-a", "session-b"])
+
+ run_session_replay_list_widget(
+ self.team,
+ {
+ "limit": 5,
+ "collectionId": collection.short_id,
+ # The widget's own property filters narrow within the collection scope.
+ "widgetFilters": self._widget_browser_filter("Chrome"),
+ },
+ user=self.user,
+ )
+
+ query = mock_list_recordings.call_args.kwargs["query"]
+ assert sorted(query.session_ids) == ["session-a", "session-b"]
+ assert query.properties is not None
+ assert query.properties[0].value == ["Chrome"]
+
+ @patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
+ def test_session_replay_widget_combines_collection_and_saved_filter(self, mock_list_recordings: MagicMock) -> None:
+ mock_list_recordings.return_value = ([], False, None, None)
+ collection = self._collection_with_recordings(self.team, ["session-a", "session-b"])
+ saved_filter = self._saved_filter_for_browser(self.team, "Firefox")
+
+ run_session_replay_list_widget(
+ self.team,
+ {
+ "limit": 5,
+ "collectionId": collection.short_id,
+ "savedFilterId": saved_filter.short_id,
+ },
+ user=self.user,
+ )
+
+ query = mock_list_recordings.call_args.kwargs["query"]
+ # The collection scopes the session ids while the saved filter owns the date range and properties.
+ assert sorted(query.session_ids) == ["session-a", "session-b"]
+ assert query.date_from == "-14d"
+ assert query.properties is not None
+ assert query.properties[0].value == ["Firefox"]
+
+ @patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
+ def test_session_replay_widget_ignores_collection_from_other_team(self, mock_list_recordings: MagicMock) -> None:
+ mock_list_recordings.return_value = ([], False, None, None)
+ other_team = Team.objects.create(organization=self.organization, name="other team")
+ collection = self._collection_with_recordings(other_team, ["session-a"])
+
+ run_session_replay_list_widget(
+ self.team,
+ {
+ "limit": 5,
+ "collectionId": collection.short_id,
+ "dateRange": {"date_from": "-7d"},
+ "widgetFilters": self._widget_browser_filter("Chrome"),
+ },
+ user=self.user,
+ )
+
+ query = mock_list_recordings.call_args.kwargs["query"]
+ # A collection owned by another team must not be reachable; fall back to the widget's filters.
+ assert query.session_ids is None
+ assert query.properties is not None
+ assert query.properties[0].value == ["Chrome"]
+
+ @patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
+ def test_session_replay_widget_falls_back_when_collection_missing(self, mock_list_recordings: MagicMock) -> None:
+ mock_list_recordings.return_value = ([], False, None, None)
+
+ run_session_replay_list_widget(
+ self.team,
+ {
+ "limit": 5,
+ "collectionId": "does_not_exist",
+ "dateRange": {"date_from": "-7d"},
+ "widgetFilters": self._widget_browser_filter("Chrome"),
+ },
+ user=self.user,
+ )
+
+ query = mock_list_recordings.call_args.kwargs["query"]
+ assert query.session_ids is None
+ assert query.properties is not None
+ assert query.properties[0].value == ["Chrome"]
+
@patch("posthog.session_recordings.session_recording_api.list_recordings_from_query")
def test_session_replay_widget_attaches_matching_events_query_for_widget_filters(
self, mock_list_recordings: MagicMock
diff --git a/products/dashboards/backend/constants.py b/products/dashboards/backend/constants.py
index 95339a1704c3..457205fd8468 100644
--- a/products/dashboards/backend/constants.py
+++ b/products/dashboards/backend/constants.py
@@ -14,6 +14,11 @@ ACTIVITY_EVENTS_DEFAULT_LIMIT = 25
# Cap widgets per batch create / run-widgets request.
MAX_WIDGETS_BATCH_SIZE = 10
+# Upper bound on pinned recordings pulled from a collection to scope a session replay widget. Bounds the
+# session_ids IN clause sent to ClickHouse and the Python list we materialize, matching the saved-filter
+# cap (MAX_SAVED_FILTER_SESSION_IDS_PER_PLAYLIST). The widget itself only ever shows MAX_WIDGET_RESULT_LIMIT.
+MAX_COLLECTION_SESSION_IDS = 1000
+
# Preset relative ranges only — widgets don't accept arbitrary HogQL date strings.
# Note: `M` is minutes, `m` would be months (see posthog.utils relative-date parsing).
WIDGET_DATE_FROM_VALUES_ORDERED: tuple[str, ...] = (
diff --git a/products/dashboards/backend/widget_specs/configs.py b/products/dashboards/backend/widget_specs/configs.py
index 9328ae1ea2d6..f35b2b8210b4 100644
--- a/products/dashboards/backend/widget_specs/configs.py
+++ b/products/dashboards/backend/widget_specs/configs.py
@@ -53,18 +53,27 @@ class SessionReplayListWidgetConfig(WidgetListConfigBase):
savedFilterId: str | None = Field(
default=None,
description=(
- "short_id of a saved session replay filter to use as the recordings source. When set, the saved filter "
- "owns the date range and property filters; only orderBy, orderDirection, and limit still apply."
+ "short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter "
+ "owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine "
+ "with collectionId to filter within a collection."
+ ),
+ )
+ collectionId: str | None = Field(
+ default=None,
+ description=(
+ "short_id of a session replay collection to scope the widget to its pinned recordings. Combine with "
+ "savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit "
+ "still apply."
),
)
- @field_validator("savedFilterId", mode="before")
+ @field_validator("savedFilterId", "collectionId", mode="before")
@classmethod
- def validate_saved_filter_id(cls, value: object) -> str | None:
+ def validate_short_id(cls, value: object) -> str | None:
if value is None or value == "":
return None
if not isinstance(value, str):
- raise ValueError("savedFilterId must be a string.")
+ raise ValueError("must be a string.")
return value
diff --git a/products/dashboards/backend/widgets/session_replay_list.py b/products/dashboards/backend/widgets/session_replay_list.py
index 875d9b078b88..c068246dc3c6 100644
--- a/products/dashboards/backend/widgets/session_replay_list.py
+++ b/products/dashboards/backend/widgets/session_replay_list.py
@@ -8,12 +8,14 @@ from posthog.schema import RecordingOrder, RecordingOrderDirection, RecordingsQu
from posthog.clickhouse.query_tagging import Feature, Product, tags_context
from posthog.models.team import Team
from posthog.models.user import User
+from posthog.rbac.user_access_control import UserAccessControl
from posthog.session_recordings.models.session_recording_playlist import SessionRecordingPlaylist
+from posthog.session_recordings.models.session_recording_playlist_item import SessionRecordingPlaylistItem
from posthog.session_recordings.playlist_filters import convert_playlist_to_recordings_query
from posthog.session_recordings.session_recording_api import run_recordings_list_query
from posthog.session_recordings.utils import filter_from_params_to_query, recordings_query_has_event_filters
-from products.dashboards.backend.constants import MAX_WIDGET_RESULT_LIMIT
+from products.dashboards.backend.constants import MAX_COLLECTION_SESSION_IDS, MAX_WIDGET_RESULT_LIMIT
from products.dashboards.backend.widget_specs.configs import SESSION_REPLAY_LIST_WIDGET_TYPE
from products.dashboards.backend.widget_specs.registry import validate_widget_config
from products.dashboards.backend.widgets.config import resolve_filter_test_accounts
@@ -34,17 +36,28 @@ ORDER_BY_TO_RECORDING_ORDER: dict[str, RecordingOrder] = {
}
+def _user_can_view_playlist(user: User | None, team: Team, playlist: SessionRecordingPlaylist) -> bool:
+ # Mirror the object-level "viewer" access the playlist API enforces, so a widget can't surface a
+ # playlist the requesting user isn't allowed to see. No-ops to True when access controls aren't
+ # licensed/configured, so the common case (everyone can view) is unaffected.
+ if user is None or user.is_anonymous:
+ return False
+ return UserAccessControl(user=user, team=team).check_access_level_for_object(playlist, "viewer")
+
+
def _build_saved_filter_recordings_query(
team: Team,
config: ValidatedSessionReplayListWidgetConfig,
saved_filter_id: str,
+ user: User | None,
) -> RecordingsQuery | None:
# The saved filter (SessionRecordingPlaylist of type "filters") is the source of truth for
# date range and property filters; the widget only layers its own sort and limit on top.
playlist = SessionRecordingPlaylist.objects.filter(
team=team, short_id=saved_filter_id, deleted=False, type="filters"
).first()
- if playlist is None:
+ # Treat a playlist the user can't view the same as a missing one — fall back without revealing it exists.
+ if playlist is None or not _user_can_view_playlist(user, team, playlist):
logger.warning("session_replay_widget_saved_filter_not_found", extra={"short_id": saved_filter_id})
return None
@@ -57,33 +70,67 @@ def _build_saved_filter_recordings_query(
return query
-def _build_recordings_query(team: Team, config: ValidatedSessionReplayListWidgetConfig) -> RecordingsQuery:
+def _build_collection_session_ids(team: Team, collection_id: str, user: User | None) -> list[str] | None:
+ # The pinned recordings of a collection (SessionRecordingPlaylist of type "collection"). Returns None when
+ # the collection can't be reached (deleted, missing, or owned by another team) so the caller can ignore it.
+ playlist = SessionRecordingPlaylist.objects.filter(
+ team=team, short_id=collection_id, deleted=False, type="collection"
+ ).first()
+ # Treat a collection the user can't view the same as a missing one — fall back without revealing it exists.
+ if playlist is None or not _user_can_view_playlist(user, team, playlist):
+ logger.warning("session_replay_widget_collection_not_found", extra={"short_id": collection_id})
+ return None
+
+ # Legacy items can have a null recording FK (they used the deprecated session_id field instead); skip
+ # them so no None leaks into session_ids and corrupts the ClickHouse IN clause. Cap the count so a huge
+ # collection can't blow up the materialized list or the ClickHouse IN clause (the widget shows far fewer).
+ return list(
+ SessionRecordingPlaylistItem.objects.filter(playlist=playlist, recording__isnull=False)
+ .exclude(deleted=True)
+ .order_by("-created_at")
+ .values_list("recording_id", flat=True)[:MAX_COLLECTION_SESSION_IDS]
+ )
+
+
+def _build_recordings_query(
+ team: Team, config: ValidatedSessionReplayListWidgetConfig, user: User | None
+) -> RecordingsQuery:
+ collection_id = config.get("collectionId")
+ collection_session_ids = _build_collection_session_ids(team, collection_id, user) if collection_id else None
+ has_collection = collection_session_ids is not None
+
+ # The query criteria come from the saved filter when one is set; otherwise from the widget's own controls.
+ # A collection (if any) is then layered on as a session-id scope, so the date range / saved filter /
+ # property filters all narrow within the collection.
saved_filter_id = config.get("savedFilterId")
- if saved_filter_id:
- saved_filter_query = _build_saved_filter_recordings_query(team, config, saved_filter_id)
- if saved_filter_query is not None:
- return saved_filter_query
-
- date_range_raw = config.get("dateRange")
- date_from = "-7d"
- if date_range_raw is not None:
- date_from_value = date_range_raw.get("date_from")
- if isinstance(date_from_value, str):
- date_from = date_from_value
-
- params: dict[str, Any] = {
- "limit": config["limit"],
- "offset": 0,
- "date_from": date_from,
- "filter_test_accounts": resolve_filter_test_accounts(config, team),
- "order": ORDER_BY_TO_RECORDING_ORDER[config["orderBy"]],
- "order_direction": config["orderDirection"],
- }
- property_filters = build_event_property_filters_from_widget_filters(config.get("widgetFilters"))
- if property_filters:
- params["properties"] = property_filters
-
- return filter_from_params_to_query(params)
+ query = _build_saved_filter_recordings_query(team, config, saved_filter_id, user) if saved_filter_id else None
+
+ if query is None:
+ date_range_raw = config.get("dateRange")
+ date_from = "-7d"
+ if date_range_raw is not None:
+ date_from_value = date_range_raw.get("date_from")
+ if isinstance(date_from_value, str):
+ date_from = date_from_value
+
+ params: dict[str, Any] = {
+ "limit": config["limit"],
+ "offset": 0,
+ "date_from": date_from,
+ "filter_test_accounts": resolve_filter_test_accounts(config, team),
+ "order": ORDER_BY_TO_RECORDING_ORDER[config["orderBy"]],
+ "order_direction": config["orderDirection"],
+ }
+ property_filters = build_event_property_filters_from_widget_filters(config.get("widgetFilters"))
+ if property_filters:
+ params["properties"] = property_filters
+
+ query = filter_from_params_to_query(params)
+
+ if has_collection:
+ query.session_ids = collection_session_ids
+
+ return query
def _build_matching_events_query(query: RecordingsQuery) -> dict[str, Any] | None:
@@ -120,7 +167,7 @@ def run_session_replay_list_widget(
typed_config = validate_widget_config(SESSION_REPLAY_LIST_WIDGET_TYPE, config)
# Build once so a saved-filter playlist is fetched/converted only a single time; both the
# visible page and the count page reuse it via model_copy with just the page limit.
- query = _build_recordings_query(team, typed_config)
+ query = _build_recordings_query(team, typed_config, user)
def fetch_page(page_limit: int) -> ListWidgetPage:
page_query = query.model_copy(update={"limit": page_limit, "offset": 0})
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index f1f71dce67b5..d916ad43c165 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -631,8 +631,10 @@ export interface SessionReplayListWidgetConfigApi {
orderBy?: SessionReplayListWidgetConfigApiOrderBy
/** Sort direction for orderBy. */
orderDirection?: SessionReplayListWidgetConfigApiOrderDirection
- /** short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. */
+ /** short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection. */
savedFilterId?: string | null
+ /** short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply. */
+ collectionId?: string | null
}
/**
diff --git a/products/dashboards/frontend/generated/api.zod.ts b/products/dashboards/frontend/generated/api.zod.ts
index 9eecad352fef..b48d9e1d89dd 100644
--- a/products/dashboards/frontend/generated/api.zod.ts
+++ b/products/dashboards/frontend/generated/api.zod.ts
@@ -632,7 +632,13 @@ export const DashboardsPartialUpdateBody = /* @__PURE__ */ zod
.union([zod.string(), zod.null()])
.optional()
.describe(
- 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ 'short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection.'
+ ),
+ collectionId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply.'
),
}),
zod.object({
@@ -1378,7 +1384,13 @@ export const DashboardsWidgetsBatchCreateBody = /* @__PURE__ */ zod
.union([zod.string(), zod.null()])
.optional()
.describe(
- 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ 'short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection.'
+ ),
+ collectionId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply.'
),
})
.describe('Configuration for the recent recordings widget.'),
@@ -1952,7 +1964,13 @@ export const DashboardsUpdateWidgetsBatchBody = /* @__PURE__ */ zod
.union([zod.string(), zod.null()])
.optional()
.describe(
- 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ 'short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection.'
+ ),
+ collectionId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply.'
),
})
.optional()
diff --git a/products/dashboards/frontend/generated/widget-config-property-keys.json b/products/dashboards/frontend/generated/widget-config-property-keys.json
index 3108ef43319d..38c6d77654bc 100644
--- a/products/dashboards/frontend/generated/widget-config-property-keys.json
+++ b/products/dashboards/frontend/generated/widget-config-property-keys.json
@@ -12,6 +12,7 @@
"widgetFilters"
],
"session_replay_list": [
+ "collectionId",
"dateRange",
"filterTestAccounts",
"limit",
@@ -259,6 +260,9 @@
},
"savedFilterId": {
"$type": "string"
+ },
+ "collectionId": {
+ "$type": "string"
}
},
"experiments_list": {
diff --git a/products/dashboards/frontend/generated/widget-config-schemas/sessionReplayListWidgetConfig.zod.ts b/products/dashboards/frontend/generated/widget-config-schemas/sessionReplayListWidgetConfig.zod.ts
index b880bed17d46..b5ff05768087 100644
--- a/products/dashboards/frontend/generated/widget-config-schemas/sessionReplayListWidgetConfig.zod.ts
+++ b/products/dashboards/frontend/generated/widget-config-schemas/sessionReplayListWidgetConfig.zod.ts
@@ -37,7 +37,13 @@ export const SessionReplayListWidgetConfig = /* @__PURE__ */ zod.object({
.union([zod.string(), zod.null()])
.optional()
.describe(
- 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ 'short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection.'
+ ),
+ collectionId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply.'
),
})
diff --git a/products/dashboards/frontend/widgets/session_replay/SessionReplayWidget.tsx b/products/dashboards/frontend/widgets/session_replay/SessionReplayWidget.tsx
index c9b69e2b5da7..0397890ae57e 100644
--- a/products/dashboards/frontend/widgets/session_replay/SessionReplayWidget.tsx
+++ b/products/dashboards/frontend/widgets/session_replay/SessionReplayWidget.tsx
@@ -173,22 +173,32 @@ export function SessionReplayWidget({ result, loading, config }: DashboardWidget
)
}
-// A saved filter overrides the widget's date range, so the header shows the filter's name in its place.
+// A collection or saved filter scopes the widget instead of its date range, so the header shows their
+// names in place — e.g. "My collection · My filter" when both are set.
export function SessionReplayWidgetTopHeading({
config,
widgetTypeLabel,
showWidgetType,
dateText,
}: DashboardWidgetTopHeadingProps): JSX.Element {
- const rawSavedFilterId = config.savedFilterId
- const savedFilterId = typeof rawSavedFilterId === 'string' && rawSavedFilterId.length > 0 ? rawSavedFilterId : null
- const { savedFilterLabelById } = useValues(sessionReplayWidgetSavedFiltersLogic)
+ const asShortId = (value: unknown): string | null => (typeof value === 'string' && value.length > 0 ? value : null)
+ const savedFilterId = asShortId(config.savedFilterId)
+ const collectionId = asShortId(config.collectionId)
+ const { savedFilterLabelById, collectionLabelById } = useValues(sessionReplayWidgetSavedFiltersLogic)
+
+ const scopeParts: string[] = []
+ if (collectionId) {
+ scopeParts.push(collectionLabelById[collectionId] ?? 'Collection')
+ }
+ if (savedFilterId) {
+ scopeParts.push(savedFilterLabelById[savedFilterId] ?? 'Saved filter')
+ }
return (
<CardTopHeadingRow
typeLabel={widgetTypeLabel}
showTypeLabel={showWidgetType}
- dateText={savedFilterId ? (savedFilterLabelById[savedFilterId] ?? 'Saved filter') : dateText}
+ dateText={scopeParts.length > 0 ? scopeParts.join(' · ') : dateText}
/>
)
}
diff --git a/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx
index 53c82578c576..6202c4af7ac6 100644
--- a/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx
@@ -5,9 +5,11 @@ import { useMemo, useRef } from 'react'
import { IconExternal } from '@posthog/icons'
import { quickFiltersLogic } from 'lib/components/QuickFilters/quickFiltersLogic'
-import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
+import { LemonSelect, type LemonSelectOptionLeaf } from 'lib/lemon-ui/LemonSelect'
import { urls } from 'scenes/urls'
+import { ReplayTabs } from '~/types'
+
import { WIDGET_DATE_RANGE_SELECT_OPTIONS, type WidgetDateFromValue } from '../../widget_types/widgetConfigShared'
import type { DashboardWidgetTileFiltersProps } from '../registry'
import { WidgetPropertyFiltersSection } from '../WidgetPropertyFiltersSection'
@@ -25,8 +27,9 @@ import { sessionReplayWidgetSavedFiltersLogic } from './sessionReplayWidgetSaved
export type SessionReplayWidgetTileFiltersProps = DashboardWidgetTileFiltersProps
-const NO_SAVED_FILTER_OPTION = { value: null as string | null, label: 'No saved filter' }
+const NONE_VALUE = '__none__'
const CREATE_SAVED_FILTER_VALUE = '__create_saved_filter__'
+const CREATE_COLLECTION_VALUE = '__create_collection__'
export function SessionReplayWidgetTileFilters({
config,
@@ -38,22 +41,46 @@ export function SessionReplayWidgetTileFilters({
const dateFrom = (parsed.dateRange?.date_from ?? '-7d') as WidgetDateFromValue
const widgetFilters = parsed.widgetFilters ?? {}
const savedFilterId = parsed.savedFilterId ?? null
+ const collectionId = parsed.collectionId ?? null
const hasSavedFilter = !!savedFilterId
+ const hasCollection = !!collectionId
+ // A saved filter owns the date range and property filters. Otherwise both controls apply — including on
+ // top of a collection, so you can scope to a collection and still narrow it by date and properties.
+ const showDateRange = !hasSavedFilter
+ const showPropertyFilters = !hasSavedFilter
const { quickFilters: projectFilterDefinitions } = useValues(
quickFiltersLogic({ context: filterDefinitionsContext })
)
- const { savedFilterOptions, savedFiltersLoading, savedFilterLabelById } = useValues(
- sessionReplayWidgetSavedFiltersLogic
- )
+ const {
+ savedFilterOptions,
+ collectionOptions,
+ savedFiltersLoading,
+ collectionsLoading,
+ savedFilterLabelById,
+ collectionLabelById,
+ } = useValues(sessionReplayWidgetSavedFiltersLogic)
const filterDefinitions = useMemo(
() => projectFilterDefinitions.filter(isAllowed),
[projectFilterDefinitions, isAllowed]
)
- const savedFilterSelectOptions = useMemo(
+ const collectionSelectOptions = useMemo<LemonSelectOptionLeaf<string>[]>(
+ () => [
+ { value: NONE_VALUE, label: 'No collection' },
+ ...collectionOptions,
+ // Always offer a shortcut to create a new collection in session replay.
+ {
+ value: CREATE_COLLECTION_VALUE,
+ label: 'Create a collection',
+ sideIcon: <IconExternal className="size-3.5" />,
+ },
+ ],
+ [collectionOptions]
+ )
+ const savedFilterSelectOptions = useMemo<LemonSelectOptionLeaf<string>[]>(
() => [
- NO_SAVED_FILTER_OPTION,
+ { value: NONE_VALUE, label: 'No saved filter' },
...savedFilterOptions,
// Always offer a shortcut to create a new saved filter in session replay.
{
@@ -64,7 +91,9 @@ export function SessionReplayWidgetTileFilters({
],
[savedFilterOptions]
)
- const savedFilterLabel = savedFilterId ? (savedFilterLabelById[savedFilterId] ?? savedFilterId) : savedFilterId
+
+ const savedFilterLabel = savedFilterId ? (savedFilterLabelById[savedFilterId] ?? savedFilterId) : null
+ const collectionLabel = collectionId ? (collectionLabelById[collectionId] ?? collectionId) : null
const configRef = useRef(config)
configRef.current = config
@@ -79,13 +108,28 @@ export function SessionReplayWidgetTileFilters({
await persistConfigNow(nextConfig)
}
+ const applyCollection = async (value: string | null): Promise<void> => {
+ // The "create" item is a navigation shortcut to the collections tab, not a persisted value.
+ if (value === CREATE_COLLECTION_VALUE) {
+ window.open(urls.replay(ReplayTabs.Playlists), '_blank', 'noopener,noreferrer')
+ return
+ }
+ const nextConfig = patchSessionReplayWidgetFilterFields(configRef.current, {
+ collectionId: value && value !== NONE_VALUE ? value : null,
+ })
+ configRef.current = nextConfig
+ await persistConfigNow(nextConfig)
+ }
+
const applySavedFilter = async (value: string | null): Promise<void> => {
// The "create" item is a navigation shortcut, not a persisted value.
if (value === CREATE_SAVED_FILTER_VALUE) {
window.open(urls.replay(), '_blank', 'noopener,noreferrer')
return
}
- const nextConfig = patchSessionReplayWidgetFilterFields(configRef.current, { savedFilterId: value })
+ const nextConfig = patchSessionReplayWidgetFilterFields(configRef.current, {
+ savedFilterId: value && value !== NONE_VALUE ? value : null,
+ })
configRef.current = nextConfig
await persistConfigNow(nextConfig)
}
@@ -103,19 +147,15 @@ export function SessionReplayWidgetTileFilters({
if (!onUpdateConfig) {
return (
<WidgetTileFiltersBar dataAttr="session-replay-widget-tile-filters-readonly">
- {hasSavedFilter ? (
- <span className="text-sm text-muted">Saved filter: {savedFilterLabel}</span>
- ) : (
- <>
- <WidgetDateRangeReadOnlyValue dateFrom={dateFrom} />
- {filterDefinitions.length > 0 ? (
- <WidgetPropertyFiltersReadOnlyValues
- filterDefinitions={filterDefinitions}
- widgetFilters={widgetFilters}
- />
- ) : null}
- </>
- )}
+ {hasCollection ? <span className="text-sm text-muted">Collection: {collectionLabel}</span> : null}
+ {hasSavedFilter ? <span className="text-sm text-muted">Filter: {savedFilterLabel}</span> : null}
+ {showDateRange ? <WidgetDateRangeReadOnlyValue dateFrom={dateFrom} /> : null}
+ {showPropertyFilters && filterDefinitions.length > 0 ? (
+ <WidgetPropertyFiltersReadOnlyValues
+ filterDefinitions={filterDefinitions}
+ widgetFilters={widgetFilters}
+ />
+ ) : null}
</WidgetTileFiltersBar>
)
}
@@ -124,36 +164,44 @@ export function SessionReplayWidgetTileFilters({
<WidgetTileFiltersBar dataAttr="session-replay-widget-tile-filters">
<LemonSelect
size="small"
- value={savedFilterId}
+ value={collectionId ?? NONE_VALUE}
+ disabled={!canUpdate}
+ disabledReason={controlDisabledReason}
+ loading={collectionsLoading}
+ options={collectionSelectOptions}
+ placeholder="Collection"
+ onChange={(value) => void applyCollection(value)}
+ />
+ <LemonSelect
+ size="small"
+ value={savedFilterId ?? NONE_VALUE}
disabled={!canUpdate}
disabledReason={controlDisabledReason}
loading={savedFiltersLoading}
options={savedFilterSelectOptions}
placeholder="Saved filter"
- onChange={(value) => void applySavedFilter(value ?? null)}
+ onChange={(value) => void applySavedFilter(value)}
/>
- {!hasSavedFilter ? (
- <>
- <LemonSelect
- size="small"
- value={dateFrom}
- disabled={!canUpdate}
- disabledReason={controlDisabledReason}
- options={WIDGET_DATE_RANGE_SELECT_OPTIONS}
- onChange={(value) => {
- if (value) {
- void applyDateFrom(value)
- }
- }}
- />
- {filterDefinitions.length > 0 ? (
- <WidgetPropertyFiltersSection
- filterDefinitions={filterDefinitions}
- widgetFilters={widgetFilters}
- onWidgetFiltersChange={applyWidgetFilters}
- />
- ) : null}
- </>
+ {showDateRange ? (
+ <LemonSelect
+ size="small"
+ value={dateFrom}
+ disabled={!canUpdate}
+ disabledReason={controlDisabledReason}
+ options={WIDGET_DATE_RANGE_SELECT_OPTIONS}
+ onChange={(value) => {
+ if (value) {
+ void applyDateFrom(value)
+ }
+ }}
+ />
+ ) : null}
+ {showPropertyFilters && filterDefinitions.length > 0 ? (
+ <WidgetPropertyFiltersSection
+ filterDefinitions={filterDefinitions}
+ widgetFilters={widgetFilters}
+ onWidgetFiltersChange={applyWidgetFilters}
+ />
) : null}
</WidgetTileFiltersBar>
)
diff --git a/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.test.ts b/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.test.ts
index f39a345eac08..b8402b609642 100644
--- a/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.test.ts
+++ b/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.test.ts
@@ -113,6 +113,24 @@ describe('patchSessionReplayWidgetFilterFields', () => {
expect(cleared.savedFilterId).toBeNull()
expect(cleared.dateRange).toEqual({ date_from: '-30d' })
})
+
+ it('sets a collection and saved filter independently so they can be combined', () => {
+ const config = sessionReplayWidgetConfigSchema.parse({})
+
+ // A collection (scope) and a saved filter (refinement) coexist — neither clears the other.
+ const withCollection = patchSessionReplayWidgetFilterFields(config, { collectionId: 'col123' })
+ expect(withCollection.collectionId).toBe('col123')
+ expect(withCollection.savedFilterId).toBeNull()
+
+ const withBoth = patchSessionReplayWidgetFilterFields(withCollection, { savedFilterId: 'abc123' })
+ expect(withBoth.collectionId).toBe('col123')
+ expect(withBoth.savedFilterId).toBe('abc123')
+
+ // Clearing one leaves the other untouched.
+ const collectionCleared = patchSessionReplayWidgetFilterFields(withBoth, { collectionId: null })
+ expect(collectionCleared.collectionId).toBeNull()
+ expect(collectionCleared.savedFilterId).toBe('abc123')
+ })
})
describe('parseSessionReplayWidgetConfigApiError', () => {
diff --git a/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.ts b/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.ts
index 1e2465180acc..654cf80643c9 100644
--- a/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.ts
+++ b/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetConfigValidation.ts
@@ -35,16 +35,20 @@ export function patchSessionReplayWidgetFilterFields(
dateFrom?: WidgetDateFromValue
widgetFilters?: Record<string, StoredWidgetFilter>
savedFilterId?: string | null
+ collectionId?: string | null
}
): SessionReplayWidgetConfig {
const base = parseSessionReplayWidgetConfig(config)
+ // A collection (scope) and a saved filter (refinement) are independent — each patches only its own field.
const savedFilterId = patch.savedFilterId !== undefined ? patch.savedFilterId : (base.savedFilterId ?? null)
+ const collectionId = patch.collectionId !== undefined ? patch.collectionId : (base.collectionId ?? null)
return sessionReplayWidgetConfigSchema.parse({
...base,
dateRange: { date_from: patch.dateFrom ?? base.dateRange?.date_from ?? '-7d' },
widgetFilters: patch.widgetFilters ?? base.widgetFilters ?? {},
savedFilterId,
+ collectionId,
})
}
diff --git a/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetSavedFiltersLogic.ts b/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetSavedFiltersLogic.ts
index 057a1e353495..0cc2c7c2358a 100644
--- a/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetSavedFiltersLogic.ts
+++ b/products/dashboards/frontend/widgets/session_replay/sessionReplayWidgetSavedFiltersLogic.ts
@@ -8,7 +8,17 @@ import type { SessionRecordingPlaylistType } from '~/types'
import type { sessionReplayWidgetSavedFiltersLogicType } from './sessionReplayWidgetSavedFiltersLogicType'
-// Saved session replay filters are SessionRecordingPlaylist rows with type "filters".
+const toOptions = (
+ playlists: SessionRecordingPlaylistType[],
+ unnamedLabel: string
+): { value: string; label: string }[] =>
+ playlists.map((playlist) => ({
+ value: playlist.short_id,
+ label: playlist.name || playlist.derived_name || unnamedLabel,
+ }))
+
+// Saved session replay filters and collections are both SessionRecordingPlaylist rows, distinguished by
+// type ("filters" vs "collection"). The widget can source recordings from either, so we load both here.
export const sessionReplayWidgetSavedFiltersLogic = kea<sessionReplayWidgetSavedFiltersLogicType>([
path(['products', 'dashboards', 'widgets', 'session_replay', 'sessionReplayWidgetSavedFiltersLogic']),
loaders({
@@ -21,15 +31,24 @@ export const sessionReplayWidgetSavedFiltersLogic = kea<sessionReplayWidgetSaved
return response.results
},
},
+ collections: {
+ __default: [] as SessionRecordingPlaylistType[],
+ loadCollections: async () => {
+ const response = await api.recordings.listPlaylists(
+ toParams({ limit: 100, order: '-last_modified_at', type: 'collection' })
+ )
+ return response.results
+ },
+ },
}),
selectors({
savedFilterOptions: [
(s) => [s.savedFilters],
- (savedFilters): { value: string; label: string }[] =>
- savedFilters.map((filter) => ({
- value: filter.short_id,
- label: filter.name || filter.derived_name || 'Unnamed filter',
- })),
+ (savedFilters): { value: string; label: string }[] => toOptions(savedFilters, 'Unnamed filter'),
+ ],
+ collectionOptions: [
+ (s) => [s.collections],
+ (collections): { value: string; label: string }[] => toOptions(collections, 'Unnamed collection'),
],
// Single source for resolving a saved-filter short_id to its display label, shared by the
// tile filter bar and the card header top heading.
@@ -38,8 +57,30 @@ export const sessionReplayWidgetSavedFiltersLogic = kea<sessionReplayWidgetSaved
(savedFilterOptions): Record<string, string> =>
Object.fromEntries(savedFilterOptions.map((option) => [option.value, option.label])),
],
+ collectionLabelById: [
+ (s) => [s.collectionOptions],
+ (collectionOptions): Record<string, string> =>
+ Object.fromEntries(collectionOptions.map((option) => [option.value, option.label])),
+ ],
}),
- afterMount(({ actions }) => {
+ afterMount(({ actions, cache }) => {
actions.loadSavedFilters()
+ actions.loadCollections()
+ // The "Create a collection / saved filter" shortcuts open session replay in a new tab. Reload both
+ // lists when the user returns so a just-created collection/filter is selectable without a page refresh.
+ cache.disposables.add(
+ () => {
+ const handler = (): void => {
+ if (document.visibilityState === 'visible') {
+ actions.loadSavedFilters()
+ actions.loadCollections()
+ }
+ }
+ document.addEventListener('visibilitychange', handler)
+ return () => document.removeEventListener('visibilitychange', handler)
+ },
+ 'reloadOnTabFocus',
+ { pauseOnPageHidden: false }
+ )
}),
])
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 6ce117a3d3c2..9390cd2cf794 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -4258,8 +4258,10 @@ export namespace Schemas {
orderBy?: SessionReplayListWidgetConfigOrderBy;
/** Sort direction for orderBy. */
orderDirection?: SessionReplayListWidgetConfigOrderDirection;
- /** short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. */
+ /** short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection. */
savedFilterId?: string | null;
+ /** short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply. */
+ collectionId?: string | null;
}
export interface SessionReplayListWidgetAddRequestOpenApi {
diff --git a/services/mcp/src/generated/dashboards/api.ts b/services/mcp/src/generated/dashboards/api.ts
index 6253e8ed59b1..d02dbb08e2d9 100644
--- a/services/mcp/src/generated/dashboards/api.ts
+++ b/services/mcp/src/generated/dashboards/api.ts
@@ -534,7 +534,13 @@ export const DashboardsPartialUpdateBody = /* @__PURE__ */ zod
.union([zod.string(), zod.null()])
.optional()
.describe(
- 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ 'short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection.'
+ ),
+ collectionId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply.'
),
}),
zod.object({
@@ -1432,7 +1438,13 @@ export const DashboardsWidgetsBatchCreateBody = /* @__PURE__ */ zod
.union([zod.string(), zod.null()])
.optional()
.describe(
- 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ 'short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection.'
+ ),
+ collectionId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply.'
),
})
.describe('Configuration for the recent recordings widget.'),
@@ -2019,7 +2031,13 @@ export const DashboardsUpdateWidgetsBatchBody = /* @__PURE__ */ zod
.union([zod.string(), zod.null()])
.optional()
.describe(
- 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ 'short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection.'
+ ),
+ collectionId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply.'
),
})
.optional()
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
index 7718756d109d..4764848061a5 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
@@ -475,6 +475,17 @@
},
{
"properties": {
+ "collectionId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply."
+ },
"dateRange": {
"anyOf": [
{
@@ -553,7 +564,7 @@
"type": "null"
}
],
- "description": "short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply."
+ "description": "short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection."
},
"widgetFilters": {
"anyOf": [
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-add.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-add.json
index 4fd920086b17..82a7e54e3438 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-add.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-add.json
@@ -523,6 +523,17 @@
"config": {
"description": "Configuration for the recent recordings widget.",
"properties": {
+ "collectionId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply."
+ },
"dateRange": {
"anyOf": [
{
@@ -601,7 +612,7 @@
"type": "null"
}
],
- "description": "short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply."
+ "description": "short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection."
},
"widgetFilters": {
"anyOf": [
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-update.json
index 6aaf5e331351..f63d550afba6 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-update.json
@@ -423,6 +423,17 @@
"config": {
"description": "New configuration for the recent recordings widget. Omit to leave unchanged.",
"properties": {
+ "collectionId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "short_id of a session replay collection to scope the widget to its pinned recordings. Combine with savedFilterId or property filters to narrow within the collection; orderBy, orderDirection, and limit still apply."
+ },
"dateRange": {
"anyOf": [
{
@@ -501,7 +512,7 @@
"type": "null"
}
],
- "description": "short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply."
+ "description": "short_id of a saved session replay filter to refine the recordings shown. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply. Combine with collectionId to filter within a collection."
},
"widgetFilters": {
"anyOf": [