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): add activity widget property filters (#70782)

Matt Puac3ea0e9776e0
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index ccd8898a7cdf..ce566221cc91 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1925,17 +1925,17 @@ snapshots:
dashboards-dashboard-widgets-overview--all-widget-types--light:
hash: v1.k794b7964.59fb61901d264c3bf3cd29dd681c9ace3520a5e14a4fcd0e8d11f44994a52600.tvKjlXPoKEJOPZWaP3E52rAkO4FRlDQjaB0SJVPY_6k
dashboards-dashboard-widgets-widget-types-activity-recent-events--default--dark:
- hash: v1.k794b7964.2452910051f06a264c5af21e003ab5286fa4b7be350b8e4c193aff454778e5b9.nowYT2exrkg_P27P5mOBomdP2jOUawjYAx6tD9v72OI
+ hash: v1.k794b7964.c69d28ef03335511de9b7dd75d5ad1c0458272d5d8f340083cdb86acc3b3c888.sG6UTKifs9l67mTpsjqLovlcw0LSVzL56FVlvzJMwhw
dashboards-dashboard-widgets-widget-types-activity-recent-events--default--light:
- hash: v1.k794b7964.718e60acbc45fa3d116cb0d33db3779fd22b192ee61b7c2ff8df943a16028c49.WEufCcKq22LRQzVfAh-NTKeOevE0TcYwC9q2R06DF1o
+ hash: v1.k794b7964.233cb727aaecfd19327bedd009d996c7fa04750a52e55f89428463c205016b70.FSObaa4l6dhVDMAAX2WThoyievlc55VNRpja9CO_md8
dashboards-dashboard-widgets-widget-types-activity-recent-events--empty--dark:
- hash: v1.k794b7964.730a19232754e6a00e9af2a8a4c17831013544fcfc6019267d13f4cab7e3ca26.aTinTWYCBDKHlfjbxxnHxBPOTdOeYAFEUDyE66liurM
+ hash: v1.k794b7964.523ebce5008e94d9b9aff5e970980ead40cd2bbd179db1af3577965c1375b2b9.4avue7kDjaSOHugE4GuSiRQx5GA6MuzGrt-zVPBFdh8
dashboards-dashboard-widgets-widget-types-activity-recent-events--empty--light:
- hash: v1.k794b7964.12f049d37afe4836f7e12fdd9eb555ca9bf4cd9ecd350d50d780ba43ece63a31.Thl9fx5DTcoq1x_M4R4nbKje3g9mmTwSkdfy80A6mro
+ hash: v1.k794b7964.755f7b40674d5f27a9930e476c4e4d09a62c918408ff49553e1cc5c67f69ae63.YMNLKBbAFZt64PhOcNuLs5yjWfM3cjwllj-hw0R4xK0
dashboards-dashboard-widgets-widget-types-activity-recent-events--loading--dark:
- hash: v1.k794b7964.87cae4729937995b072889db74be4ed80f9dccc0c30c5ce0721f45cfdd054e3b.KkLauKTJRRWPwd_3lpvffCi2ciBnKzWMWA_xX5M04q4
+ hash: v1.k794b7964.2d8bf0bf8c9da7bde31f52653ca4ef033430f9c657a7a1923b6730cf9ed857cb.YMwHbhFjFW3C01kJ4lpY8cLiPFZ3vqU0ZxoIgNOVE8I
dashboards-dashboard-widgets-widget-types-activity-recent-events--loading--light:
- hash: v1.k794b7964.19aaea74e5b83b2978aaa2fbe2e1571b04a369cc1fb81f35894cdd3003298d22.C66YRZlvfw0EMx5KqApeYTUOIeHxEPSCDJEYxJhO4qI
+ hash: v1.k794b7964.e88d69650143ac49b21e984aa8c26becabf97f16d61c8cae46fe7b1f72eaa94f.bg6LDBIimmJtjN-9bOmalC2zCiU0G4BNVHSupcIwwJk
dashboards-dashboard-widgets-widget-types-activity-recent-events--tile-filters-read-only--dark:
hash: v1.k794b7964.092862fa126fa9d89eb14efa0eebc8f74cfeb10aa1550301404662317ff6cfae.yckxUzCihAx1XdCoH-5WZJomiag7K40nW6gXRoUG_rY
dashboards-dashboard-widgets-widget-types-activity-recent-events--tile-filters-read-only--light:
diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.py
index 42c058c46e40..2b357cd02f9e 100644
--- a/products/dashboards/backend/api/dashboard.py
+++ b/products/dashboards/backend/api/dashboard.py
@@ -1657,9 +1657,10 @@ class DashboardSerializer(DashboardMetadataSerializer):
previous_widget_filters = extract_widget_filters(widget.widget_type, widget.config)
if "config" in widget_data:
+ config_patch = widget_data["config"]
widget.config = validate_widget_config(
widget.widget_type,
- widget_data["config"],
+ {**widget.config, **config_patch},
)
if "name" in widget_data:
widget.name = widget_data["name"] or None
diff --git a/products/dashboards/backend/api/test/test_dashboard_widgets.py b/products/dashboards/backend/api/test/test_dashboard_widgets.py
index 9b282cf8c173..050f878cbd84 100644
--- a/products/dashboards/backend/api/test/test_dashboard_widgets.py
+++ b/products/dashboards/backend/api/test/test_dashboard_widgets.py
@@ -1222,6 +1222,28 @@ class TestDashboardWidgetsBatchUpdate(APIBaseTest):
assert updated_tile["widget"]["config"]["limit"] == 5
assert updated_tile["widget"]["config"]["orderBy"] == "last_seen"
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_config_patch_preserves_fields_unknown_to_stale_clients(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(
+ dashboard_id,
+ widget_type="activity_events_list",
+ config={
+ "limit": 5,
+ "properties": [{"type": "person", "key": "email", "operator": "icontains", "value": "@posthog.com"}],
+ },
+ )
+ tile = dashboard_json["tiles"][0]
+
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "config": {"limit": 10}}])
+
+ assert response.status_code == status.HTTP_200_OK
+ updated_config = response.json()["tiles"][0]["widget"]["config"]
+ assert updated_config["limit"] == 10
+ assert updated_config["properties"] == [
+ {"type": "person", "key": "email", "operator": "icontains", "value": "@posthog.com"}
+ ]
+
@override_settings(IN_UNIT_TESTING=True)
def test_sets_session_replay_saved_filter_id(self) -> None:
dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
diff --git a/products/dashboards/backend/api/test/test_run_widgets.py b/products/dashboards/backend/api/test/test_run_widgets.py
index d1b394f84edc..5945e8b19867 100644
--- a/products/dashboards/backend/api/test/test_run_widgets.py
+++ b/products/dashboards/backend/api/test/test_run_widgets.py
@@ -29,6 +29,8 @@ from products.dashboards.backend.api import widget_openapi_serializers as widget
from products.dashboards.backend.constants import (
ACTIVITY_EVENTS_DEFAULT_LIMIT,
ACTIVITY_EVENTS_MAX_LIMIT,
+ ACTIVITY_EVENTS_MAX_PROPERTY_FILTER_VALUES,
+ ACTIVITY_EVENTS_MAX_PROPERTY_FILTERS,
DEFAULT_WIDGET_LIST_LIMIT,
LOGS_LIST_DEFAULT_LIMIT,
LOGS_LIST_MAX_LIMIT,
@@ -146,6 +148,56 @@ class TestWidgetRegistry(APIBaseTest):
with self.assertRaises(Exception):
validate_widget_config(ACTIVITY_EVENTS_LIST_WIDGET_TYPE, {"limit": ACTIVITY_EVENTS_MAX_LIMIT + 1})
+ @parameterized.expand(
+ [
+ (
+ "missing_key",
+ {"properties": [{"type": "person", "operator": "icontains", "value": "@posthog.com"}]},
+ ),
+ (
+ "unknown_type",
+ {"properties": [{"type": "unknown", "key": "email", "operator": "exact", "value": "[email protected]"}]},
+ ),
+ (
+ "unsupported_operator",
+ {"properties": [{"type": "person", "key": "email", "operator": "flag_evaluates_to", "value": True}]},
+ ),
+ (
+ "in_requires_list",
+ {"properties": [{"type": "event", "key": "$browser", "operator": "in", "value": "Chrome"}]},
+ ),
+ (
+ "between_requires_pair",
+ {"properties": [{"type": "event", "key": "score", "operator": "between", "value": [1]}]},
+ ),
+ (
+ "too_many_filters",
+ {
+ "properties": [{"type": "event", "key": "$browser", "operator": "exact", "value": "Chrome"}]
+ * (ACTIVITY_EVENTS_MAX_PROPERTY_FILTERS + 1)
+ },
+ ),
+ (
+ "too_many_values",
+ {
+ "properties": [
+ {
+ "type": "event",
+ "key": "$browser",
+ "operator": "in",
+ "value": ["Chrome"] * (ACTIVITY_EVENTS_MAX_PROPERTY_FILTER_VALUES + 1),
+ }
+ ]
+ },
+ ),
+ ]
+ )
+ def test_validate_activity_events_list_config_rejects_invalid_property_filters(
+ self, _label: str, config: dict[str, object]
+ ) -> None:
+ with self.assertRaises(Exception):
+ validate_widget_config(ACTIVITY_EVENTS_LIST_WIDGET_TYPE, config)
+
@parameterized.expand(
[
("activity_events", ACTIVITY_EVENTS_LIST_WIDGET_TYPE),
@@ -539,7 +591,7 @@ class TestDashboardRunWidgets(APIBaseTest):
self.assertEqual(query.limit, 12)
@patch("products.dashboards.backend.widgets.activity_events_list.EventsQueryRunner")
- def test_activity_events_widget_applies_date_range_and_widget_filters(self, mock_runner_cls: MagicMock) -> None:
+ def test_activity_events_widget_applies_date_range_and_property_filters(self, mock_runner_cls: MagicMock) -> None:
mock_runner_cls.return_value.calculate.return_value = MagicMock(
model_dump=lambda mode="json": {"results": [], "hasMore": False}
)
@@ -549,6 +601,14 @@ class TestDashboardRunWidgets(APIBaseTest):
{
"limit": 5,
"dateRange": {"date_from": "-7d"},
+ "properties": [
+ {
+ "type": "person",
+ "key": "email",
+ "operator": "icontains",
+ "value": "@posthog.com",
+ }
+ ],
"widgetFilters": {
"filter-1": {
"filterId": "filter-1",
@@ -565,9 +625,32 @@ class TestDashboardRunWidgets(APIBaseTest):
query = mock_runner_cls.call_args.kwargs["query"]
self.assertEqual(query.after, "-7d")
assert query.properties is not None
- self.assertEqual(len(query.properties), 1)
- self.assertEqual(query.properties[0].key, "$current_url")
- self.assertEqual(query.properties[0].value, ["/checkout"])
+ self.assertEqual(len(query.properties), 2)
+ self.assertEqual(query.properties[0].key, "email")
+ self.assertEqual(query.properties[0].value, "@posthog.com")
+ self.assertEqual(query.properties[1].key, "$current_url")
+ self.assertEqual(query.properties[1].value, ["/checkout"])
+
+ @parameterized.expand([("event", "$current_url"), ("person", "email")])
+ @patch("products.dashboards.backend.widgets.activity_events_list.restricted_property_names")
+ @patch("products.dashboards.backend.widgets.activity_events_list.EventsQueryRunner")
+ def test_activity_events_widget_rejects_restricted_property_filters(
+ self,
+ property_type: str,
+ property_key: str,
+ mock_runner_cls: MagicMock,
+ mock_restricted_property_names: MagicMock,
+ ) -> None:
+ mock_restricted_property_names.return_value = {property_key}
+
+ with self.assertRaisesMessage(Exception, "restricted property"):
+ run_activity_events_list_widget(
+ self.team,
+ {"properties": [{"type": property_type, "key": property_key, "operator": "exact", "value": "secret"}]},
+ user=self.user,
+ )
+
+ mock_runner_cls.assert_not_called()
@parameterized.expand(
[
diff --git a/products/dashboards/backend/constants.py b/products/dashboards/backend/constants.py
index 70b42c50f260..b7cca2103988 100644
--- a/products/dashboards/backend/constants.py
+++ b/products/dashboards/backend/constants.py
@@ -10,6 +10,11 @@ DEFAULT_WIDGET_LIST_LIMIT = 10
# Activity events list allows a larger page than other list widgets (lightweight rows).
ACTIVITY_EVENTS_MAX_LIMIT = 50
ACTIVITY_EVENTS_DEFAULT_LIMIT = 25
+ACTIVITY_EVENTS_MAX_PROPERTY_FILTERS = 20
+ACTIVITY_EVENTS_MAX_PROPERTY_FILTER_VALUES = 100
+ACTIVITY_EVENTS_MAX_PROPERTY_KEY_LENGTH = 400
+ACTIVITY_EVENTS_MAX_PROPERTY_LABEL_LENGTH = 400
+ACTIVITY_EVENTS_MAX_PROPERTY_VALUE_LENGTH = 4000
# Logs list allows the largest page — log rows are cheap and users scan many at once.
LOGS_LIST_MAX_LIMIT = 100
diff --git a/products/dashboards/backend/widget_specs/configs.py b/products/dashboards/backend/widget_specs/configs.py
index 4dce90b53331..5c3c5469ed23 100644
--- a/products/dashboards/backend/widget_specs/configs.py
+++ b/products/dashboards/backend/widget_specs/configs.py
@@ -1,11 +1,18 @@
from __future__ import annotations
-from typing import Literal
+from typing import Annotated, Literal, Self
-from pydantic import BaseModel, ConfigDict, Field, field_validator
+from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
+
+from posthog.schema import PropertyOperator
from products.dashboards.backend.constants import (
ACTIVITY_EVENTS_DEFAULT_LIMIT,
+ ACTIVITY_EVENTS_MAX_PROPERTY_FILTER_VALUES,
+ ACTIVITY_EVENTS_MAX_PROPERTY_FILTERS,
+ ACTIVITY_EVENTS_MAX_PROPERTY_KEY_LENGTH,
+ ACTIVITY_EVENTS_MAX_PROPERTY_LABEL_LENGTH,
+ ACTIVITY_EVENTS_MAX_PROPERTY_VALUE_LENGTH,
DEFAULT_WIDGET_LIST_LIMIT,
LOGS_LIST_DEFAULT_LIMIT,
)
@@ -27,6 +34,18 @@ EXPERIMENT_RESULTS_WIDGET_TYPE = "experiment_results"
SURVEY_RESULTS_WIDGET_TYPE = "survey_results"
LOGS_LIST_WIDGET_TYPE = "logs_list"
+ActivityEventsPropertyKey = Annotated[
+ str,
+ Field(min_length=1, max_length=ACTIVITY_EVENTS_MAX_PROPERTY_KEY_LENGTH),
+]
+ActivityEventsPropertyLabel = Annotated[str, Field(max_length=ACTIVITY_EVENTS_MAX_PROPERTY_LABEL_LENGTH)]
+ActivityEventsPropertyStringValue = Annotated[str, Field(max_length=ACTIVITY_EVENTS_MAX_PROPERTY_VALUE_LENGTH)]
+ActivityEventsPropertyScalar = ActivityEventsPropertyStringValue | float | bool
+ActivityEventsPropertyValues = Annotated[
+ list[ActivityEventsPropertyScalar],
+ Field(max_length=ACTIVITY_EVENTS_MAX_PROPERTY_FILTER_VALUES),
+]
+
ErrorTrackingOrderBy = Literal["last_seen", "first_seen", "occurrences", "users", "sessions"]
ErrorTrackingWidgetStatus = Literal["archived", "active", "resolved", "pending_release", "suppressed", "all"]
SessionReplayOrderBy = Literal[
@@ -49,6 +68,36 @@ class WidgetAssigneeFilter(BaseModel):
type: WidgetAssigneeType
+class ActivityEventsPropertyFilter(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ key: ActivityEventsPropertyKey
+ label: ActivityEventsPropertyLabel | None = None
+ operator: PropertyOperator
+ type: Literal["event", "person"]
+ value: ActivityEventsPropertyValues | ActivityEventsPropertyScalar | None = None
+
+ @model_validator(mode="after")
+ def validate_operator_value(self) -> Self:
+ if self.operator == PropertyOperator.FLAG_EVALUATES_TO:
+ raise ValueError("flag_evaluates_to is only valid for feature flag filters.")
+ if self.operator in {PropertyOperator.IN_, PropertyOperator.NOT_IN} and not isinstance(self.value, list):
+ raise ValueError(f"{self.operator.value} requires a list of values.")
+ if self.operator in {PropertyOperator.BETWEEN, PropertyOperator.NOT_BETWEEN} and (
+ not isinstance(self.value, list) or len(self.value) != 2
+ ):
+ raise ValueError(f"{self.operator.value} requires exactly two values.")
+ if self.operator in {
+ PropertyOperator.IS_DATE_EXACT,
+ PropertyOperator.IS_DATE_BEFORE,
+ PropertyOperator.IS_DATE_AFTER,
+ PropertyOperator.REGEX,
+ PropertyOperator.NOT_REGEX,
+ } and not isinstance(self.value, str):
+ raise ValueError(f"{self.operator.value} requires a string value.")
+ return self
+
+
class ErrorTrackingListWidgetConfig(WidgetListConfigBase):
limit: WidgetLimit = Field(default=DEFAULT_WIDGET_LIST_LIMIT, description="Maximum number of issues to return.")
orderBy: ErrorTrackingOrderBy = Field(default="occurrences", description="Issue ranking column.")
@@ -100,6 +149,11 @@ class ActivityEventsListWidgetConfig(WidgetListConfigBase):
min_length=1,
description="Limit the feed to a single event name. Omit or null for all events.",
)
+ properties: list[ActivityEventsPropertyFilter] | None = Field(
+ default=None,
+ max_length=ACTIVITY_EVENTS_MAX_PROPERTY_FILTERS,
+ description="Event and person property filters, matching Activity > Explore events.",
+ )
class ExperimentsListWidgetConfig(BaseModel):
diff --git a/products/dashboards/backend/widget_specs/registry.py b/products/dashboards/backend/widget_specs/registry.py
index 198830f49f76..a5505a1d53a6 100644
--- a/products/dashboards/backend/widget_specs/registry.py
+++ b/products/dashboards/backend/widget_specs/registry.py
@@ -111,7 +111,7 @@ def _load_widget_specs() -> dict[str, WidgetSpec]:
product_access_denied_message=None,
availability_requirements=(),
form_fields=("limit", "dateRange", "filterTestAccounts"),
- filter_fields=("eventName",),
+ filter_fields=("eventName", "properties"),
),
ERROR_TRACKING_LIST_WIDGET_TYPE: WidgetSpec(
widget_type=ERROR_TRACKING_LIST_WIDGET_TYPE,
diff --git a/products/dashboards/backend/widgets/activity_events_list.py b/products/dashboards/backend/widgets/activity_events_list.py
index 78317f5a8dcf..d4d2305dad5e 100644
--- a/products/dashboards/backend/widgets/activity_events_list.py
+++ b/products/dashboards/backend/widgets/activity_events_list.py
@@ -2,12 +2,16 @@ from __future__ import annotations
from typing import Any
+from rest_framework.exceptions import ValidationError
+
from posthog.schema import EventsQuery
from posthog.clickhouse.query_tagging import Feature, Product, tags_context
from posthog.hogql_queries.events_query_runner import EventsQueryRunner
+from posthog.models import PropertyDefinition
from posthog.models.team import Team
from posthog.models.user import User
+from posthog.taxonomy.property_access import restricted_property_names
from products.dashboards.backend.constants import ACTIVITY_EVENTS_MAX_LIMIT
from products.dashboards.backend.widget_specs.configs import ACTIVITY_EVENTS_LIST_WIDGET_TYPE
@@ -33,9 +37,36 @@ ACTIVITY_EVENTS_WIDGET_SELECT = [
ACTIVITY_EVENTS_WIDGET_RESULT_KEYS = ["uuid", "event", "person", "url", "lib", "timestamp"]
+def _validate_property_filter_access(
+ team: Team,
+ user: User | None,
+ property_filters: list[dict[str, Any]],
+) -> None:
+ restricted_event_properties = restricted_property_names(team, user, PropertyDefinition.Type.EVENT)
+ restricted_person_properties = restricted_property_names(team, user, PropertyDefinition.Type.PERSON)
+
+ for property_filter in property_filters:
+ property_type = property_filter.get("type")
+ property_key = property_filter.get("key")
+ if property_type == "event" and property_key in restricted_event_properties:
+ raise ValidationError("Filter references a restricted property")
+ if property_type == "person" and property_key in restricted_person_properties:
+ raise ValidationError("Filter references a restricted property")
+
+
+def _build_activity_events_property_filters(config: ValidatedActivityEventsListWidgetConfig) -> list[dict[str, Any]]:
+ configured_property_filters = config.get("properties")
+ widget_property_filters = build_event_property_filters_from_widget_filters(config.get("widgetFilters"))
+ return [
+ *(configured_property_filters if isinstance(configured_property_filters, list) else []),
+ *(widget_property_filters or []),
+ ]
+
+
def _build_activity_events_query(
team: Team,
config: ValidatedActivityEventsListWidgetConfig,
+ property_filters: list[dict[str, Any]],
limit: int,
) -> EventsQuery:
date_range_raw = config.get("dateRange")
@@ -45,8 +76,6 @@ def _build_activity_events_query(
if isinstance(date_from_value, str):
after = date_from_value
- property_filters = build_event_property_filters_from_widget_filters(config.get("widgetFilters"))
-
event_name = config.get("eventName")
event = event_name if isinstance(event_name, str) and event_name else None
@@ -66,11 +95,12 @@ def _build_activity_events_query(
def _run_activity_events_query(
team: Team,
config: ValidatedActivityEventsListWidgetConfig,
+ property_filters: list[dict[str, Any]],
user: User | None,
*,
limit: int,
) -> dict[str, Any]:
- query = _build_activity_events_query(team, config, limit)
+ query = _build_activity_events_query(team, config, property_filters, limit)
with tags_context(product=Product.PRODUCT_ANALYTICS, feature=Feature.QUERY, team_id=team.pk):
return EventsQueryRunner(team=team, query=query, user=user).calculate().model_dump(mode="json")
@@ -87,9 +117,11 @@ def run_activity_events_list_widget(
include_total_count: bool = True,
) -> dict[str, Any]:
typed_config = validate_widget_config(ACTIVITY_EVENTS_LIST_WIDGET_TYPE, config)
+ property_filters = _build_activity_events_property_filters(typed_config)
+ _validate_property_filter_access(team, user, property_filters)
def fetch_page(page_limit: int) -> ListWidgetPage:
- data = _run_activity_events_query(team, typed_config, user, limit=page_limit)
+ data = _run_activity_events_query(team, typed_config, property_filters, user, limit=page_limit)
raw_results = data.get("results")
return ListWidgetPage(
results=raw_results if isinstance(raw_results, list) else [],
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 98326f8b583a..aef9951785a2 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -503,6 +503,26 @@ export interface WidgetFilterEntryApi {
value?: string | string[] | null
}
+export type ActivityEventsPropertyFilterApiType =
+ (typeof ActivityEventsPropertyFilterApiType)[keyof typeof ActivityEventsPropertyFilterApiType]
+
+export const ActivityEventsPropertyFilterApiType = {
+ Event: 'event',
+ Person: 'person',
+} as const
+
+export interface ActivityEventsPropertyFilterApi {
+ /**
+ * @minLength 1
+ * @maxLength 400
+ */
+ key: string
+ label?: string | null
+ operator: PropertyOperatorApi
+ type: ActivityEventsPropertyFilterApiType
+ value?: (string | number | boolean)[] | string | number | boolean | null
+}
+
export type ActivityEventsListWidgetConfigApiWidgetFilters = { [key: string]: WidgetFilterEntryApi } | null
export interface ActivityEventsListWidgetConfigApi {
@@ -517,6 +537,8 @@ export interface ActivityEventsListWidgetConfigApi {
limit?: number
/** Limit the feed to a single event name. Omit or null for all events. */
eventName?: string | null
+ /** Event and person property filters, matching Activity > Explore events. */
+ properties?: ActivityEventsPropertyFilterApi[] | null
}
/**
diff --git a/products/dashboards/frontend/generated/api.zod.ts b/products/dashboards/frontend/generated/api.zod.ts
index cfc483b89fca..3ca3d3e54e48 100644
--- a/products/dashboards/frontend/generated/api.zod.ts
+++ b/products/dashboards/frontend/generated/api.zod.ts
@@ -219,6 +219,18 @@ export const dashboardsPartialUpdateBodyNameMax = 400
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOneLimitDefault = 25
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOneLimitMax = 50
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemKeyMax = 400
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemLabelOneMax = 400
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneItemOneMax = 4000
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneMax = 100
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueTwoMax = 4000
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneMax = 20
+
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneTwoLimitDefault = 10
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneTwoLimitMax = 25
@@ -411,6 +423,102 @@ export const DashboardsPartialUpdateBody = /* @__PURE__ */ zod
.describe(
'Limit the feed to a single event name. Omit or null for all events.'
),
+ properties: zod
+ .union([
+ zod
+ .array(
+ zod.object({
+ key: zod
+ .string()
+ .min(1)
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemKeyMax
+ ),
+ label: zod
+ .union([
+ zod
+ .string()
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemLabelOneMax
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ type: zod.enum(['event', 'person']),
+ value: zod
+ .union([
+ zod
+ .array(
+ zod.union([
+ zod
+ .string()
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneItemOneMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ ])
+ )
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneMax
+ ),
+ zod
+ .string()
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueTwoMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ zod.null(),
+ ])
+ .optional(),
+ })
+ )
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneMax
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'Event and person property filters, matching Activity > Explore events.'
+ ),
}),
zod.object({
dateRange: zod
@@ -993,6 +1101,18 @@ export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneNameMax = 400
export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOneLimitDefault = 25
export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOneLimitMax = 50
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax = 400
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax = 400
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax = 4000
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax = 100
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax = 4000
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneMax = 20
+
export const dashboardsWidgetsBatchCreateBodyWidgetsItemTwoNameMax = 400
export const dashboardsWidgetsBatchCreateBodyWidgetsItemTwoConfigOneLimitDefault = 10
@@ -1184,6 +1304,100 @@ export const DashboardsWidgetsBatchCreateBody = /* @__PURE__ */ zod
.union([zod.string().min(1), zod.null()])
.optional()
.describe('Limit the feed to a single event name. Omit or null for all events.'),
+ properties: zod
+ .union([
+ zod
+ .array(
+ zod.object({
+ key: zod
+ .string()
+ .min(1)
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax
+ ),
+ label: zod
+ .union([
+ zod
+ .string()
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ type: zod.enum(['event', 'person']),
+ value: zod
+ .union([
+ zod
+ .array(
+ zod.union([
+ zod
+ .string()
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ ])
+ )
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax
+ ),
+ zod
+ .string()
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ zod.null(),
+ ])
+ .optional(),
+ })
+ )
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneMax
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Event and person property filters, matching Activity > Explore events.'),
})
.describe('Configuration for the recent events widget.'),
}),
@@ -1927,6 +2141,18 @@ export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneNameMax = 400
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitDefault = 25
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitMax = 50
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax = 4000
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax = 100
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax = 4000
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneMax = 20
+
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoNameMax = 400
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitDefault = 10
@@ -2076,6 +2302,100 @@ export const DashboardsUpdateWidgetsBatchBody = /* @__PURE__ */ zod
.union([zod.string().min(1), zod.null()])
.optional()
.describe('Limit the feed to a single event name. Omit or null for all events.'),
+ properties: zod
+ .union([
+ zod
+ .array(
+ zod.object({
+ key: zod
+ .string()
+ .min(1)
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax
+ ),
+ label: zod
+ .union([
+ zod
+ .string()
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ type: zod.enum(['event', 'person']),
+ value: zod
+ .union([
+ zod
+ .array(
+ zod.union([
+ zod
+ .string()
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ ])
+ )
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax
+ ),
+ zod
+ .string()
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ zod.null(),
+ ])
+ .optional(),
+ })
+ )
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneMax
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Event and person property filters, matching Activity > Explore events.'),
})
.optional()
.describe('New configuration for the recent events widget. Omit to leave unchanged.'),
diff --git a/products/dashboards/frontend/generated/widget-config-property-keys.json b/products/dashboards/frontend/generated/widget-config-property-keys.json
index 2fd09f07a2c5..8abbe99e49b7 100644
--- a/products/dashboards/frontend/generated/widget-config-property-keys.json
+++ b/products/dashboards/frontend/generated/widget-config-property-keys.json
@@ -1,6 +1,13 @@
{
"configPropertyKeys": {
- "activity_events_list": ["dateRange", "eventName", "filterTestAccounts", "limit", "widgetFilters"],
+ "activity_events_list": [
+ "dateRange",
+ "eventName",
+ "filterTestAccounts",
+ "limit",
+ "properties",
+ "widgetFilters"
+ ],
"error_tracking_list": [
"assignee",
"dateRange",
@@ -104,6 +111,60 @@
},
"eventName": {
"$type": "string"
+ },
+ "properties": {
+ "$array": {
+ "key": {
+ "$type": "string"
+ },
+ "label": {
+ "$type": "string"
+ },
+ "operator": {
+ "$enum": [
+ "between",
+ "exact",
+ "flag_evaluates_to",
+ "gt",
+ "gte",
+ "icontains",
+ "icontains_multi",
+ "in",
+ "is_cleaned_path_exact",
+ "is_date_after",
+ "is_date_before",
+ "is_date_exact",
+ "is_not",
+ "is_not_set",
+ "is_set",
+ "lt",
+ "lte",
+ "max",
+ "min",
+ "not_between",
+ "not_icontains",
+ "not_icontains_multi",
+ "not_in",
+ "not_regex",
+ "regex",
+ "semver_caret",
+ "semver_eq",
+ "semver_gt",
+ "semver_gte",
+ "semver_lt",
+ "semver_lte",
+ "semver_neq",
+ "semver_tilde",
+ "semver_wildcard"
+ ]
+ },
+ "type": {
+ "$enum": ["event", "person"]
+ },
+ "value": {
+ "$types": ["string"]
+ }
+ }
}
},
"error_tracking_list": {
diff --git a/products/dashboards/frontend/generated/widget-config-schemas/activityEventsListWidgetConfig.zod.ts b/products/dashboards/frontend/generated/widget-config-schemas/activityEventsListWidgetConfig.zod.ts
index f657a765c1d7..9046f1bd070e 100644
--- a/products/dashboards/frontend/generated/widget-config-schemas/activityEventsListWidgetConfig.zod.ts
+++ b/products/dashboards/frontend/generated/widget-config-schemas/activityEventsListWidgetConfig.zod.ts
@@ -6,12 +6,15 @@
*/
import { z as zod } from 'zod'
+import { ActivityEventsPropertyFilter } from './activityEventsPropertyFilter.zod'
import { WidgetDateRange } from './widgetDateRange.zod'
import { WidgetFilterEntry } from './widgetFilterEntry.zod'
export const activityEventsListWidgetConfigLimitDefault = 25
export const activityEventsListWidgetConfigLimitMax = 50
+export const activityEventsListWidgetConfigPropertiesOneMax = 20
+
export const ActivityEventsListWidgetConfig = /* @__PURE__ */ zod.object({
dateRange: zod.union([WidgetDateRange, zod.null()]).optional(),
filterTestAccounts: zod.union([zod.boolean(), zod.null()]).optional(),
@@ -26,6 +29,13 @@ export const ActivityEventsListWidgetConfig = /* @__PURE__ */ zod.object({
.union([zod.string().min(1), zod.null()])
.optional()
.describe('Limit the feed to a single event name. Omit or null for all events.'),
+ properties: zod
+ .union([
+ zod.array(ActivityEventsPropertyFilter).max(activityEventsListWidgetConfigPropertiesOneMax),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Event and person property filters, matching Activity > Explore events.'),
})
export type ActivityEventsListWidgetConfig = zod.input<typeof ActivityEventsListWidgetConfig>
diff --git a/products/dashboards/frontend/generated/widget-config-schemas/activityEventsPropertyFilter.zod.ts b/products/dashboards/frontend/generated/widget-config-schemas/activityEventsPropertyFilter.zod.ts
new file mode 100644
index 000000000000..cc334e9600cd
--- /dev/null
+++ b/products/dashboards/frontend/generated/widget-config-schemas/activityEventsPropertyFilter.zod.ts
@@ -0,0 +1,46 @@
+/**
+ * Generated by orval v8.14.0 🍺
+ * Do not edit manually.
+ * PostHog API - 1 ops
+ * OpenAPI spec version: 1.0.0
+ */
+import { z as zod } from 'zod'
+
+import { PropertyOperator } from './propertyOperator.zod'
+
+export const activityEventsPropertyFilterKeyMax = 400
+
+export const activityEventsPropertyFilterLabelOneMax = 400
+
+export const activityEventsPropertyFilterValueOneItemOneMax = 4000
+
+export const activityEventsPropertyFilterValueOneMax = 100
+
+export const activityEventsPropertyFilterValueTwoMax = 4000
+
+export const ActivityEventsPropertyFilter = /* @__PURE__ */ zod.object({
+ key: zod.string().min(1).max(activityEventsPropertyFilterKeyMax),
+ label: zod.union([zod.string().max(activityEventsPropertyFilterLabelOneMax), zod.null()]).optional(),
+ operator: PropertyOperator,
+ type: zod.enum(['event', 'person']),
+ value: zod
+ .union([
+ zod
+ .array(
+ zod.union([
+ zod.string().max(activityEventsPropertyFilterValueOneItemOneMax),
+ zod.number(),
+ zod.boolean(),
+ ])
+ )
+ .max(activityEventsPropertyFilterValueOneMax),
+ zod.string().max(activityEventsPropertyFilterValueTwoMax),
+ zod.number(),
+ zod.boolean(),
+ zod.null(),
+ ])
+ .optional(),
+})
+
+export type ActivityEventsPropertyFilter = zod.input<typeof ActivityEventsPropertyFilter>
+export type ActivityEventsPropertyFilterOutput = zod.output<typeof ActivityEventsPropertyFilter>
diff --git a/products/dashboards/frontend/widgets/activity/ActivityEventsWidgetTileFilters.test.tsx b/products/dashboards/frontend/widgets/activity/ActivityEventsWidgetTileFilters.test.tsx
new file mode 100644
index 000000000000..4c91f0ae2ed3
--- /dev/null
+++ b/products/dashboards/frontend/widgets/activity/ActivityEventsWidgetTileFilters.test.tsx
@@ -0,0 +1,94 @@
+import '@testing-library/jest-dom'
+
+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
+
+import type { EventsQuery } from '~/queries/schema/schema-general'
+
+import { WIDGET_TILE_REFRESH_DEBOUNCE_MS } from '../constants'
+import { ActivityEventsWidgetTileFilters } from './ActivityEventsWidgetTileFilters'
+
+jest.mock('products/actions/frontend/components/EventName', () => ({
+ EventName: (): JSX.Element => <div>Event name filter</div>,
+}))
+
+jest.mock('~/queries/nodes/EventsNode/EventPropertyFilters', () => ({
+ EventPropertyFilters: ({ query, setQuery }: { query: EventsQuery; setQuery: (query: EventsQuery) => void }) => (
+ <>
+ <div>{`Property filters for ${query.event}`}</div>
+ <button
+ type="button"
+ onClick={() =>
+ setQuery({
+ ...query,
+ properties: [
+ { type: 'person', key: 'email', operator: 'icontains', value: '@posthog.com' },
+ ] as EventsQuery['properties'],
+ })
+ }
+ >
+ Add property filter
+ </button>
+ <button type="button" onClick={() => setQuery({ ...query, properties: [] })}>
+ Clear property filters
+ </button>
+ </>
+ ),
+}))
+
+describe('ActivityEventsWidgetTileFilters', () => {
+ beforeEach(() => {
+ jest.useFakeTimers()
+ })
+
+ afterEach(() => {
+ cleanup()
+ jest.useRealTimers()
+ })
+
+ it('persists added and cleared property filters without dropping existing config', async () => {
+ const onUpdateConfig = jest.fn().mockResolvedValue(undefined)
+
+ render(
+ <ActivityEventsWidgetTileFilters
+ tileId={1}
+ config={{ limit: 10, dateRange: { date_from: '-7d' }, eventName: '$pageview' }}
+ onUpdateConfig={onUpdateConfig}
+ />
+ )
+
+ expect(screen.getByText('Property filters for $pageview')).toBeInTheDocument()
+
+ fireEvent.click(screen.getByText('Add property filter'))
+ await act(async () => {
+ jest.advanceTimersByTime(WIDGET_TILE_REFRESH_DEBOUNCE_MS)
+ await Promise.resolve()
+ })
+
+ expect(onUpdateConfig).toHaveBeenLastCalledWith({
+ limit: 10,
+ dateRange: { date_from: '-7d' },
+ eventName: '$pageview',
+ properties: [
+ {
+ type: 'person',
+ key: 'email',
+ operator: 'icontains',
+ value: '@posthog.com',
+ },
+ ],
+ })
+
+ fireEvent.click(screen.getByText('Clear property filters'))
+ await act(async () => {
+ jest.advanceTimersByTime(WIDGET_TILE_REFRESH_DEBOUNCE_MS)
+ await Promise.resolve()
+ })
+
+ expect(onUpdateConfig).toHaveBeenLastCalledWith({
+ limit: 10,
+ dateRange: { date_from: '-7d' },
+ eventName: '$pageview',
+ properties: [],
+ })
+ })
+})
diff --git a/products/dashboards/frontend/widgets/activity/ActivityEventsWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/activity/ActivityEventsWidgetTileFilters.tsx
index 4a65c131a39a..b40825f616fa 100644
--- a/products/dashboards/frontend/widgets/activity/ActivityEventsWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/activity/ActivityEventsWidgetTileFilters.tsx
@@ -1,7 +1,10 @@
-import { useRef } from 'react'
-
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
+import { EventPropertyFilters } from '~/queries/nodes/EventsNode/EventPropertyFilters'
+import { NodeKind, type EventsQuery } from '~/queries/schema/schema-general'
+import type { AnyPropertyFilter } from '~/types'
+
import { EventName } from 'products/actions/frontend/components/EventName'
import { WIDGET_DATE_RANGE_SELECT_OPTIONS, type WidgetDateFromValue } from '../../widget_types/widgetConfigShared'
@@ -27,35 +30,53 @@ export function ActivityEventsWidgetTileFilters({
const parsed = parseActivityEventsWidgetConfig(config)
const dateFrom = (parsed.dateRange?.date_from ?? '-24h') as WidgetDateFromValue
const eventName = parsed.eventName ?? null
+ const properties = (parsed.properties ?? []) as AnyPropertyFilter[]
- const configRef = useRef(config)
- configRef.current = config
- const { persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig)
+ const { getLatestConfig, persistConfigDebounced, persistConfigNow } = useWidgetTileConfigPersist(
+ onUpdateConfig,
+ config
+ )
const controlDisabledReason = disabledReason
const canUpdate = !!onUpdateConfig && !controlDisabledReason
const applyDateFrom = async (value: WidgetDateFromValue): Promise<void> => {
- const nextConfig = patchActivityEventsWidgetFilterFields(configRef.current, { dateFrom: value })
- configRef.current = nextConfig
+ const nextConfig = patchActivityEventsWidgetFilterFields(getLatestConfig(), { dateFrom: value })
await persistConfigNow(nextConfig)
}
const applyEventName = async (value: string | null): Promise<void> => {
- const nextConfig = patchActivityEventsWidgetFilterFields(configRef.current, { eventName: value })
- configRef.current = nextConfig
+ const nextConfig = patchActivityEventsWidgetFilterFields(getLatestConfig(), { eventName: value })
await persistConfigNow(nextConfig)
}
+ const applyProperties = (value: AnyPropertyFilter[]): void => {
+ const nextConfig = patchActivityEventsWidgetFilterFields(getLatestConfig(), { properties: value })
+ persistConfigDebounced(nextConfig)
+ }
+
if (!onUpdateConfig) {
return (
<WidgetTileFiltersBar dataAttr="activity-events-widget-tile-filters-readonly">
<WidgetDateRangeReadOnlyValue dateFrom={dateFrom} />
{eventName ? <WidgetTileFilterReadOnlyLabel name="Event" value={eventName} /> : null}
+ {properties.length > 0 ? (
+ <WidgetTileFilterReadOnlyLabel
+ name="Properties"
+ value={`${properties.length} ${properties.length === 1 ? 'filter' : 'filters'}`}
+ />
+ ) : null}
</WidgetTileFiltersBar>
)
}
+ const propertyFilterQuery: EventsQuery = {
+ kind: NodeKind.EventsQuery,
+ select: [],
+ event: eventName ?? undefined,
+ properties,
+ }
+
return (
<WidgetTileFiltersBar dataAttr="activity-events-widget-tile-filters">
<LemonSelect
@@ -79,6 +100,22 @@ export function ActivityEventsWidgetTileFilters({
void applyEventName(value)
}}
/>
+ {canUpdate && (
+ <EventPropertyFilters
+ query={propertyFilterQuery}
+ setQuery={(query) => applyProperties(query.properties ?? [])}
+ taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ ]}
+ />
+ )}
+ {!canUpdate && properties.length > 0 && (
+ <WidgetTileFilterReadOnlyLabel
+ name="Properties"
+ value={`${properties.length} ${properties.length === 1 ? 'filter' : 'filters'}`}
+ />
+ )}
</WidgetTileFiltersBar>
)
}
diff --git a/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.test.ts b/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.test.ts
index fe06768a5f4e..d4d419b7c0d5 100644
--- a/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.test.ts
+++ b/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.test.ts
@@ -1,5 +1,7 @@
import { ApiError } from 'lib/api-error'
+import { type AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
+
import { activityEventsWidgetConfigSchema } from '../../generated/widget-configs.zod'
import {
ACTIVITY_EVENTS_WIDGET_FORM_FIELD_NAMES,
@@ -53,12 +55,14 @@ describe('activityEventsWidgetConfigValidation', () => {
const config = activityEventsWidgetConfigSchema.parse({
limit: 15,
dateRange: { date_from: '-24h' },
+ properties: [{ type: 'event', key: '$browser', operator: 'exact', value: 'Chrome' }],
})
const next = patchActivityEventsWidgetFilterFields(config, { dateFrom: '-7d' })
expect(next.dateRange).toEqual({ date_from: '-7d' })
expect(next.limit).toBe(15)
+ expect(next.properties).toEqual([{ type: 'event', key: '$browser', operator: 'exact', value: 'Chrome' }])
})
it('sets and clears the event name without touching the date range', () => {
@@ -71,6 +75,23 @@ describe('activityEventsWidgetConfigValidation', () => {
const cleared = patchActivityEventsWidgetFilterFields(withEvent, { eventName: null })
expect(cleared.eventName).toBeNull()
})
+
+ it('updates property filters without touching the event name', () => {
+ const config = activityEventsWidgetConfigSchema.parse({ eventName: '$pageview' })
+ const properties: AnyPropertyFilter[] = [
+ {
+ type: PropertyFilterType.Person,
+ key: 'email',
+ operator: PropertyOperator.IContains,
+ value: '@',
+ },
+ ]
+
+ const next = patchActivityEventsWidgetFilterFields(config, { properties })
+
+ expect(next.eventName).toBe('$pageview')
+ expect(next.properties).toEqual(properties)
+ })
})
describe('parseActivityEventsWidgetConfigApiError', () => {
diff --git a/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.ts b/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.ts
index d282fb79e47e..c79691d21c94 100644
--- a/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.ts
+++ b/products/dashboards/frontend/widgets/activity/activityEventsWidgetConfigValidation.ts
@@ -2,6 +2,8 @@ import { z } from 'zod'
import { ApiError } from 'lib/api-error'
+import type { AnyPropertyFilter } from '~/types'
+
import {
activityEventsWidgetConfigSchema,
activityEventsWidgetFormSchema,
@@ -37,6 +39,7 @@ export function patchActivityEventsWidgetFilterFields(
patch: {
dateFrom?: WidgetDateFromValue
eventName?: string | null
+ properties?: AnyPropertyFilter[]
}
): ActivityEventsWidgetConfig {
const base = parseActivityEventsWidgetConfig(config)
@@ -46,6 +49,7 @@ export function patchActivityEventsWidgetFilterFields(
dateRange: { date_from: patch.dateFrom ?? base.dateRange?.date_from ?? ACTIVITY_EVENTS_DEFAULT_DATE_FROM },
// `in` (not ??) so an explicit null clears the filter — ?? would fall back to base
eventName: 'eventName' in patch ? patch.eventName : base.eventName,
+ properties: patch.properties ?? base.properties,
})
}
diff --git a/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidgetTileFilters.tsx
index 793394821992..27d7402ecf7f 100644
--- a/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/error_tracking/ErrorTrackingWidgetTileFilters.tsx
@@ -1,6 +1,6 @@
import { deepEqual as equal } from 'fast-equals'
import { useValues } from 'kea'
-import { useMemo, useRef } from 'react'
+import { useMemo } from 'react'
import { quickFiltersLogic } from 'lib/components/QuickFilters/quickFiltersLogic'
import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
@@ -54,26 +54,26 @@ export function ErrorTrackingWidgetTileFilters({
[projectFilterDefinitions, isAllowed]
)
- const configRef = useRef(config)
- configRef.current = config
- const { persistConfigDebounced, persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig)
+ const { getLatestConfig, persistConfigDebounced, persistConfigNow } = useWidgetTileConfigPersist(
+ onUpdateConfig,
+ config
+ )
const controlDisabledReason = disabledReason
const canUpdate = !!onUpdateConfig && !controlDisabledReason
const applyPatch = async (patch: Parameters<typeof patchErrorTrackingWidgetFilterFields>[1]): Promise<void> => {
- const nextConfig = patchErrorTrackingWidgetFilterFields(configRef.current, patch)
- configRef.current = nextConfig
+ const nextConfig = patchErrorTrackingWidgetFilterFields(getLatestConfig(), patch)
await persistConfigNow(nextConfig)
}
const applyWidgetFilters = (nextWidgetFilters: typeof widgetFilters): void => {
- const nextConfig = patchErrorTrackingWidgetFilterFields(configRef.current, { widgetFilters: nextWidgetFilters })
- const current = parseErrorTrackingWidgetConfig(configRef.current)
+ const latestConfig = getLatestConfig()
+ const nextConfig = patchErrorTrackingWidgetFilterFields(latestConfig, { widgetFilters: nextWidgetFilters })
+ const current = parseErrorTrackingWidgetConfig(latestConfig)
if (equal(current.widgetFilters ?? {}, nextWidgetFilters)) {
return
}
- configRef.current = nextConfig
persistConfigDebounced(nextConfig)
}
diff --git a/products/dashboards/frontend/widgets/experiments/ExperimentResultsWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/experiments/ExperimentResultsWidgetTileFilters.tsx
index aef7b7013dc7..0048d907fc40 100644
--- a/products/dashboards/frontend/widgets/experiments/ExperimentResultsWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/experiments/ExperimentResultsWidgetTileFilters.tsx
@@ -1,5 +1,5 @@
import { useActions, useValues } from 'kea'
-import { useEffect, useRef, useState } from 'react'
+import { useEffect, useState } from 'react'
import type { DashboardWidgetTileFiltersProps } from '../registry'
import { useWidgetTileConfigPersist } from '../widgetTileFiltersHooks'
@@ -41,9 +41,7 @@ export function ExperimentResultsWidgetTileFilters({
const parsed = parseExperimentResultsWidgetConfig(config)
const experimentId = parsed.experimentId ?? null
- const configRef = useRef(config)
- configRef.current = config
- const { persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig)
+ const { getLatestConfig, persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig, config)
// Reflect the pick immediately rather than waiting for the persist round-trip to update `config`.
const [optimisticExperimentId, setOptimisticExperimentId] = useState<number | null | undefined>(undefined)
@@ -51,8 +49,7 @@ export function ExperimentResultsWidgetTileFilters({
const applyExperimentId = async (value: number | null): Promise<void> => {
setOptimisticExperimentId(value)
- const nextConfig = patchExperimentResultsWidgetConfig(configRef.current, value)
- configRef.current = nextConfig
+ const nextConfig = patchExperimentResultsWidgetConfig(getLatestConfig(), value)
try {
// persist resolves only after `config` reflects the pick, so clearing here never flickers.
await persistConfigNow(nextConfig)
diff --git a/products/dashboards/frontend/widgets/experiments/ExperimentsListWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/experiments/ExperimentsListWidgetTileFilters.tsx
index e9e32b730740..804de48ebadb 100644
--- a/products/dashboards/frontend/widgets/experiments/ExperimentsListWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/experiments/ExperimentsListWidgetTileFilters.tsx
@@ -1,5 +1,3 @@
-import { useRef } from 'react'
-
import { MemberSelect } from 'lib/components/MemberSelect'
import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
@@ -22,21 +20,17 @@ export function ExperimentsListWidgetTileFilters({
const status = parsed.status ?? 'all'
const createdBy = parsed.createdBy ?? null
- const configRef = useRef(config)
- configRef.current = config
- const { persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig)
+ const { getLatestConfig, persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig, config)
const canUpdate = !!onUpdateConfig && !disabledReason
const applyStatus = async (value: ExperimentsListWidgetStatus): Promise<void> => {
- const nextConfig = patchExperimentsListWidgetConfig(configRef.current, { status: value })
- configRef.current = nextConfig
+ const nextConfig = patchExperimentsListWidgetConfig(getLatestConfig(), { status: value })
await persistConfigNow(nextConfig)
}
const applyCreatedBy = async (userId: number | null): Promise<void> => {
- const nextConfig = patchExperimentsListWidgetConfig(configRef.current, { createdBy: userId })
- configRef.current = nextConfig
+ const nextConfig = patchExperimentsListWidgetConfig(getLatestConfig(), { createdBy: userId })
await persistConfigNow(nextConfig)
}
diff --git a/products/dashboards/frontend/widgets/logs/LogsWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/logs/LogsWidgetTileFilters.tsx
index 401bd35393ef..b8afc8efa549 100644
--- a/products/dashboards/frontend/widgets/logs/LogsWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/logs/LogsWidgetTileFilters.tsx
@@ -1,5 +1,5 @@
import { useActions, useValues } from 'kea'
-import { useEffect, useMemo, useRef } from 'react'
+import { useEffect, useMemo } from 'react'
import { IconExternal } from '@posthog/icons'
@@ -96,9 +96,7 @@ export function LogsWidgetTileFilters({
)
const savedViewLabel = savedViewId ? (savedViewLabelById[savedViewId] ?? savedViewId) : savedViewId
- const configRef = useRef(config)
- configRef.current = config
- const { persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig)
+ const { getLatestConfig, persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig, config)
// Severity and service pickers can't render a disabled state, so when editing is unavailable
// (view-only dashboard, or no edit permission) show the read-only summary instead of dead controls.
@@ -110,8 +108,7 @@ export function LogsWidgetTileFilters({
orderBy?: LogsOrderByValue
savedViewId?: string | null
}): Promise<void> => {
- const nextConfig = patchLogsWidgetFilterFields(configRef.current, patch)
- configRef.current = nextConfig
+ const nextConfig = patchLogsWidgetFilterFields(getLatestConfig(), patch)
await persistConfigNow(nextConfig)
}
diff --git a/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx
index 463658d96dfd..523ea19b9054 100644
--- a/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/session_replay/SessionReplayWidgetTileFilters.tsx
@@ -1,6 +1,6 @@
import { deepEqual as equal } from 'fast-equals'
import { useValues } from 'kea'
-import { useMemo, useRef } from 'react'
+import { useMemo } from 'react'
import { IconExternal } from '@posthog/icons'
@@ -95,16 +95,16 @@ export function SessionReplayWidgetTileFilters({
const savedFilterLabel = savedFilterId ? (savedFilterLabelById[savedFilterId] ?? savedFilterId) : null
const collectionLabel = collectionId ? (collectionLabelById[collectionId] ?? collectionId) : null
- const configRef = useRef(config)
- configRef.current = config
- const { persistConfigDebounced, persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig)
+ const { getLatestConfig, persistConfigDebounced, persistConfigNow } = useWidgetTileConfigPersist(
+ onUpdateConfig,
+ config
+ )
const controlDisabledReason = disabledReason
const canUpdate = !!onUpdateConfig && !controlDisabledReason
const applyDateFrom = async (value: WidgetDateFromValue): Promise<void> => {
- const nextConfig = patchSessionReplayWidgetFilterFields(configRef.current, { dateFrom: value })
- configRef.current = nextConfig
+ const nextConfig = patchSessionReplayWidgetFilterFields(getLatestConfig(), { dateFrom: value })
await persistConfigNow(nextConfig)
}
@@ -114,10 +114,9 @@ export function SessionReplayWidgetTileFilters({
window.open(urls.replay(ReplayTabs.Playlists), '_blank', 'noopener,noreferrer')
return
}
- const nextConfig = patchSessionReplayWidgetFilterFields(configRef.current, {
+ const nextConfig = patchSessionReplayWidgetFilterFields(getLatestConfig(), {
collectionId: value && value !== NONE_VALUE ? value : null,
})
- configRef.current = nextConfig
await persistConfigNow(nextConfig)
}
@@ -127,20 +126,19 @@ export function SessionReplayWidgetTileFilters({
window.open(urls.replay(), '_blank', 'noopener,noreferrer')
return
}
- const nextConfig = patchSessionReplayWidgetFilterFields(configRef.current, {
+ const nextConfig = patchSessionReplayWidgetFilterFields(getLatestConfig(), {
savedFilterId: value && value !== NONE_VALUE ? value : null,
})
- configRef.current = nextConfig
await persistConfigNow(nextConfig)
}
const applyWidgetFilters = (nextWidgetFilters: typeof widgetFilters): void => {
- const nextConfig = patchSessionReplayWidgetFilterFields(configRef.current, { widgetFilters: nextWidgetFilters })
- const current = parseSessionReplayWidgetConfig(configRef.current)
+ const latestConfig = getLatestConfig()
+ const nextConfig = patchSessionReplayWidgetFilterFields(latestConfig, { widgetFilters: nextWidgetFilters })
+ const current = parseSessionReplayWidgetConfig(latestConfig)
if (equal(current.widgetFilters ?? {}, nextWidgetFilters)) {
return
}
- configRef.current = nextConfig
persistConfigDebounced(nextConfig)
}
diff --git a/products/dashboards/frontend/widgets/surveys/SurveyResultsWidgetTileFilters.tsx b/products/dashboards/frontend/widgets/surveys/SurveyResultsWidgetTileFilters.tsx
index dd68066fc411..70c8b7dba464 100644
--- a/products/dashboards/frontend/widgets/surveys/SurveyResultsWidgetTileFilters.tsx
+++ b/products/dashboards/frontend/widgets/surveys/SurveyResultsWidgetTileFilters.tsx
@@ -1,6 +1,6 @@
import { useValues } from 'kea'
import posthog from 'posthog-js'
-import { useRef, useState } from 'react'
+import { useState } from 'react'
import type { DashboardWidgetTileFiltersProps } from '../registry'
import { useWidgetTileConfigPersist } from '../widgetTileFiltersHooks'
@@ -29,9 +29,7 @@ export function SurveyResultsWidgetTileFilters({
}: DashboardWidgetTileFiltersProps): JSX.Element {
const surveyId = parseSurveyResultsWidgetConfig(config).surveyId ?? null
- const configRef = useRef(config)
- configRef.current = config
- const { persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig)
+ const { getLatestConfig, persistConfigNow } = useWidgetTileConfigPersist(onUpdateConfig, config)
// Reflect the pick immediately rather than waiting for the persist round-trip to update `config`.
const [optimisticSurveyId, setOptimisticSurveyId] = useState<string | null | undefined>(undefined)
@@ -39,8 +37,7 @@ export function SurveyResultsWidgetTileFilters({
const applySurveyId = async (value: string | null): Promise<void> => {
setOptimisticSurveyId(value)
- const nextConfig = patchSurveyResultsWidgetConfig(configRef.current, value)
- configRef.current = nextConfig
+ const nextConfig = patchSurveyResultsWidgetConfig(getLatestConfig(), value)
try {
await persistConfigNow(nextConfig)
} finally {
diff --git a/products/dashboards/frontend/widgets/widgetTileFiltersHooks.test.ts b/products/dashboards/frontend/widgets/widgetTileFiltersHooks.test.ts
index 31708a81d6bf..1b0f3379d810 100644
--- a/products/dashboards/frontend/widgets/widgetTileFiltersHooks.test.ts
+++ b/products/dashboards/frontend/widgets/widgetTileFiltersHooks.test.ts
@@ -31,4 +31,122 @@ describe('useWidgetTileConfigPersist', () => {
expect(onUpdateConfig).toHaveBeenCalledTimes(1)
expect(onUpdateConfig).toHaveBeenCalledWith({ limit: 10, status: 'resolved' })
})
+
+ it('serializes config updates', async () => {
+ let resolveFirstUpdate: (() => void) | undefined
+ const onUpdateConfig = jest
+ .fn()
+ .mockImplementationOnce(
+ () =>
+ new Promise<void>((resolve) => {
+ resolveFirstUpdate = resolve
+ })
+ )
+ .mockResolvedValueOnce(undefined)
+ const { result } = renderHook(() => useWidgetTileConfigPersist(onUpdateConfig))
+
+ let firstUpdate: Promise<void>
+ let secondUpdate: Promise<void>
+ act(() => {
+ firstUpdate = result.current.persistConfigNow({ status: 'active' })
+ secondUpdate = result.current.persistConfigNow({ status: 'resolved' })
+ })
+
+ await act(async () => {
+ await Promise.resolve()
+ })
+ expect(onUpdateConfig).toHaveBeenCalledTimes(1)
+
+ resolveFirstUpdate?.()
+ await act(async () => {
+ await firstUpdate
+ await secondUpdate
+ })
+
+ expect(onUpdateConfig).toHaveBeenNthCalledWith(1, { status: 'active' })
+ expect(onUpdateConfig).toHaveBeenNthCalledWith(2, { status: 'resolved' })
+ })
+
+ it('keeps the latest local config while queued updates are pending', async () => {
+ let resolveFirstUpdate: (() => void) | undefined
+ const onUpdateConfig = jest.fn().mockImplementationOnce(
+ () =>
+ new Promise<void>((resolve) => {
+ resolveFirstUpdate = resolve
+ })
+ )
+ const { result, rerender } = renderHook(({ config }) => useWidgetTileConfigPersist(onUpdateConfig, config), {
+ initialProps: { config: { status: 'initial' } },
+ })
+
+ let firstUpdate: Promise<void>
+ let secondUpdate: Promise<void>
+ act(() => {
+ firstUpdate = result.current.persistConfigNow({ status: 'active' })
+ secondUpdate = result.current.persistConfigNow({ status: 'resolved' })
+ })
+
+ await act(async () => {
+ await Promise.resolve()
+ })
+
+ rerender({ config: { status: 'active' } })
+
+ expect(result.current.getLatestConfig()).toEqual({ status: 'resolved' })
+
+ resolveFirstUpdate?.()
+ await act(async () => {
+ await firstUpdate
+ await secondUpdate
+ })
+ })
+
+ it('keeps a newer queued config when an earlier update fails', async () => {
+ let rejectFirstUpdate: ((error: Error) => void) | undefined
+ const onUpdateConfig = jest
+ .fn()
+ .mockImplementationOnce(
+ () =>
+ new Promise<void>((_resolve, reject) => {
+ rejectFirstUpdate = reject
+ })
+ )
+ .mockResolvedValueOnce(undefined)
+ const { result } = renderHook(() => useWidgetTileConfigPersist(onUpdateConfig, { status: 'initial' }))
+
+ let firstUpdate: Promise<void>
+ let secondUpdate: Promise<void>
+ act(() => {
+ firstUpdate = result.current.persistConfigNow({ status: 'active' })
+ secondUpdate = result.current.persistConfigNow({ status: 'resolved' })
+ })
+
+ await act(async () => {
+ await Promise.resolve()
+ })
+
+ rejectFirstUpdate?.(new Error('Update failed'))
+ await act(async () => {
+ await firstUpdate
+ await secondUpdate
+ })
+
+ expect(result.current.getLatestConfig()).toEqual({ status: 'resolved' })
+ })
+
+ it('flushes a pending debounced update on unmount', async () => {
+ const onUpdateConfig = jest.fn().mockResolvedValue(undefined)
+ const { result, unmount } = renderHook(() => useWidgetTileConfigPersist(onUpdateConfig))
+
+ act(() => {
+ result.current.persistConfigDebounced({ status: 'active' })
+ })
+ unmount()
+
+ await act(async () => {
+ await Promise.resolve()
+ })
+
+ expect(onUpdateConfig).toHaveBeenCalledWith({ status: 'active' })
+ })
})
diff --git a/products/dashboards/frontend/widgets/widgetTileFiltersHooks.ts b/products/dashboards/frontend/widgets/widgetTileFiltersHooks.ts
index dd1ae6e9da1e..b91d6097d0fb 100644
--- a/products/dashboards/frontend/widgets/widgetTileFiltersHooks.ts
+++ b/products/dashboards/frontend/widgets/widgetTileFiltersHooks.ts
@@ -1,5 +1,7 @@
import { useCallback, useEffect, useRef } from 'react'
+import { lemonToast } from 'lib/lemon-ui/LemonToast'
+
import type { QuickFilter } from '~/types'
import {
@@ -38,21 +40,65 @@ export function getWidgetTileFiltersSetup(widgetType: DashboardWidgetCatalogKey)
}
export function useWidgetTileConfigPersist(
- onUpdateConfig?: (config: Record<string, unknown>) => void | Promise<void>
+ onUpdateConfig?: (config: Record<string, unknown>) => void | Promise<void>,
+ receivedConfig?: Record<string, unknown>
): {
+ getLatestConfig: () => Record<string, unknown>
persistConfigDebounced: (config: Record<string, unknown>) => void
persistConfigNow: (config: Record<string, unknown>) => Promise<void>
} {
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null)
+ const debouncedConfigRef = useRef<Record<string, unknown> | null>(null)
+ const latestConfigRef = useRef<Record<string, unknown>>(receivedConfig ?? {})
+ const receivedConfigRef = useRef(receivedConfig)
+ const pendingPersistCountRef = useRef(0)
+ const persistQueueRef = useRef<Promise<void>>(Promise.resolve())
const onUpdateConfigRef = useRef(onUpdateConfig)
onUpdateConfigRef.current = onUpdateConfig
+ if (receivedConfig !== receivedConfigRef.current) {
+ receivedConfigRef.current = receivedConfig
+ if (!debounceRef.current && pendingPersistCountRef.current === 0 && receivedConfig) {
+ latestConfigRef.current = receivedConfig
+ }
+ }
+
+ const getLatestConfig = useCallback((): Record<string, unknown> => latestConfigRef.current, [])
+
const persistConfigNow = useCallback(async (config: Record<string, unknown>): Promise<void> => {
if (debounceRef.current) {
clearTimeout(debounceRef.current)
debounceRef.current = null
+ debouncedConfigRef.current = null
+ }
+ latestConfigRef.current = config
+ pendingPersistCountRef.current += 1
+ const persistPromise = persistQueueRef.current
+ .catch(() => undefined)
+ .then(() => onUpdateConfigRef.current?.(config))
+ persistQueueRef.current = persistPromise
+ try {
+ await persistPromise
+ } catch (error) {
+ if (receivedConfigRef.current && latestConfigRef.current === config) {
+ latestConfigRef.current = receivedConfigRef.current
+ }
+ if (
+ error instanceof Error &&
+ error.name === 'WidgetConfigValidationError' &&
+ 'fieldErrors' in error &&
+ typeof error.fieldErrors === 'object' &&
+ error.fieldErrors !== null
+ ) {
+ const fieldErrors = error.fieldErrors as Record<string, string | undefined>
+ const validationMessage = Object.values(fieldErrors).find((message) => !!message)
+ lemonToast.error(
+ validationMessage ?? 'Could not update widget filters. Check the values and try again.'
+ )
+ }
+ } finally {
+ pendingPersistCountRef.current -= 1
}
- await onUpdateConfigRef.current?.(config)
}, [])
const persistConfigDebounced = useCallback(
@@ -63,8 +109,11 @@ export function useWidgetTileConfigPersist(
if (debounceRef.current) {
clearTimeout(debounceRef.current)
}
+ latestConfigRef.current = config
+ debouncedConfigRef.current = config
debounceRef.current = setTimeout(() => {
debounceRef.current = null
+ debouncedConfigRef.current = null
void persistConfigNow(config)
}, WIDGET_TILE_REFRESH_DEBOUNCE_MS)
},
@@ -75,9 +124,15 @@ export function useWidgetTileConfigPersist(
return () => {
if (debounceRef.current) {
clearTimeout(debounceRef.current)
+ debounceRef.current = null
+ }
+ if (debouncedConfigRef.current) {
+ const pendingConfig = debouncedConfigRef.current
+ debouncedConfigRef.current = null
+ void persistConfigNow(pendingConfig)
}
}
- }, [])
+ }, [persistConfigNow])
- return { persistConfigDebounced, persistConfigNow }
+ return { getLatestConfig, persistConfigDebounced, persistConfigNow }
}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index c0717b7bb48a..376f90e6f1ad 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -2030,6 +2030,26 @@ export namespace Schemas {
value?: string | string[] | null;
}
+ export type ActivityEventsPropertyFilterType = typeof ActivityEventsPropertyFilterType[keyof typeof ActivityEventsPropertyFilterType];
+
+
+ export const ActivityEventsPropertyFilterType = {
+ Event: 'event',
+ Person: 'person',
+ } as const;
+
+ export interface ActivityEventsPropertyFilter {
+ /**
+ * @minLength 1
+ * @maxLength 400
+ */
+ key: string;
+ label?: string | null;
+ operator: PropertyOperator;
+ type: ActivityEventsPropertyFilterType;
+ value?: (string | number | boolean)[] | string | number | boolean | null;
+ }
+
export type ActivityEventsListWidgetConfigWidgetFilters = {[key: string]: WidgetFilterEntry} | null;
export interface ActivityEventsListWidgetConfig {
@@ -2044,6 +2064,8 @@ export namespace Schemas {
limit?: number;
/** Limit the feed to a single event name. Omit or null for all events. */
eventName?: string | null;
+ /** Event and person property filters, matching Activity > Explore events. */
+ properties?: ActivityEventsPropertyFilter[] | null;
}
export interface ActivityEventsListWidgetAddRequestOpenApi {
diff --git a/services/mcp/src/generated/dashboards/api.ts b/services/mcp/src/generated/dashboards/api.ts
index b261c5c54897..0b5cee44eb9c 100644
--- a/services/mcp/src/generated/dashboards/api.ts
+++ b/services/mcp/src/generated/dashboards/api.ts
@@ -123,6 +123,18 @@ export const dashboardsPartialUpdateBodyNameMax = 400
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOneLimitDefault = 25
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOneLimitMax = 50
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemKeyMax = 400
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemLabelOneMax = 400
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneItemOneMax = 4000
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneMax = 100
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueTwoMax = 4000
+
+export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneMax = 20
+
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneTwoLimitDefault = 10
export const dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneTwoLimitMax = 25
@@ -313,6 +325,102 @@ export const DashboardsPartialUpdateBody = /* @__PURE__ */ zod
.describe(
'Limit the feed to a single event name. Omit or null for all events.'
),
+ properties: zod
+ .union([
+ zod
+ .array(
+ zod.object({
+ key: zod
+ .string()
+ .min(1)
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemKeyMax
+ ),
+ label: zod
+ .union([
+ zod
+ .string()
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemLabelOneMax
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ type: zod.enum(['event', 'person']),
+ value: zod
+ .union([
+ zod
+ .array(
+ zod.union([
+ zod
+ .string()
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneItemOneMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ ])
+ )
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueOneMax
+ ),
+ zod
+ .string()
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneItemValueTwoMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ zod.null(),
+ ])
+ .optional(),
+ })
+ )
+ .max(
+ dashboardsPartialUpdateBodyTilesItemWidgetOneConfigOneOnePropertiesOneMax
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'Event and person property filters, matching Activity > Explore events.'
+ ),
}),
zod.object({
dateRange: zod
@@ -1047,6 +1155,18 @@ export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneNameMax = 400
export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOneLimitDefault = 25
export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOneLimitMax = 50
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax = 400
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax = 400
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax = 4000
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax = 100
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax = 4000
+
+export const dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneMax = 20
+
export const dashboardsWidgetsBatchCreateBodyWidgetsItemTwoNameMax = 400
export const dashboardsWidgetsBatchCreateBodyWidgetsItemTwoConfigOneLimitDefault = 10
@@ -1238,6 +1358,100 @@ export const DashboardsWidgetsBatchCreateBody = /* @__PURE__ */ zod
.union([zod.string().min(1), zod.null()])
.optional()
.describe('Limit the feed to a single event name. Omit or null for all events.'),
+ properties: zod
+ .union([
+ zod
+ .array(
+ zod.object({
+ key: zod
+ .string()
+ .min(1)
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax
+ ),
+ label: zod
+ .union([
+ zod
+ .string()
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ type: zod.enum(['event', 'person']),
+ value: zod
+ .union([
+ zod
+ .array(
+ zod.union([
+ zod
+ .string()
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ ])
+ )
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax
+ ),
+ zod
+ .string()
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ zod.null(),
+ ])
+ .optional(),
+ })
+ )
+ .max(
+ dashboardsWidgetsBatchCreateBodyWidgetsItemOneConfigOnePropertiesOneMax
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Event and person property filters, matching Activity > Explore events.'),
})
.describe('Configuration for the recent events widget.'),
}),
@@ -1994,6 +2208,18 @@ export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneNameMax = 400
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitDefault = 25
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitMax = 50
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax = 4000
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax = 100
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax = 4000
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneMax = 20
+
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoNameMax = 400
export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitDefault = 10
@@ -2143,6 +2369,100 @@ export const DashboardsUpdateWidgetsBatchBody = /* @__PURE__ */ zod
.union([zod.string().min(1), zod.null()])
.optional()
.describe('Limit the feed to a single event name. Omit or null for all events.'),
+ properties: zod
+ .union([
+ zod
+ .array(
+ zod.object({
+ key: zod
+ .string()
+ .min(1)
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemKeyMax
+ ),
+ label: zod
+ .union([
+ zod
+ .string()
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemLabelOneMax
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ type: zod.enum(['event', 'person']),
+ value: zod
+ .union([
+ zod
+ .array(
+ zod.union([
+ zod
+ .string()
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneItemOneMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ ])
+ )
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueOneMax
+ ),
+ zod
+ .string()
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneItemValueTwoMax
+ ),
+ zod.number(),
+ zod.boolean(),
+ zod.null(),
+ ])
+ .optional(),
+ })
+ )
+ .max(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOnePropertiesOneMax
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Event and person property filters, matching Activity > Explore events.'),
})
.optional()
.describe('New configuration for the recent events widget. Omit to leave unchanged.'),
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 fbc4124862ea..49fd1130a241 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
@@ -180,6 +180,118 @@
"minimum": 1,
"type": "number"
},
+ "properties": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "key": {
+ "maxLength": 400,
+ "minLength": 1,
+ "type": "string"
+ },
+ "label": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "operator": {
+ "enum": [
+ "exact",
+ "is_not",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex",
+ "gt",
+ "gte",
+ "lt",
+ "lte",
+ "is_set",
+ "is_not_set",
+ "is_date_exact",
+ "is_date_before",
+ "is_date_after",
+ "between",
+ "not_between",
+ "min",
+ "max",
+ "in",
+ "not_in",
+ "is_cleaned_path_exact",
+ "flag_evaluates_to",
+ "semver_eq",
+ "semver_neq",
+ "semver_gt",
+ "semver_gte",
+ "semver_lt",
+ "semver_lte",
+ "semver_tilde",
+ "semver_caret",
+ "semver_wildcard",
+ "icontains_multi",
+ "not_icontains_multi"
+ ],
+ "type": "string"
+ },
+ "type": {
+ "enum": ["event", "person"],
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "items": {
+ "anyOf": [
+ {
+ "maxLength": 4000,
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ }
+ ]
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "maxLength": 4000,
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["key", "operator", "type"],
+ "type": "object"
+ },
+ "maxItems": 20,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Event and person property filters, matching Activity > Explore events."
+ },
"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 fff980dd29f5..83102aeec4c7 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
@@ -76,6 +76,118 @@
"minimum": 1,
"type": "number"
},
+ "properties": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "key": {
+ "maxLength": 400,
+ "minLength": 1,
+ "type": "string"
+ },
+ "label": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "operator": {
+ "enum": [
+ "exact",
+ "is_not",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex",
+ "gt",
+ "gte",
+ "lt",
+ "lte",
+ "is_set",
+ "is_not_set",
+ "is_date_exact",
+ "is_date_before",
+ "is_date_after",
+ "between",
+ "not_between",
+ "min",
+ "max",
+ "in",
+ "not_in",
+ "is_cleaned_path_exact",
+ "flag_evaluates_to",
+ "semver_eq",
+ "semver_neq",
+ "semver_gt",
+ "semver_gte",
+ "semver_lt",
+ "semver_lte",
+ "semver_tilde",
+ "semver_caret",
+ "semver_wildcard",
+ "icontains_multi",
+ "not_icontains_multi"
+ ],
+ "type": "string"
+ },
+ "type": {
+ "enum": ["event", "person"],
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "items": {
+ "anyOf": [
+ {
+ "maxLength": 4000,
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ }
+ ]
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "maxLength": 4000,
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["key", "operator", "type"],
+ "type": "object"
+ },
+ "maxItems": 20,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Event and person property filters, matching Activity > Explore events."
+ },
"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 9013256bc9bf..995db91de13b 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
@@ -76,6 +76,118 @@
"minimum": 1,
"type": "number"
},
+ "properties": {
+ "anyOf": [
+ {
+ "items": {
+ "properties": {
+ "key": {
+ "maxLength": 400,
+ "minLength": 1,
+ "type": "string"
+ },
+ "label": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "operator": {
+ "enum": [
+ "exact",
+ "is_not",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex",
+ "gt",
+ "gte",
+ "lt",
+ "lte",
+ "is_set",
+ "is_not_set",
+ "is_date_exact",
+ "is_date_before",
+ "is_date_after",
+ "between",
+ "not_between",
+ "min",
+ "max",
+ "in",
+ "not_in",
+ "is_cleaned_path_exact",
+ "flag_evaluates_to",
+ "semver_eq",
+ "semver_neq",
+ "semver_gt",
+ "semver_gte",
+ "semver_lt",
+ "semver_lte",
+ "semver_tilde",
+ "semver_caret",
+ "semver_wildcard",
+ "icontains_multi",
+ "not_icontains_multi"
+ ],
+ "type": "string"
+ },
+ "type": {
+ "enum": ["event", "person"],
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "items": {
+ "anyOf": [
+ {
+ "maxLength": 4000,
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ }
+ ]
+ },
+ "maxItems": 100,
+ "type": "array"
+ },
+ {
+ "maxLength": 4000,
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["key", "operator", "type"],
+ "type": "object"
+ },
+ "maxItems": 20,
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Event and person property filters, matching Activity > Explore events."
+ },
"widgetFilters": {
"anyOf": [
{