diff --git a/content/docs/platform/inbox/configuration/data-object.mdx b/content/docs/platform/inbox/configuration/data-object.mdx index a865c58ee..1ab83d600 100644 --- a/content/docs/platform/inbox/configuration/data-object.mdx +++ b/content/docs/platform/inbox/configuration/data-object.mdx @@ -64,7 +64,9 @@ This allows TypeScript to infer the structure of `notification.data`, reducing e ## Use data object keys as filters for tabs -You can use data object keys as filter for tabs. For more information, refer to [Tabs](/platform/inbox/configuration/tabs#filter-tabs-by-data-attributes). +Use data object keys to filter Inbox tabs, `useNotifications`, and bulk actions such as mark-all-read. Filters support exact scalars, OR lists, nested keys (one level), and AND-of-OR groups on the same field. + +For examples and limits, refer to [Tabs — Using the data object](/platform/inbox/configuration/tabs#using-the-data-object). ```tsx import { Inbox } from '@novu/react'; diff --git a/content/docs/platform/inbox/configuration/tabs.mdx b/content/docs/platform/inbox/configuration/tabs.mdx index 4ee330103..37262b5a5 100644 --- a/content/docs/platform/inbox/configuration/tabs.mdx +++ b/content/docs/platform/inbox/configuration/tabs.mdx @@ -85,6 +85,63 @@ function InboxTabs() { export default InboxTabs; ``` +#### Match multiple values (OR) + +Match notifications when a data key equals any value in a list. Pass a scalar array or an explicit `{ or: [...] }` object: + +```tsx +const tabs = [ + { + label: 'Open or draft', + filter: { + data: { status: ['open', 'draft'] }, + }, + }, + { + label: 'Team A or B', + filter: { + data: { team: { or: ['alpha', 'beta'] } }, + }, + }, +]; +``` + +#### Combine conditions (AND) + +Require multiple OR-groups on the same key by using `{ and: [{ or: [...] }, ...] }`. Every group must match. Use this when a notification stores an array in `data` and you need several values to appear together. + +```tsx +const tabs = [ + { + label: 'Tagged urgent and in review', + filter: { + data: { + labels: { and: [{ or: ['urgent'] }, { or: ['review'] }] }, + }, + }, + }, +]; +``` + +#### Nested data keys + +Filter on one level of nesting under `data`. Sub-keys support the same scalar, array, `{ or }`, and `{ and }` shapes as top-level keys. + +```tsx +const tabs = [ + { + label: 'Project A or B', + filter: { + data: { project: { id: ['proj-a', 'proj-b'] } }, + }, + }, +]; +``` + +Multiple top-level keys in the same `data` filter are combined with AND logic. For example, `{ status: 'open', project: 'abc' }` matches only notifications where both keys match. + +Data filter values must be scalars (string, number, boolean, or null). String values are limited to 256 characters. Each OR-group allows up to 100 values, with up to 30 AND-groups and 200 total values per field. + ### Using tags and data object You can combine tags and the data object in the same filter to create more specific tabs tailored to your use case. diff --git a/content/docs/platform/sdks/javascript/index.mdx b/content/docs/platform/sdks/javascript/index.mdx index 492f66695..98ffa9461 100644 --- a/content/docs/platform/sdks/javascript/index.mdx +++ b/content/docs/platform/sdks/javascript/index.mdx @@ -344,6 +344,11 @@ await novu.notifications.seenAll({ data: { type: 'login' } }); +// Match any of several data values (OR) +await novu.notifications.seenAll({ + data: { status: ['open', 'draft'] }, +}); + // Mark all notifications as seen (no filters) await novu.notifications.seenAll(); ``` diff --git a/content/docs/platform/sdks/react/hooks/use-notifications.mdx b/content/docs/platform/sdks/react/hooks/use-notifications.mdx index 2a8175be6..e45a00b34 100644 --- a/content/docs/platform/sdks/react/hooks/use-notifications.mdx +++ b/content/docs/platform/sdks/react/hooks/use-notifications.mdx @@ -16,7 +16,7 @@ The `useNotifications` hook provides a way to fetch and manage notifications in "type": "string[]" }, "data": { - "description": "", + "description": "Filter by notification.data keys. Each key accepts a scalar (exact match), a scalar array or { or: Scalar[] } (match any value), { and: [{ or: Scalar[] }, ...] } (AND of OR-groups), or a one-level nested object with the same shapes on sub-keys. Multiple keys are AND-ed.", "type": "Record" }, "read": {