Commit 868a9a67 authored by Andrew Fontaine's avatar Andrew Fontaine

Add Experiment Surrounding Environment Guidance

We want to be able to limit the amount of users who can see this alert
as a slow rollout to see if it is useful.

This experiment is only enabled for projects that don't have existing
environments, and we currently only track if the user clicks on the
Learn More link embedded in the alert.

As with all experiments, this is only applicable to GitLab.com
parent 4cf8a898
......@@ -19,7 +19,13 @@ export default {
<span>
<gl-sprintf :message="$options.message">
<template #link="{ content }">
<gl-link :href="helpLink" target="_blank">{{ content }}</gl-link>
<gl-link
:href="helpLink"
target="_blank"
data-track-action="click_link"
data-track-experiment="in_product_guidance_environments_webide"
>{{ content }}</gl-link
>
</template>
</gl-sprintf>
</span>
......
# frozen_string_literal: true
class InProductGuidanceEnvironmentsWebideExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
exclude :has_environments?
def control_behavior
false
end
private
def has_environments?
!context.project.environments.empty?
end
end
......@@ -18,7 +18,7 @@ module IdeHelper
'merge-request' => @merge_request,
'fork-info' => @fork_info&.to_json,
'project' => convert_to_project_entity_json(@project),
'enable-environments-guidance' => enable_environment_guidance?.to_s
'enable-environments-guidance' => enable_environments_guidance?.to_s
}
end
......@@ -30,8 +30,16 @@ module IdeHelper
API::Entities::Project.represent(project).to_json
end
def enable_environment_guidance?
current_user.find_or_initialize_callout(:web_ide_ci_environments_guidance).dismissed_at.nil?
def enable_environments_guidance?
experiment(:in_product_guidance_environments_webide, project: @project) do |e|
e.try { !has_dismissed_ide_environments_callout? }
e.run
end
end
def has_dismissed_ide_environments_callout?
current_user.dismissed_callout?(feature_name: 'web_ide_ci_environments_guidance')
end
end
......
---
name: in_product_guidance_environments_webide
introduced_by_url:
rollout_issue_url:
milestone: '13.12'
type: experiment
group: group::release
default_enabled: false
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe InProductGuidanceEnvironmentsWebideExperiment, :experiment do
subject { described_class.new(project: project) }
let(:project) { create(:project, :repository) }
before do
stub_experiments(in_product_guidance_environments_webide: :candidate)
end
it 'excludes projects with environments' do
create(:environment, project: project)
expect(subject).to exclude(project: project)
end
it 'does not exlude projects without environments' do
expect(subject).not_to exclude(project: project)
end
end
......@@ -45,5 +45,35 @@ RSpec.describe IdeHelper do
)
end
end
context 'environments guidance experiment', :experiment do
before do
stub_experiments(in_product_guidance_environments_webide: :candidate)
self.instance_variable_set(:@project, project)
end
context 'when project has no enviornments' do
it 'enables environment guidance' do
expect(helper.ide_data).to include('enable-environments-guidance' => 'true')
end
context 'and the callout has been dismissed' do
it 'disables environment guidance' do
callout = create(:user_callout, feature_name: :web_ide_ci_environments_guidance, user: project.creator)
callout.update!(dismissed_at: Time.now - 1.week)
allow(helper).to receive(:current_user).and_return(User.find(project.creator.id))
expect(helper.ide_data).to include('enable-environments-guidance' => 'false')
end
end
end
context 'when the project has environments' do
it 'disables environment guidance' do
create(:environment, project: project)
expect(helper.ide_data).to include('enable-environments-guidance' => 'false')
end
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