Skip to content
Snippets Groups Projects
Verified Commit ab0dea4f authored by Doug Stull's avatar Doug Stull :two: Committed by GitLab
Browse files

Merge branch '448506-move-and-deduplicate-tracking' into 'master'

Draft: Move tracking for duo pro trial into service layer

See merge request !147698



Merged-by: Doug Stull's avatarDoug Stull <dstull@gitlab.com>
parents 047d6d3b 34c91b41
No related branches found
No related tags found
No related merge requests found
Pipeline #1224498413 failed
Pipeline: GitLab

#1224504890

    Pipeline: GitLab

    #1224504621

      Pipeline: GitLab

      #1224504611

        ......@@ -37,9 +37,6 @@ def create
        if @result.success?
        # lead and trial created
        track_event('duo_pro_trial_registration_success')
        redirect_to group_path(@result.payload[:namespace])
        elsif @result.reason == GitlabSubscriptions::Trials::CreateDuoProService::NO_SINGLE_NAMESPACE
        # lead created, but we now need to select namespace and then apply a trial
        ......@@ -56,8 +53,6 @@ def create
        render :step_namespace_failed
        else
        # trial creation failed
        track_event('duo_pro_trial_registration_failure')
        params[:namespace_id] = @result.payload[:namespace_id]
        render :trial_failed
        ......
        ......@@ -40,27 +40,35 @@ def lead_flow
        result = lead_service_class.new.execute({ trial_user: trial_user_params })
        if result.success?
        if single_eligible_namespace_for_trial?
        @namespace = namespaces_eligible_for_trial.first
        apply_trial_flow
        else
        # trigger new creation for next step...
        trial_selection_params = {
        step: TRIAL
        }.merge(lead_params.slice(:glm_content, :glm_source))
        .merge(trial_params.slice(:namespace_id))
        ServiceResponse.error(
        message: 'Lead created, but singular eligible namespace not present',
        reason: NO_SINGLE_NAMESPACE,
        payload: { trial_selection_params: trial_selection_params }
        )
        end
        after_lead_success_hook
        else
        ServiceResponse.error(message: result.message, reason: LEAD_FAILED)
        after_lead_error_hook(result)
        end
        end
        def after_lead_success_hook
        if single_eligible_namespace_for_trial?
        @namespace = namespaces_eligible_for_trial.first
        apply_trial_flow
        else
        # trigger new creation for next step...
        trial_selection_params = {
        step: TRIAL
        }.merge(lead_params.slice(:glm_content, :glm_source))
        .merge(trial_params.slice(:namespace_id))
        ServiceResponse.error(
        message: 'Lead created, but singular eligible namespace not present',
        reason: NO_SINGLE_NAMESPACE,
        payload: { trial_selection_params: trial_selection_params }
        )
        end
        end
        def after_lead_error_hook(result)
        ServiceResponse.error(message: result.message, reason: LEAD_FAILED)
        end
        def lead_service_class
        raise NoMethodError, 'Subclasses must implement the lead_service_class method'
        end
        ......@@ -101,12 +109,16 @@ def apply_trial_flow
        ServiceResponse.success(message: 'Trial applied', payload: { namespace: namespace })
        else
        ServiceResponse.error(
        message: result.message, payload: { namespace_id: trial_params[:namespace_id] }, reason: TRIAL_FAILED
        )
        after_trial_error_hook(result)
        end
        end
        def after_trial_error_hook(result)
        ServiceResponse.error(
        message: result.message, payload: { namespace_id: trial_params[:namespace_id] }, reason: TRIAL_FAILED
        )
        end
        def apply_trial_service_class
        raise NoMethodError, 'Subclasses must implement the apply_trial_service_class method'
        end
        ......
        ......@@ -5,10 +5,10 @@ module Trials
        class CreateDuoProService < ::GitlabSubscriptions::Trials::BaseCreateService
        private
        def lead_flow
        super.tap do |response|
        track_lead_creation(response)
        end
        def after_lead_success_hook
        track_event('duo_pro_lead_creation_success')
        super
        end
        def lead_service_class
        ......@@ -35,12 +35,16 @@ def trial_user_params
        )
        end
        def track_lead_creation(response)
        if response.error? && response.reason == LEAD_FAILED
        track_event('duo_pro_lead_creation_failure')
        else
        track_event('duo_pro_lead_creation_success')
        end
        def after_lead_error_hook(_result)
        track_event('duo_pro_lead_creation_failure')
        super
        end
        def after_trial_error_hook(_result)
        track_event('duo_pro_trial_registration_failure')
        super
        end
        def track_event(action)
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment