Updates cube funnels to read schema from clickhouse
What does this MR do and why?
This updates Cube to use the Clickhouse stored funnel configurations rather than trying to retrieve them via the GitLab API (that had a downside of not being auto refreshed)
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
-
Update cube schema in docker
-
Create a new funnel or update existing funnel by making an api call to
/funnel-schemas
endpoint in configuratorPOST http://{analytics-configurator-endpoint}/funnel-schemas Authorization: Basic [AUTH_USERNAME] [AUTH_PASSWORD] Content-Type: application/json { "project_ids": ["gitlab_project_20001"], "funnels": [ { "name": "completed_purchase", "schema": "SELECT (SELECT max(derived_tstamp) FROM gitlab_project_20001.snowplow_events) as x, windowFunnel(3600)(toDateTime(derived_tstamp), page_urlpath = ''/page1.html'', page_urlpath = ''/page2.html'') as step FROM gitlab_project_20001.snowplow_events", "state": "created" } ] }
OR
Pull from gitlab-org/gitlab!150292 (merged) and run GDK locally. Create a new file in any repository called
.gitlab/analytics/funnels/completed_purchase.yaml
with the following contents.name: Completed Purchase seconds_to_convert: 3600 steps: - name: view_page_1 target: '/page1.html' action: 'pageview' - name: view_page_2 target: '/page2.html' action: 'pageview'
-
Check clickhouse table
gitlab_project_#{id}.funnel_schemas
to verify if the funnel got saved -
Make an API call to cubejs
/v1/meta
endpoint to see the cube schema defined. It shouls have a cube schema definitioncompleted_purchase
-
Seed clickhouse table
snowplow_events
with some random datainsert into gitlab_project_20001.snowplow_events (derived_tstamp, event, user_id, user_id_type, page_urlpath) values ('2023-02-07 10:44:10','page_view', '1', 'identify', '/page1.html'), ('2023-02-08 10:44:12','page_view', '1', 'identify', '/page2.html'), ('2023-02-10 10:44:22','page_view', generateUUIDv4(), 'cookie', null), ('2023-02-11 10:44:22','page_view', generateUUIDv4(), 'cookie', null);
-
Make cube's REST api call to
/v1/load
endpoint. It should return a 200 OK responsePOST /cubejs-api/v1/load HTTP/1.1 Content-Type: application/json Authorization: JWT encoded cube security header { "query": { "measures": [ "completed_purchase.count" ] }, "queryType": "multi" }
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Relates to gitlab-org/gitlab#438036 (closed)