Repository navigation
feat(insights): paths with start/end points, cleaning rules, groupings, exclusions and actors - #10
Merged
Merged
Conversation
…s, exclusions and actors POST /api/v1/insights/paths builds per-session paths of pageviews and/or custom events and returns a weighted edge list (PostHog PathsQuery shape: "1_/home" -> "2_/pricing"), with step_limit, edge_limit, min/max edge weight, start_point / end_point, regex path cleaning rules, wildcard groupings and excluded items. POST /api/v1/insights/paths/actors returns the visitors behind a node, an edge, or a drop-off. Adds the `regex` crate (already in Cargo.lock transitively) for RE2-style cleaning rules, compiled once per query; invalid patterns return 400. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b24086de4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…es cannot exhaust memory Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and Why
Pulse's paths showed only a one-hop next/previous page from a single URL. This adds PostHog-style multi-step paths: a weighted edge list ready for a Sankey chart, with start and end points, cleaning and grouping, exclusions, and drill-down to the visitors behind any node, edge or drop-off.
Stacked on #9 (base
ayush/retention-lifecycle); retarget tomainonce the stack below merges.Reference followed: PostHog
PathsQuery/PathsFilter(includeEventTypes,startPoint,endPoint,stepLimit,edgeLimit,minEdgeWeight/maxEdgeWeight,localPathCleaningFilters,pathGroupings,excludeEvents) andPathsActorsQuery. The node key format"<step>_<item>"matches PostHog's response, so a Sankey component built for PostHog can render it unchanged.Changes
POST /api/v1/insights/pathsstart_pointstarts each path at the first occurrence of that item.end_pointkeeps the steps leading up to it.step_limit(2–20),edge_limit, andmin_edge_weight/max_edge_weight.path_cleaning_rules({regex, alias}, applied in order),path_groupings(wildcards such as/blog/*),exclude_events, and global filters with nested groups.source,target,value, andaverage_conversion_time_secs.POST /api/v1/insights/paths/actorsreturns the visitors behind a node (path_start_key), an edge (pluspath_end_key), or a drop-off (dropoff: true).spawn_blocking, with a 2M-event cap that returns 400 when hit.regex = "1". It's the standard Rust regex crate, already inCargo.locktransitively, and its RE2-style syntax matches the ClickHouse/re2 rules PostHog path cleaning uses. Patterns are compiled once per query, and invalid ones return 400.Reviews and Follow-up
identityFiles Changed
services/insights/paths.rs(new)services/insights/mod.rs,routes/insights.rs,main.rsCargo.toml,Cargo.lockScope and Non-scope
In scope: the paths insight and its actors. Out of scope: UI, saved project cleaning rules, and the excluded LLM/account features.
Validation
I ran it on Postgres 18 with the seeded dataset, plus extra blog and user pages so the paths vary. Every edge map was compared with an independent Python path builder over the raw rows:
All match.
Testing
cargo test: 118 passed, including 5 new paths tests covering collapsing, exclusions, start/end/step limits, cleaning and grouping, regex escaping and validation.Size and Notes
About 540 changed lines. No migrations, and existing endpoints are unchanged.
🤖 Generated with Claude Code