Skip to content

Add nested condition groups to saved segments - #4457

Open
lucy-the-marketer wants to merge 1 commit into
umami-software:devfrom
lucy-the-marketer:feat/nested-segment-groups
Open

lucy-the-marketer wants to merge 1 commit into
umami-software:devfrom
lucy-the-marketer:feat/nested-segment-groups

Conversation

@lucy-the-marketer

@lucy-the-marketer lucy-the-marketer commented Aug 16, 2026

Copy link
Copy Markdown

Summary

  • allow saved segments to contain recursively nested condition groups with independent all/any matching
  • add nested group controls to the segment editor and preserve nested definitions through the segment API
  • compile nested filters consistently for PostgreSQL and ClickHouse report queries
  • keep existing flat saved segments compatible

Validation

  • focused Biome lint on all 12 changed files
  • production build via pnpm build-docker with geo download disabled
  • git diff --check

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

@lucy-the-marketer is attempting to deploy a commit to the Umami Software Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 63784f32-eb28-4b8f-a118-53784a2b337c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds recursively nested all/any condition groups to saved segments and carries them through editing, validation, request resolution, and both analytics backends.

  • Adds recursive segment-group editor controls and API schemas.
  • Compiles nested filter trees into PostgreSQL and ClickHouse predicates with unique parameters.
  • Preserves existing flat segment filters while adding nested definitions.
  • The new control labels are currently present only in the English locale catalog.

Confidence Score: 4/5

The PR appears safe to merge, with the non-blocking issue that its new group controls are not localized outside English.

Nested groups are propagated through the editor, API, request pipeline, and both database builders, but the two newly rendered labels are absent from every non-English locale catalog.

Files Needing Attention: public/intl/messages/en-US.json and the other public/intl/messages locale catalogs

Important Files Changed

Filename Overview
src/app/(main)/websites/[websiteId]/segments/SegmentGroupFields.tsx Adds the recursive editor for nested condition groups and exposes add/remove controls.
src/lib/schema.ts Adds recursive validation for persisted child groups while retaining flat segment compatibility.
src/lib/request.ts Loads nested saved-group definitions into report query filters.
src/lib/params.ts Resolves nested filter columns and unique parameter names and flattens trees for parameter binding.
src/lib/prisma.ts Adds PostgreSQL compilation and parameter binding for recursive groups.
src/lib/clickhouse.ts Mirrors recursive group compilation and binding for ClickHouse.
public/intl/messages/en-US.json Adds the two editor labels only to en-US, leaving other supported locale catalogs without them.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  UI[Segment editor] --> API[Segment API validation]
  API --> Store[(Saved segment parameters)]
  Store --> Request[getQueryFilters]
  Request --> Tree[Resolve nested filter groups]
  Tree --> PG[PostgreSQL predicate builder]
  Tree --> CH[ClickHouse predicate builder]
  PG --> Reports[Analytics reports]
  CH --> Reports
Loading

Reviews (1): Last reviewed commit: "Add nested condition groups to saved seg..." | Re-trigger Greptile

"actions": "Actions",
"activity": "Activity",
"add": "Add",
"add-group": "Add group",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Group labels lack translations

The new add-group and delete-group keys exist only in the English catalog, so users of every other supported locale see missing-key fallback text on the nested-group controls. Add these keys to the other locale catalogs.

Knowledge Base Used: Frontend App Shell

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant