Skip to content

Commit 1aafaa1

Browse files
committed
Update doc for filters
1 parent 1734460 commit 1aafaa1

File tree

1 file changed

+112
-30
lines changed

1 file changed

+112
-30
lines changed
Lines changed: 112 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,149 @@
11
# Event Filters
22

3-
Event filters let you **narrow down the events** sent to your destination by applying simple matching rules. They’re useful when you're only interested in specific types of changes—like ignoring automated updates or focusing on certain attributes.
3+
Event filters let you **focus only on the events that matter to you** by applying simple, readable conditions. Instead of receiving every single event, you can choose to receive just a subset—like changes made by a specific user or updates to a specific attribute.
44

5-
**Filters are optional**: if no filter is defined, your subscription will receive **all events** matching its type and source.
5+
This helps you reduce noise and tailor your event subscription to your needs.
66

7-
Filters are defined when configuring [your subscription](/event-platform/concepts.html) and are automatically evaluated during event routing.
7+
> ℹ️ **Filters are optional**
8+
> If no filter is defined, your subscription will receive **all events** that match its type and source.
89
9-
> ℹ️ For now, only **one filter** can be configured per subscription. Combining multiple filters (e.g., filtering by both user and attribute) is not yet supported.
10+
> ⚠️ **Filter behavior depends on the event type**
11+
> The `user` filter (author) works with all event types.
12+
> Filters like `attribute`, `locale`, `scope`, and `channel` can technically be used on any subscription, but they only **make sense** for `product.updated.delta` and `product_model.updated.delta` events.
13+
>
14+
> If used with other event types, these filters may silently skip events, as the necessary data (like `"changes"`) won't be present in the payload.
15+
>
16+
> **Tip**: For best results, create a dedicated subscription for delta events and apply these filters there.
17+
18+
## How filters work
19+
20+
Filters are defined during the subscription configuration (more details on [the Subscriptions page](/event-platform/concepts.html)) and are automatically evaluated when an event is processed. If the event **matches your filter**, it is forwarded to your destination. If not, it is silently skipped.
1021

1122
---
1223

13-
## `user`
24+
## Available Filters
25+
26+
### `user`
1427

15-
Use this filter to receive only events triggered by a specific user.
28+
Receive only events triggered by a specific user.
1629

17-
- **Syntax**
30+
- **Syntax**
1831
`user="user_identifier"`
19-
- **Parameters**
20-
- `user_identifier`: The UUID of the user who authored the event.
2132

22-
- **Example**
33+
- **Parameter**
34+
`user_identifier`: The UUID of the user who performed the change.
35+
36+
- **Example**
2337
`user="57616f6f-1a4d-490e-bc23-c5877d2b30d9"`
2438

39+
> 💡 Useful for: Ignoring updates by a designated user.
40+
2541
---
2642

27-
## `attribute`
43+
### `attribute`
2844

29-
Use this filter to receive only delta events where a specific attribute was updated.
45+
Receive only events where a specific attribute was modified.
3046

31-
- **Syntax**
47+
- **Syntax**
3248
`attribute="attribute_code"`
33-
- **Parameters**
34-
- `attribute_code`: The code of the attribute you want to track.
3549

36-
- **Example**
50+
- **Parameter**
51+
`attribute_code`: The code of the attribute you want to monitor.
52+
53+
- **Example**
3754
`attribute="short_description"`
3855

56+
> 💡 Useful for: Tracking changes to business-critical fields like price, title, or status.
57+
3958
---
4059

41-
## `scope`
60+
### `scope`
61+
62+
Receive only events related to a specific channel (also called *scope*).
4263

43-
Use this filter to receive only delta events related to a specific channel.
64+
- **Syntax**
65+
`scope="channel_code"` or `channel="channel_code"`
4466

45-
- **Syntax**
46-
`scope="code"` or `channel="code"`
47-
- **Parameters**
48-
- `code`: The scope / channel code of the updated data.
67+
- **Parameter**
68+
`channel_code`: The code of the channel where the update occurred.
4969

50-
- **Example**
51-
`scope="my_scope"`
70+
- **Example**
71+
`scope="ecommerce"`
72+
73+
> 💡 Useful for: Filtering updates specific to a distribution channel like "mobile", "print", or "marketplace".
5274
5375
---
5476

55-
## `locale`
77+
### `locale`
5678

57-
Use this filter to receive only delta events for a specific locale.
79+
Receive only events related to a specific locale.
5880

59-
- **Syntax**
81+
- **Syntax**
6082
`locale="locale_code"`
61-
- **Parameters**
62-
- `locale_code`: The locale code of the updated data.
6383

64-
- **Example**
84+
- **Parameter**
85+
`locale_code`: The code of the locale (e.g., language-region).
86+
87+
- **Example**
6588
`locale="en_US"`
6689

90+
> 💡 Useful for: Only processing updates in a particular language or region.
91+
92+
---
93+
94+
## Filter Operators
95+
96+
Filters support **basic logic operators** that let you build more flexible and expressive conditions. This means you can combine or exclude criteria in a single filter expression.
97+
98+
---
99+
100+
### Supported Operators
101+
102+
| Operator | Description |
103+
|----------|-------------|
104+
| `and` | All conditions must match. |
105+
| `or` | At least one condition must match. |
106+
| `not` | Excludes matching events. |
107+
67108
---
109+
110+
### Examples
111+
112+
#### "Receive only events where the **author is a specific user** **and** a specific **attribute** was updated"
113+
`user="john-uuid" and attribute="price"`
114+
115+
#### "Receive events where **either** the "description" or "title" attribute was updated"
116+
`attribute="description" or attribute="title"`
117+
118+
#### "Receive all updates **except** those made by the system user"
119+
`not user="system"`
120+
121+
#### "Receive updates to the "name" attribute **in French** but **not** made by the system"
122+
`(attribute="name" and locale="fr_FR") and not user="system"`
123+
124+
## Limitations & Rules
125+
126+
To keep filters simple, readable, and fast to evaluate, a few rules and limitations apply:
127+
128+
- You can define **One filter per subscription**
129+
130+
131+
- **All values must be wrapped in double quotes**
132+
`user="system"`
133+
`user=system`
134+
135+
136+
- **You can use parentheses** to group conditions and clarify your logic.
137+
Example:
138+
`user="system" and (attribute="name" or attribute="description")`
139+
140+
141+
- **Maximum filter length**: 500 characters
142+
143+
144+
- **Maximum number of operators**: 4
145+
146+
147+
- **Query complexity is limited**
148+
Deeply nested or overly complex filters may be rejected. If this happens, you’ll receive an error message.
149+
Try simplifying your expression or splitting your use case into multiple subscriptions.

0 commit comments

Comments
 (0)