Commit b2670b67 authored by Andy Soiron's avatar Andy Soiron

Merge branch '342853-follow-up-change-tracking-messages-on-successful-purchase' into 'master'

Add differentiation for tracking purchases

See merge request gitlab-org/gitlab!80718
parents dd41d7a2 7cdb2319
# frozen_string_literal: true
class SubscriptionsController < ApplicationController
SUCCESS_SUBSCRIPTION = 'Success: subscription'
SUCCESS_ADDON = 'Success: add-on'
include InternalRedirect
include OneTrustCSP
......@@ -101,7 +103,7 @@ class SubscriptionsController < ApplicationController
).execute
if response[:success]
track_purchase message: 'Success', namespace: group
track_purchase message: track_success_message, namespace: group
response[:data] = { location: redirect_location(group) }
else
track_purchase message: response.dig(:data, :errors), namespace: group
......@@ -121,6 +123,14 @@ class SubscriptionsController < ApplicationController
)
end
def track_success_message
addon? ? SUCCESS_ADDON : SUCCESS_SUBSCRIPTION
end
def addon?
Gitlab::Utils.to_boolean(subscription_params[:is_addon], default: false)
end
def redirect_location(group)
return safe_redirect_path(params[:redirect_after_success]) if params[:redirect_after_success]
......
......@@ -442,7 +442,26 @@ RSpec.describe SubscriptionsController do
category: 'SubscriptionsController',
label: 'confirm_purchase',
action: 'click_button',
property: 'Success',
property: 'Success: subscription',
namespace: selected_group,
user: user
)
end
end
context 'purchasing an addon' do
before do
params[:subscription][:is_addon] = true
end
it 'tracks creation with add-on success message' do
subject
expect_snowplow_event(
category: 'SubscriptionsController',
label: 'confirm_purchase',
action: 'click_button',
property: 'Success: add-on',
namespace: selected_group,
user: user
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment