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 # frozen_string_literal: true
class SubscriptionsController < ApplicationController class SubscriptionsController < ApplicationController
SUCCESS_SUBSCRIPTION = 'Success: subscription'
SUCCESS_ADDON = 'Success: add-on'
include InternalRedirect include InternalRedirect
include OneTrustCSP include OneTrustCSP
...@@ -101,7 +103,7 @@ class SubscriptionsController < ApplicationController ...@@ -101,7 +103,7 @@ class SubscriptionsController < ApplicationController
).execute ).execute
if response[:success] if response[:success]
track_purchase message: 'Success', namespace: group track_purchase message: track_success_message, namespace: group
response[:data] = { location: redirect_location(group) } response[:data] = { location: redirect_location(group) }
else else
track_purchase message: response.dig(:data, :errors), namespace: group track_purchase message: response.dig(:data, :errors), namespace: group
...@@ -121,6 +123,14 @@ class SubscriptionsController < ApplicationController ...@@ -121,6 +123,14 @@ class SubscriptionsController < ApplicationController
) )
end 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) def redirect_location(group)
return safe_redirect_path(params[:redirect_after_success]) if params[:redirect_after_success] return safe_redirect_path(params[:redirect_after_success]) if params[:redirect_after_success]
......
...@@ -442,7 +442,26 @@ RSpec.describe SubscriptionsController do ...@@ -442,7 +442,26 @@ RSpec.describe SubscriptionsController do
category: 'SubscriptionsController', category: 'SubscriptionsController',
label: 'confirm_purchase', label: 'confirm_purchase',
action: 'click_button', 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, namespace: selected_group,
user: user 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