Skip to content

Update Cube proxy to work with Cube JS library

What does this MR do and why?

This MR changes the following:

  • Moves the endpoint from being a POST to a GET
  • Append the /load to the end of the endpoint
  • Add the queryType param to the Cube API query body

These changes are behind the :cube_api_proxy feature flag.

Screenshots or screen recordings

Created using the patches in the issue and associated MRs

Screen_Recording_2022-10-11_at_15.42.53

How to set up and validate locally

  1. Enable the feature flag: echo "Feature.enable(:cube_api_proxy)" | rails c.
  2. Set up the devkit and start it running using docker-compose up.
  3. Update application settings: echo "ApplicationSetting.current.update(cube_api_base_url: 'http://localhost:4000', cube_api_key: API KEY FROM CUBE .env)" | rails c.
  4. As an authenticated user who has developer+ access to a particular project, make the following API call:
POST /api/v4/projects/{PROJECT_ID}/product_analytics/request

Content-Type: application/json

Send it with a valid cube query as a JSON body:

{
  "query": {
    "measures": [
      "Jitsu.count"
    ],
    "timeDimensions": [
      {
        "dimension": "Jitsu.utcTime",
        "dateRange": "This week"
      }
    ],
    "order": [
      [
        "Jitsu.count",
        "desc"
      ],
      [
        "Jitsu.docPath",
        "desc"
      ],
      [
        "Jitsu.utcTime",
        "asc"
      ]
    ],
    "dimensions": [
      "Jitsu.docPath"
    ],
    "limit": 23
  },
  "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.

Related to #377511 (closed)

Edited by Robert Hunt

Merge request reports