Commit e20fb276 authored by Dallas Reedy's avatar Dallas Reedy

Track the Continuous Onboarding Iteration 2 experiment

- Create a custom experiment class so we can add the project's
  namespace's id to the automatically tracked "assignment" event
- Add data-track-experiment attribute to the Learn GitLab dashboard
  links
parent 45f4b2ce
...@@ -40,6 +40,7 @@ export default { ...@@ -40,6 +40,7 @@ export default {
data-track-action="click_link" data-track-action="click_link"
:data-track-label="$options.i18n.ACTION_LABELS[action].title" :data-track-label="$options.i18n.ACTION_LABELS[action].title"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
data-track-experiment="change_continuous_onboarding_link_urls"
> >
{{ $options.i18n.ACTION_LABELS[action].title }} {{ $options.i18n.ACTION_LABELS[action].title }}
</gl-link> </gl-link>
......
# 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
...@@ -13,6 +13,7 @@ module LearnGitlabHelper ...@@ -13,6 +13,7 @@ module LearnGitlabHelper
urls_to_use = nil urls_to_use = nil
experiment(:change_continuous_onboarding_link_urls) do |e| experiment(:change_continuous_onboarding_link_urls) do |e|
e.namespace = project.namespace
e.use { urls_to_use = action_urls } e.use { urls_to_use = action_urls }
e.try { urls_to_use = new_action_urls(project) } e.try { urls_to_use = new_action_urls(project) }
end 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
...@@ -135,6 +135,7 @@ exports[`Learn GitLab renders correctly 1`] = ` ...@@ -135,6 +135,7 @@ exports[`Learn GitLab renders correctly 1`] = `
<a <a
class="gl-link" class="gl-link"
data-track-action="click_link" data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Set up CI/CD" data-track-label="Set up CI/CD"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/" href="http://example.com/"
...@@ -156,6 +157,7 @@ exports[`Learn GitLab renders correctly 1`] = ` ...@@ -156,6 +157,7 @@ exports[`Learn GitLab renders correctly 1`] = `
<a <a
class="gl-link" class="gl-link"
data-track-action="click_link" data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Start a free Ultimate trial" data-track-label="Start a free Ultimate trial"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/" href="http://example.com/"
...@@ -177,6 +179,7 @@ exports[`Learn GitLab renders correctly 1`] = ` ...@@ -177,6 +179,7 @@ exports[`Learn GitLab renders correctly 1`] = `
<a <a
class="gl-link" class="gl-link"
data-track-action="click_link" data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Add code owners" data-track-label="Add code owners"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/" href="http://example.com/"
...@@ -205,6 +208,7 @@ exports[`Learn GitLab renders correctly 1`] = ` ...@@ -205,6 +208,7 @@ exports[`Learn GitLab renders correctly 1`] = `
<a <a
class="gl-link" class="gl-link"
data-track-action="click_link" data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Add merge request approval" data-track-label="Add merge request approval"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/" href="http://example.com/"
...@@ -269,6 +273,7 @@ exports[`Learn GitLab renders correctly 1`] = ` ...@@ -269,6 +273,7 @@ exports[`Learn GitLab renders correctly 1`] = `
<a <a
class="gl-link" class="gl-link"
data-track-action="click_link" data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Create an issue" data-track-label="Create an issue"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/" href="http://example.com/"
...@@ -290,6 +295,7 @@ exports[`Learn GitLab renders correctly 1`] = ` ...@@ -290,6 +295,7 @@ exports[`Learn GitLab renders correctly 1`] = `
<a <a
class="gl-link" class="gl-link"
data-track-action="click_link" data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Submit a merge request" data-track-label="Submit a merge request"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/" href="http://example.com/"
...@@ -347,6 +353,7 @@ exports[`Learn GitLab renders correctly 1`] = ` ...@@ -347,6 +353,7 @@ exports[`Learn GitLab renders correctly 1`] = `
<a <a
class="gl-link" class="gl-link"
data-track-action="click_link" data-track-action="click_link"
data-track-experiment="change_continuous_onboarding_link_urls"
data-track-label="Run a Security scan using CI/CD" data-track-label="Run a Security scan using CI/CD"
data-track-property="Growth::Conversion::Experiment::LearnGitLab" data-track-property="Growth::Conversion::Experiment::LearnGitLab"
href="http://example.com/" href="http://example.com/"
......
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