Update funnels data model
What does this MR do and why?
The code changes the way the funnel data is calculated. Instead of using a window function to calculate the time between steps, it now uses a recursive query to calculate the time between each step. This change should improve the accuracy of the funnel data, especially for funnels with a large number of steps. Additionally, the code now uses a more efficient way to calculate the number of users who completed each step of the funnel.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
-
Pull from gitlab-org/analytics-section/product-analytics/devkit!166 (merged) in devkit to update the cube schema definition.
-
Update any existing funnel or create a new funnel for a project already onboarded with product analytics.
name: Path Funnel seconds_to_convert: 3600 steps: - name: view_page_1 target: '/page1.html' action: 'pageview' - name: view_page_2 target: '/page2.html' action: 'pageview' - name: view_page_3 target: '/page3.html' action: 'pageview'
-
Verify SQL saved in clickhouse by running
SELECT JSONExtractString(contents, 'schema') AS sql FROM ${appId}.funnel_schemas WHERE name = 'path_funnel'
-
Ensure newly created dynamic cube is reflected in
/v1/meta
endpoint. -
Query newly created cube on
/v1/load
endpoint with measures and dimensions and filter(optional) and verify if filtered data is correct.POST /cubejs-api/v1/load HTTP/1.1 Host: localhost:4000 Accept: */* Accept-Language: en-GB,en-US;q=0.9,en;q=0.8 Authorization: content-type: application/json { "query": { "measures": [ "path_funnel.count" ], "filters": [ { "member": "path_funnel.date", "operator": "inDateRange", "values": [ "2023-02-07", "2023-02-08" ] }, { "member": "path_funnel.step", "operator": "equals", "values": [1] } ], "dimensions": [ "path_funnel.step" ] }, "queryType": "multi" }
Related to #463491 (closed)