Skip to content

Update product analytics onboarding state management

Jiaan Louw requested to merge 391974-update-product-analytics-state into master

What does this MR do and why?

This MR updates the Product Analytics onboarding to use the new productAnalyticsState resource that was added in #391973 (closed).

This MR makes the following changes:

  • Add a new state component that queries productAnalyticsState.
  • Update the onboarding components to use the new state component.
  • Move GraphQL queries out of the mutations dir.
  • Move instance creation mutation to the empty state component so that it's in the component that calls it.
  • Remove unused hasAnalyticsData method.

Related issue [Frontend] Update the analytics app to retrieve... (#391974 - closed).

This feature is hidden behind a default off feature flag.

Screenshots or screen recordings

There should be no visual changes.

Recording

Kapture_2023-03-28_at_17.49.01

Screenshots

Click to expand

Not set up state

Before After
image image

Waiting for events state

Before After
image image

Complete state

Before After
image image

How to set up and validate locally

To test the product analytics dashboard items are shown, you will need to follow the instructions at https://gitlab.com/gitlab-org/gitlab/-/snippets/2474959 to enable Product Analytics on your GDK.

  1. Create a new project or view one that does not have product analytics setup yet.
  2. Visit the product analytics view at [GDK_HOST]/gitlab-org/[PROJECT]/-/product_analytics/dashboards/
    • Note this is not the new /analytics view!
  3. Click on Set up product analytics
  4. Wait for the instrumentation screen to appear and copy the SDK App ID.
  5. To create events, add the userscript below (eg using tapermonkey) for your GDK and change YOUR_APP_ID_KEY to your SDK App ID.
  6. Go back the instrumentation screen tab and click on something. You should then be redirected to the dashboard lists view.
Click to view userscript
(function() {
  var jsSDK = document.createElement('script');
  jsSDK.setAttribute('src','https://unpkg.com/@gitlab/application-sdk-js/dist/gl-sdk.min.js');

  jsSDK.onload = function() {

    window.glClient = window.glSDK.glClientSDK({
      applicationId: 'YOUR_APP_ID_KEY',
      host: 'http://localhost:8000/configurator'
    });

    window.glClient.page();
  }

  document.head.appendChild(jsSDK);
})();

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 #391974 (closed)

Edited by Jiaan Louw

Merge request reports