Commit b2735b88 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch...

Merge branch '348469-update-tracking-for-the-continuous-onboarding-iteration-2-experiment' into 'master'

Update tracking for the Continuous Onboarding iteration 2 experiment

See merge request gitlab-org/gitlab!76979
parents c6f0db11 90385228
# frozen_string_literal: true
class ChangeContinuousOnboardingLinkUrlsExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
attr_writer :namespace
def track(action, **event_args)
super(action, **event_args.merge(namespace: @namespace))
end
end
......@@ -27,8 +27,12 @@ module LearnGitlabHelper
urls_to_use = nil
experiment(:change_continuous_onboarding_link_urls) do |e|
e.namespace = project.namespace
experiment(
:change_continuous_onboarding_link_urls,
namespace: project.namespace,
actor: current_user,
sticky_to: project.namespace
) do |e|
e.use { urls_to_use = action_urls }
e.try { urls_to_use = new_action_urls(project) }
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ChangeContinuousOnboardingLinkUrlsExperiment, :snowplow do
before do
stub_experiments(change_continuous_onboarding_link_urls: 'control')
end
describe '#track' do
context 'when no namespace has been set' do
it 'tracks the action as normal' do
subject.track(:some_action)
expect_snowplow_event(
category: subject.name,
action: 'some_action',
namespace: nil,
context: [
{
schema: 'iglu:com.gitlab/gitlab_experiment/jsonschema/1-0-0',
data: an_instance_of(Hash)
}
]
)
end
end
context 'when a namespace has been set' do
let_it_be(:namespace) { create(:namespace) }
before do
subject.namespace = namespace
end
it 'tracks the action and merges the namespace into the event args' do
subject.track(:some_action)
expect_snowplow_event(
category: subject.name,
action: 'some_action',
namespace: namespace,
context: [
{
schema: 'iglu:com.gitlab/gitlab_experiment/jsonschema/1-0-0',
data: an_instance_of(Hash)
}
]
)
end
end
end
end
......@@ -176,6 +176,19 @@ RSpec.describe LearnGitlabHelper do
)
})
end
it 'calls experiment with expected context & options' do
allow(helper).to receive(:current_user).and_return(user)
expect(helper).to receive(:experiment).with(
:change_continuous_onboarding_link_urls,
namespace: namespace,
actor: user,
sticky_to: namespace
)
learn_gitlab_data
end
end
end
end
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