Skip to content

Add additional fields to product analytics processor to be able to retrieve dashboard/visualization configurations via GraphQL

Max Woolf requested to merge add-additional-dashboard-visualisation-graphql into master

What does this MR do and why?

  • Adds support for product analytics dashboards visualizations in the GraphQL API.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Enable the feature flag
    Feature.enable(:cube_api_proxy)
  2. Make sure the following application settings are set. (Their values aren't important for this endpoint.)
  • product_analytics_enabled == true
  • cube_api_base_url
  • cube_api_key
  1. In any repository, create a dashboard definition by creating a file .gitlab/product_analytics/dashboards/north_star/north_star.yaml with this content:
---
version: '1'
title: North Star Metrics
description: North Star Metrics across all departments for the last 3 quarters.
widgets:
  - title: Overall Conversion Rate
    gridAttributes:
      yPos: 4
      xPos: 1
      width: 12
      height: 2
    visualization: cube_line_chart
  1. Create a visualization (.gitlab/product_analytics/dashboards/visualizations/cube_line_chart.yaml)
version: '1'
type: LineChart
options:
  xAxis:
    name: Time
    type: time
  yAxis:
    name: Counts
data:
  type: Cube
  query:
    measures:
      - Stories.count
    dimensions:
      - Stories.category
    filters:
      - member: Stories.isDraft
        operator: equals
        values:
          - 'No'
    timeDimensions:
      - dimension: Stories.time
        # dateRange set by the dashboard filter
        granularity: month
    limit: 100
    offset: 50
    order:
      Stories.time: asc
      Stories.count: desc
    timezone: America/Los_Angeles
  1. Make an API call to that project using GraphQL authenticated using a developer or higher on that project.
query {
  project(fullPath: "flightjs/project_twenty") {
    name
    productAnalyticsDashboards(slug: "north_star") {
      nodes {
        title
        description
        widgets {
          nodes {
            title
            gridAttributes
            visualization {
              type
              options
              data
            }
          }
        }
      }
    }
  }
}
  1. Assert that the dashboard, widget and visualization data is returned.

MR acceptance checklist

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

Edited by Max Woolf

Merge request reports