Repository navigation
Implement core logic of dynamic funnels support - #6762
Merged
Merged
Conversation
zoldar
force-pushed
the
dynamic-funnel-core
branch
from
October 8, 2026 10:23
5618ffa to
c744fab
Compare
zoldar
force-pushed
the
dynamic-funnel-core
branch
2 times, most recently
from
October 14, 2026 11:42
3fbe6de to
82ccead
Compare
zoldar
force-pushed
the
dynamic-funnel-core
branch
from
October 14, 2026 12:33
82ccead to
4133094
Compare
|
zoldar
marked this pull request as ready for review
October 14, 2026 15:57
zoldar
force-pushed
the
dynamic-funnel-core
branch
2 times, most recently
from
October 15, 2026 11:06
d5752c3 to
8c34891
Compare
apata
approved these changes
Oct 19, 2026
apata
left a comment
Contributor
There was a problem hiding this comment.
Elegant, nice work! Some minor comms below:
Co-authored-by: Uku Taht <Uku.taht@gmail.com>
Co-authored-by: Artur Pata <4290938+apata@users.noreply.github.com>
Co-authored-by: Artur Pata <4290938+apata@users.noreply.github.com>
zoldar
force-pushed
the
dynamic-funnel-core
branch
from
October 20, 2026 08:11
4659a74 to
9df904b
Compare
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.
Changes
Follow-up to #6761. Implements support for configuring steps dynamically via core funnels API.
There are no user facing changes at this stage yet. The PR is focused on introducing core logic for supporting querying and configuring funnels with dynamic steps.
The key addition is
dynamic_stepsembed introduced inPlausible.Funnelschema. This field, along with core API:changeset/2with extendedput_steps/1,goals/1,steps/1,as_goal/1andswap/1, provides the core abstraction for manipulating steps of the funnel without having to explicitly handle division between goal-backed, static steps and goal-less dynamic steps.The
DynamicStepstruct embed merges properties of a step with those of theGoalstruct, reusing significant part of its validation logic too.The
put_stepsstage in the changeset now ensures that steps passed as params are seamlessly split into static and dynamic ones, preserving their original ordering.The funnel steps must always be retrieved via
steps/1function to ensure both types of steps are returned in a consistent shape and order.Similarly,
goal/1returns a consistent list of step goals. In the case of dynamic steps, theGoalstructs are populated on the fly. Additionally, there'sas_goalto retrieve respectiveGoalstruct on the basis of a given step.Finally,
swap/2is exposed for a pretty specific case of swapping funnel steps in place without parsing through params. It ensures consistent step ordering is ensured. It's current only use is calculating revenue metrics when querying funnel stats.The steps of different types can be mixed freely within a single funnel as long as constraints like minimum and maximum steps count are met.
Funnels.list/1andFunnels.with_goals_query/1, which are base functions for querying funnel definitions, are also updated to gracefully handle fully dynamic funnels (stepsjoins getting switched toLEFT) and return accurate data (steps_countaccounting for steps being spread among 2 columns).One last significant change is how ephemeral funnel is built in
Live.FunnelSettings.Form. Until now, it only consideredevent_nameandpage_pathfields of theGoalas all the other were filtered out. This meant that the numbers from funnel evaluation in form view did not reflect what an actual funnel would return. Withscroll_thresholdandcustom_propstaken into consideration, the evaluation result has much higher fidelity. Thecurrencyis not strictly necessary as the evaluation does not query for revenue. Regardless, it was added for completeness' sake - the cost of sending it over the wire is not that significant, given it's at most 3 extra bytes + JSON wrapping.The rest is pretty much a sweeping scan of the codebase and replacing direct references to the funnel steps with usage of newly introduced API functions mentioned earlier.
There's one consequence of introducing the notion of dynamic steps to consider - the funnel steps might no longer be unique within a single funnel. Even though the
stepsjoin table has a unique constraint onfunnel_idandgoal_idcombination, there's currently nothing that would stop somebody (once the API is exposed to the users) from using a goal step and a dynamic step with exact same parameters, or multiple dynamic steps with exact same parameters.The follow-up PR #6741 introducing final batch of changes to the
FunnelSettingsform will still filter out goals used in previous steps from the suggestions for further steps. However, this can't be enforced via database constraints anymore - and it's not explicitly disallowed on the changeset level either.Tests