Skip to content

Fix product analytics state when addon is not purchased

Halil Coban requested to merge access-to-the-product-analytics-onboarding into master

What does this MR do and why?

This MR fixes a bug that occurs when

  • Product analytics onboarding is completed before
  • product_analytics_billing is enabled
  • Customer did not purchase the add on
  • Customer visits the product analytics dashboards page

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

When FF is disabled

No visual change

When FF is enabled

Before

Screenshot_2024-04-05_at_13.37.01

After

When Screenshot
Customer sees set up button Screenshot_2024-04-05_at_13.39.29
Setup button takes to onboarding page Screenshot_2024-04-05_at_13.39.33
After customer buys the addon Screenshot_2024-04-05_at_13.41.06

How to set up and validate locally

  1. Disable the feature flag
    Feature.disable(:product_analytics_billing, namespace, type: :wip)
  2. Set up product analytics
  3. Visit dashboards page http://gdk.test:3000/namespace/project/-/analytics/dashboards
  4. You should be able to see product analytics dashboards
  5. Enable the feature flag
    Feature.enable(:product_analytics_billing, namespace, type: :wip)
  6. Visit same dashboards page http://gdk.test:3000/namespace/project/-/analytics/dashboards
  7. You should not see dashboards but see a Set up button
  8. Clicking set up button should show Sales CTA
  9. Create an add on
a = GitlabSubscriptions::AddOn.new(description: "Product analytics", name = 2)
a.save
p = GitlabSubscriptions::AddOnPurchase.new(namespace: group, expires_on: 1.year.from_now.to_date, quantity: 1, purchase_xid: SecureRandom.hex(16),  subscription_add_on_id: a.id)
p.save
  1. Visit same dashboards page http://gdk.test:3000/namespace/project/-/analytics/dashboards
  2. You should be able to see product analytics dashboards

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/454335

Edited by Halil Coban

Merge request reports