Skip to content

Fix cube schema funnels

Robert Hunt requested to merge fix-cube-funnels-schema into main

What does this MR do and why?

This MR updates the dynamic funnel schema to correctly generate the funnels based upon the GitLab API response.

It starts by moving the funnels retrieve out of the schema file itself, as schema file compilation is done in a more restricted environment.

It then adds a new schema version cache invalidation which is currently set to 10 minutes for normal schemas, and one minute for funnels.

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

  1. Pull this branch
  2. Set up a project with the configuration project being the same as the project itself.
  3. Set up a new funnel definition. For example, you could create a file named .gitlab/analytics/funnels/product_analytics_dashboards_funnel.yaml which contains:
    name: product_analytics_dashboards_funnel
    seconds_to_convert: 300
    steps:
      - name: view_landing_page
        target: '/gitlab-org/gdk-tracking'
        action: 'pageview'
      - name: view_dashboards
        target: '/gitlab-org/gdk-tracking/-/analytics/dashboards'
        action: 'pageview'
  4. Create an PAT for the user with access to the project.
  5. Send a request to the funnels API endpoint to confirm the funnel data is being retrieved by the GitLab API:
    curl --location '<GDK_HOST>/api/v4/projects/<PROJECT_ID>/product_analytics/funnels' \
    --header 'PRIVATE-TOKEN: <TOKEN>' \
    --header 'Content-Type: application/json'
  6. Send a request to the meta API endpoint to confirm Cube is finding the funnel:
    curl --location '<GDK_HOST>/api/v4/projects/<PROJECT_ID>/product_analytics/request/meta' \
    --header 'PRIVATE-TOKEN: <TOKEN>' \
    --header 'Content-Type: application/json' \
    --data '{}'
  7. Send a request to the load API endpoint to confirm the funnel data is returned by Cube:
    curl --location '<GDK_HOST>/api/v4/projects/<PROJECT_ID>/product_analytics/request/load?queryType=multi&include_token=true' \
    --header 'PRIVATE-TOKEN: <TOKEN>' \
    --header 'Content-Type: application/json' \
    --data '{
      "query": {
        "measures": [
          "product_analytics_dashboards_funnel.count"
        ],
        "order": {
          "product_analytics_dashboards_funnel.count": "desc"
        },
        "dimensions": [
          "product_analytics_dashboards_funnel.step"
        ]
      }
    }'
  8. Change the configuration project to a different project (to test the PATs) and repeat steps 3-7.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Relates to gitlab-org/gitlab#427860 (closed)

Edited by Robert Hunt

Merge request reports

Loading