|
1 | 1 | # Event Filters
|
2 | 2 |
|
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. |
4 | 4 |
|
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. |
6 | 6 |
|
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. |
8 | 9 |
|
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. |
10 | 21 |
|
11 | 22 | ---
|
12 | 23 |
|
13 |
| -## `user` |
| 24 | +## Available Filters |
| 25 | + |
| 26 | +### `user` |
14 | 27 |
|
15 |
| -Use this filter to receive only events triggered by a specific user. |
| 28 | +Receive only events triggered by a specific user. |
16 | 29 |
|
17 |
| -- **Syntax** |
| 30 | +- **Syntax** |
18 | 31 | `user="user_identifier"`
|
19 |
| -- **Parameters** |
20 |
| - - `user_identifier`: The UUID of the user who authored the event. |
21 | 32 |
|
22 |
| -- **Example** |
| 33 | +- **Parameter** |
| 34 | + `user_identifier`: The UUID of the user who performed the change. |
| 35 | + |
| 36 | +- **Example** |
23 | 37 | `user="57616f6f-1a4d-490e-bc23-c5877d2b30d9"`
|
24 | 38 |
|
| 39 | +> 💡 Useful for: Ignoring updates by a designated user. |
| 40 | +
|
25 | 41 | ---
|
26 | 42 |
|
27 |
| -## `attribute` |
| 43 | +### `attribute` |
28 | 44 |
|
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. |
30 | 46 |
|
31 |
| -- **Syntax** |
| 47 | +- **Syntax** |
32 | 48 | `attribute="attribute_code"`
|
33 |
| -- **Parameters** |
34 |
| - - `attribute_code`: The code of the attribute you want to track. |
35 | 49 |
|
36 |
| -- **Example** |
| 50 | +- **Parameter** |
| 51 | + `attribute_code`: The code of the attribute you want to monitor. |
| 52 | + |
| 53 | +- **Example** |
37 | 54 | `attribute="short_description"`
|
38 | 55 |
|
| 56 | +> 💡 Useful for: Tracking changes to business-critical fields like price, title, or status. |
| 57 | +
|
39 | 58 | ---
|
40 | 59 |
|
41 |
| -## `scope` |
| 60 | +### `scope` |
| 61 | + |
| 62 | +Receive only events related to a specific channel (also called *scope*). |
42 | 63 |
|
43 |
| -Use this filter to receive only delta events related to a specific channel. |
| 64 | +- **Syntax** |
| 65 | + `scope="channel_code"` or `channel="channel_code"` |
44 | 66 |
|
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. |
49 | 69 |
|
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". |
52 | 74 |
|
53 | 75 | ---
|
54 | 76 |
|
55 |
| -## `locale` |
| 77 | +### `locale` |
56 | 78 |
|
57 |
| -Use this filter to receive only delta events for a specific locale. |
| 79 | +Receive only events related to a specific locale. |
58 | 80 |
|
59 |
| -- **Syntax** |
| 81 | +- **Syntax** |
60 | 82 | `locale="locale_code"`
|
61 |
| -- **Parameters** |
62 |
| - - `locale_code`: The locale code of the updated data. |
63 | 83 |
|
64 |
| -- **Example** |
| 84 | +- **Parameter** |
| 85 | + `locale_code`: The code of the locale (e.g., language-region). |
| 86 | + |
| 87 | +- **Example** |
65 | 88 | `locale="en_US"`
|
66 | 89 |
|
| 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 | + |
67 | 108 | ---
|
| 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