Funnels schema SQL remains unchanged when syncing funnels
Issue:
When syncing funnels in case of custom dashboards, SQL schema does not change. It might produce error when querying cube for new synced funnels or show incorrect data.
Steps to reproduce:
-
Onboard two projects with product analytics, project A and project B.
-
Update project A's custom dashboard pointer project to project B.
-
Create a funnel definition yaml in project B by creating a file
.gitlab/analytics/funnels/dashboard_usage.yaml
with following contents.name: Dashboard Usage seconds_to_convert: 3600 steps: - name: homepage target: '/' action: 'pageview' - name: subsection target: '/#section-1' action: 'pageview'
-
It will sync funnels to project A's clickhouse table
funnel_schemas
. Check clickhouse tableselect * from gitlab_project_A.funnel_schemas where name = 'dashboard_usage'
You will see that funnel schema is generated for project B instead of project A.
{"name":"dashboard_usage","schema":" SELECT\n (SELECT max(derived_tstamp) FROM gitlab_project_B.snowplow_events) as x,\n windowFunnel(3600)(toDateTime(derived_tstamp), page_urlpath = '/', page_urlpath = '/page2.html') as step\n FROM gitlab_project_B.snowplow_events\n","steps":["page_urlpath = '/'","page_urlpath = '/page2.html'"]}
-
If we use cube to query this funnel. It can either return incorrect data (if cube has privileges to read project A and project B clickhouse tables else it will throw error).
-
Same issue exists for moved funnels (MoveFunnelsWorker) too.
Implementation plan
- In
analytics-manager
when saving a funnel for a project, replace the project name in the schema to match the project id.