Added namespace actor to Product Analytics billing feature flag
What does this MR do and why?
This MR is in continuation with https://gitlab.com/gitlab-org/gitlab/-/issues/438399 where we are enabling product analytics billing.
This adds a namespace actor to product_analytics_billing
feature flag. Namespaces with the flag enabled will be able to purchase product_analytics
addon and use product analytics features.
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
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
-
Set GDK to SaaS simulation and enable product analytics feature flag.
-
Create a new group, with ultimate subscription.
-
Try to purchase product_analytics addon for the group namespace.
POST /api/v4/namespaces/{namespace_id}/subscription_add_on_purchase/product_analytics Request Body - {"quantity":"1","expires_on":"2024-03-03","purchase_xid":"1234"}
-
You should get a 500 error. The addon cannot be purchased as the billing flag
product_analytics_billing
is not enabled for the namespace. -
You can also check the status of billing flag for a given namespace using
Feature.enabled?(:product_analytics_billing, namespace, type: :wip)
-
Now enable the feature flag
product_analytics_billing
for the group namespaceFeature.enable(:product_analytics_billing, namespace, type: :wip)
-
Try to purchase the
product_analytics
addon again. You should get a 200 OK response this time. -
Verify that addon and addon purchase are assigned to the namespace
[3] pry(main)> GitlabSubscriptions::AddOnPurchase.last => #<GitlabSubscriptions::AddOnPurchase:0x000000012a1777c8 id: 1, created_at: Fri, 23 Feb 2024 07:38:18.079237000 UTC +00:00, updated_at: Fri, 23 Feb 2024 07:38:18.079237000 UTC +00:00, subscription_add_on_id: 1, namespace_id: 24, quantity: 1, expires_on: Wed, 01 Jan 2025, purchase_xid: "ANY STRING", last_assigned_users_refreshed_at: nil> [4] pry(main)> GitlabSubscriptions::AddOn.last => #<GitlabSubscriptions::AddOn:0x000000012a673948 id: 1, created_at: Fri, 23 Feb 2024 07:38:18.043147000 UTC +00:00, updated_at: Fri, 23 Feb 2024 07:38:18.043147000 UTC +00:00, name: "product_analytics", description: "[FILTERED]">
Related to #441245