From 54050fd8affb7217d7b8ba08c2c9607695353143 Mon Sep 17 00:00:00 2001 From: david hamp-gonsalves Date: Wed, 10 Sep 2025 12:05:08 -0300 Subject: [PATCH] Add experiment tracking for the control assignment event --- .../base_namespace_create_service.rb | 2 ++ .../standard_namespace_create_service_spec.rb | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ee/app/services/registrations/base_namespace_create_service.rb b/ee/app/services/registrations/base_namespace_create_service.rb index ec16b500898ed5..17d5ce20a2d68d 100644 --- a/ee/app/services/registrations/base_namespace_create_service.rb +++ b/ee/app/services/registrations/base_namespace_create_service.rb @@ -19,6 +19,8 @@ def after_successful_group_creation(group_track_action:) Gitlab::Tracking.event(self.class.name, group_track_action, namespace: group, user: user) ::Onboarding::Progress.onboard(group) + experiment(:lightweight_trial_registration_redesign, actor: user).track(:assignment, namespace: group) + apply_trial if onboarding_user_status.apply_trial? end diff --git a/ee/spec/services/registrations/standard_namespace_create_service_spec.rb b/ee/spec/services/registrations/standard_namespace_create_service_spec.rb index e2353d31889353..f42a56655da13d 100644 --- a/ee/spec/services/registrations/standard_namespace_create_service_spec.rb +++ b/ee/spec/services/registrations/standard_namespace_create_service_spec.rb @@ -83,6 +83,26 @@ ) end + context 'with experiment lightweight_trial_registration_redesign' do + let(:experiment) { instance_double(ApplicationExperiment) } + + before do + allow_next_instance_of(described_class) do |service| + allow(service).to receive(:experiment).with(:lightweight_trial_registration_redesign, + actor: user).and_return(experiment) + end + end + + it 'tracks experiment assignment' do + allow_next_instance_of(::Projects::CreateService) do |service| + allow(service).to receive(:after_create_actions) + end + + expect(experiment).to receive(:track).with(:assignment, namespace: an_instance_of(Group)) + expect(execute).to be_success + end + end + it 'enqueues a create event worker' do expect(Groups::CreateEventWorker).to receive(:perform_async).with(anything, user.id, 'created') -- GitLab