Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e96846a5
Commit
e96846a5
authored
Aug 20, 2021
by
Dallas Reedy
Committed by
Doug Stull
Aug 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tracking events for trial reassurance experiment
parent
c581d371
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
165 additions
and
29 deletions
+165
-29
ee/app/controllers/ee/registrations/welcome_controller.rb
ee/app/controllers/ee/registrations/welcome_controller.rb
+5
-0
ee/app/controllers/trial_registrations_controller.rb
ee/app/controllers/trial_registrations_controller.rb
+12
-0
ee/app/controllers/trials_controller.rb
ee/app/controllers/trials_controller.rb
+6
-0
ee/app/views/trial_registrations/new.html.haml
ee/app/views/trial_registrations/new.html.haml
+4
-1
ee/spec/controllers/registrations/welcome_controller_spec.rb
ee/spec/controllers/registrations/welcome_controller_spec.rb
+19
-0
ee/spec/controllers/trial_registrations_controller_spec.rb
ee/spec/controllers/trial_registrations_controller_spec.rb
+22
-2
ee/spec/controllers/trials_controller_spec.rb
ee/spec/controllers/trials_controller_spec.rb
+61
-10
ee/spec/views/trial_registrations/new.html.haml_spec.rb
ee/spec/views/trial_registrations/new.html.haml_spec.rb
+36
-16
No files found.
ee/app/controllers/ee/registrations/welcome_controller.rb
View file @
e96846a5
...
@@ -15,6 +15,11 @@ module EE
...
@@ -15,6 +15,11 @@ module EE
:trial_getting_started
,
:trial_getting_started
,
:trial_onboarding_board
:trial_onboarding_board
]
]
before_action
only: :show
do
experiment
(
:trial_registration_with_reassurance
,
actor:
current_user
)
.
track
(
:render
,
label:
'registrations:welcome:show'
,
user:
current_user
)
end
end
end
def
trial_getting_started
def
trial_getting_started
...
...
ee/app/controllers/trial_registrations_controller.rb
View file @
e96846a5
...
@@ -17,6 +17,18 @@ class TrialRegistrationsController < RegistrationsController
...
@@ -17,6 +17,18 @@ class TrialRegistrationsController < RegistrationsController
private
private
# This is called from within the RegistrationsController#create action and is
# given the newly created user.
def
after_request_hook
(
user
)
super
return
unless
user
.
persisted?
e
=
experiment
(
:trial_registration_with_reassurance
,
actor:
user
)
e
.
track
(
:create_user
,
label:
'trial_registrations:create'
,
user:
user
)
e
.
publish_to_database
end
def
set_redirect_url
def
set_redirect_url
target_url
=
new_trial_url
(
params:
request
.
query_parameters
)
target_url
=
new_trial_url
(
params:
request
.
query_parameters
)
...
...
ee/app/controllers/trials_controller.rb
View file @
e96846a5
...
@@ -16,10 +16,14 @@ class TrialsController < ApplicationController
...
@@ -16,10 +16,14 @@ class TrialsController < ApplicationController
feature_category
:purchase
feature_category
:purchase
def
new
def
new
experiment
(
:trial_registration_with_reassurance
,
actor:
current_user
)
.
track
(
:render
,
label:
'trials:new'
,
user:
current_user
)
record_experiment_user
(
:remove_known_trial_form_fields_welcoming
,
remove_known_trial_form_fields_context
)
record_experiment_user
(
:remove_known_trial_form_fields_welcoming
,
remove_known_trial_form_fields_context
)
end
end
def
select
def
select
experiment
(
:trial_registration_with_reassurance
,
actor:
current_user
)
.
track
(
:render
,
label:
'trials:select'
,
user:
current_user
)
end
end
def
create_lead
def
create_lead
...
@@ -44,6 +48,8 @@ class TrialsController < ApplicationController
...
@@ -44,6 +48,8 @@ class TrialsController < ApplicationController
record_experiment_user
(
:remove_known_trial_form_fields_welcoming
,
namespace_id:
@namespace
.
id
)
record_experiment_user
(
:remove_known_trial_form_fields_welcoming
,
namespace_id:
@namespace
.
id
)
record_experiment_conversion_event
(
:remove_known_trial_form_fields_welcoming
)
record_experiment_conversion_event
(
:remove_known_trial_form_fields_welcoming
)
experiment
(
:trial_registration_with_reassurance
,
actor:
current_user
)
.
track
(
:apply_trial
,
label:
'trials:apply'
,
namespace:
@namespace
,
user:
current_user
)
experiment
(
:force_company_trial
,
user:
current_user
).
track
(
:create_trial
,
namespace:
@namespace
,
user:
current_user
,
label:
'trials_controller'
)
if
@namespace
.
created_at
>
24
.
hours
.
ago
experiment
(
:force_company_trial
,
user:
current_user
).
track
(
:create_trial
,
namespace:
@namespace
,
user:
current_user
,
label:
'trials_controller'
)
if
@namespace
.
created_at
>
24
.
hours
.
ago
if
discover_group_security_flow?
if
discover_group_security_flow?
...
...
ee/app/views/trial_registrations/new.html.haml
View file @
e96846a5
...
@@ -15,7 +15,10 @@
...
@@ -15,7 +15,10 @@
=
render
'devise/shared/sign_in_link'
=
render
'devise/shared/sign_in_link'
.row
.row
-
experiment
(
:trial_registration_with_reassurance
)
do
|
e
|
-
experiment
(
:trial_registration_with_reassurance
,
actor:
current_user
)
do
|
e
|
-
if
e
.
should_track?
%span
{
data:
{
track_action: :render
,
track_experiment: :trial_registration_with_reassurance
}
}
-
e
.
use
do
-
e
.
use
do
.col-md-6.offset-md-3
.col-md-6.offset-md-3
%h2
.gl-text-center.gl-pb-5.gl-my-0
%h2
.gl-text-center.gl-pb-5.gl-my-0
...
...
ee/spec/controllers/registrations/welcome_controller_spec.rb
View file @
e96846a5
...
@@ -7,6 +7,25 @@ RSpec.describe Registrations::WelcomeController do
...
@@ -7,6 +7,25 @@ RSpec.describe Registrations::WelcomeController do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
describe
'#show'
do
context
'when the trial_registration_with_reassurance experiment is active'
,
:experiment
do
before
do
sign_in
(
user
)
stub_experiments
(
trial_registration_with_reassurance: :control
)
end
it
'tracks a "render" event'
do
expect
(
experiment
(
:trial_registration_with_reassurance
)).
to
track
(
:render
,
user:
user
,
label:
'registrations:welcome:show'
).
with_context
(
actor:
user
).
on_next_instance
get
:show
end
end
end
describe
'#continuous_onboarding_getting_started'
do
describe
'#continuous_onboarding_getting_started'
do
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
...
...
ee/spec/controllers/trial_registrations_controller_spec.rb
View file @
e96846a5
...
@@ -66,20 +66,40 @@ RSpec.describe TrialRegistrationsController do
...
@@ -66,20 +66,40 @@ RSpec.describe TrialRegistrationsController do
before
do
before
do
stub_application_setting
(
send_user_confirmation_email:
true
)
stub_application_setting
(
send_user_confirmation_email:
true
)
post
:create
,
params:
{
user:
user_params
}
end
end
subject
(
:post_create
)
{
post
:create
,
params:
{
user:
user_params
}
}
it_behaves_like
'a dot-com only feature'
do
it_behaves_like
'a dot-com only feature'
do
let
(
:success_status
)
{
:found
}
let
(
:success_status
)
{
:found
}
subject
{
response
}
end
end
it
'marks the account as unconfirmed'
do
it
'marks the account as unconfirmed'
do
post_create
expect
(
User
.
last
).
not_to
be_confirmed
expect
(
User
.
last
).
not_to
be_confirmed
end
end
context
'when the trial_registration_with_reassurance experiment is active'
,
:experiment
do
before
do
stub_experiments
(
trial_registration_with_reassurance: :control
)
end
it
'tracks a "create_user" event & records the actor to the database'
,
:aggregate_failures
do
expect
(
experiment
(
:trial_registration_with_reassurance
)).
to
track
(
:create_user
,
user:
an_instance_of
(
User
),
label:
'trial_registrations:create'
).
with_context
(
actor:
an_instance_of
(
User
)).
on_next_instance
expect
{
post_create
}.
to
change
{
ExperimentSubject
.
count
}
end
end
context
'derivation of name'
do
context
'derivation of name'
do
it
'sets name from first and last name'
do
it
'sets name from first and last name'
do
post_create
expect
(
User
.
last
.
name
).
to
eq
(
"
#{
user_params
[
:first_name
]
}
#{
user_params
[
:last_name
]
}
"
)
expect
(
User
.
last
.
name
).
to
eq
(
"
#{
user_params
[
:first_name
]
}
#{
user_params
[
:last_name
]
}
"
)
end
end
end
end
...
...
ee/spec/controllers/trials_controller_spec.rb
View file @
e96846a5
...
@@ -50,15 +50,31 @@ RSpec.describe TrialsController do
...
@@ -50,15 +50,31 @@ RSpec.describe TrialsController do
end
end
describe
'#new'
do
describe
'#new'
do
subject
do
subject
(
:get_new
)
do
get
:new
get
:new
response
response
end
end
context
'when the trial_registration_with_reassurance experiment is active'
,
:experiment
do
before
do
stub_experiments
(
trial_registration_with_reassurance: :control
)
end
it
'tracks a "render" event'
do
expect
(
experiment
(
:trial_registration_with_reassurance
)).
to
track
(
:render
,
user:
user
,
label:
'trials:new'
).
with_context
(
actor:
user
).
on_next_instance
get_new
end
end
it
'calls record_experiment_user for the experiments'
do
it
'calls record_experiment_user for the experiments'
do
expect
(
controller
).
to
receive
(
:record_experiment_user
).
with
(
:remove_known_trial_form_fields_welcoming
,
remove_known_trial_form_fields_context
)
expect
(
controller
).
to
receive
(
:record_experiment_user
).
with
(
:remove_known_trial_form_fields_welcoming
,
remove_known_trial_form_fields_context
)
subject
get_new
end
end
it_behaves_like
'an authenticated endpoint'
it_behaves_like
'an authenticated endpoint'
...
@@ -142,13 +158,29 @@ RSpec.describe TrialsController do
...
@@ -142,13 +158,29 @@ RSpec.describe TrialsController do
end
end
describe
'#select'
do
describe
'#select'
do
subject
do
subject
(
:get_select
)
do
get
:select
get
:select
response
response
end
end
it_behaves_like
'an authenticated endpoint'
it_behaves_like
'an authenticated endpoint'
it_behaves_like
'a dot-com only feature'
it_behaves_like
'a dot-com only feature'
context
'when the trial_registration_with_reassurance experiment is active'
,
:experiment
do
before
do
stub_experiments
(
trial_registration_with_reassurance: :control
)
end
it
'tracks a "render" event'
do
expect
(
experiment
(
:trial_registration_with_reassurance
)).
to
track
(
:render
,
user:
user
,
label:
'trials:select'
).
with_context
(
actor:
user
).
on_next_instance
get_select
end
end
end
end
describe
'#apply'
do
describe
'#apply'
do
...
@@ -163,9 +195,10 @@ RSpec.describe TrialsController do
...
@@ -163,9 +195,10 @@ RSpec.describe TrialsController do
allow_next_instance_of
(
GitlabSubscriptions
::
ApplyTrialService
)
do
|
service
|
allow_next_instance_of
(
GitlabSubscriptions
::
ApplyTrialService
)
do
|
service
|
allow
(
service
).
to
receive
(
:execute
).
and_return
({
success:
apply_trial_result
})
allow
(
service
).
to
receive
(
:execute
).
and_return
({
success:
apply_trial_result
})
end
end
allow
(
controller
).
to
receive
(
:experiment
).
and_call_original
end
end
subject
do
subject
(
:post_apply
)
do
post
:apply
,
params:
post_params
post
:apply
,
params:
post_params
response
response
end
end
...
@@ -177,12 +210,30 @@ RSpec.describe TrialsController do
...
@@ -177,12 +210,30 @@ RSpec.describe TrialsController do
let
(
:apply_trial_result
)
{
true
}
let
(
:apply_trial_result
)
{
true
}
it
{
is_expected
.
to
redirect_to
(
"/
#{
namespace
.
path
}
?trial=true"
)
}
it
{
is_expected
.
to
redirect_to
(
"/
#{
namespace
.
path
}
?trial=true"
)
}
it
'calls the record conversion method for the experiments'
do
it
'calls the record conversion method for the experiments'
do
expect
(
controller
).
to
receive
(
:record_experiment_user
).
with
(
:remove_known_trial_form_fields_welcoming
,
namespace_id:
namespace
.
id
)
expect
(
controller
).
to
receive
(
:record_experiment_user
).
with
(
:remove_known_trial_form_fields_welcoming
,
namespace_id:
namespace
.
id
)
expect
(
controller
).
to
receive
(
:record_experiment_conversion_event
).
with
(
:remove_known_trial_form_fields_welcoming
)
expect
(
controller
).
to
receive
(
:record_experiment_conversion_event
).
with
(
:remove_known_trial_form_fields_welcoming
)
expect
(
experiment
(
:force_company_trial
)).
to
track
(
:create_trial
,
namespace:
namespace
,
user:
user
,
label:
'trials_controller'
).
with_context
(
user:
user
).
on_next_instance
expect
(
experiment
(
:force_company_trial
)).
to
track
(
:create_trial
,
namespace:
namespace
,
user:
user
,
label:
'trials_controller'
).
with_context
(
user:
user
).
on_next_instance
subject
post_apply
end
context
'when the trial_registration_with_reassurance experiment is active'
,
:experiment
do
before
do
stub_experiments
(
trial_registration_with_reassurance: :control
)
end
it
'tracks an "apply_trial" event'
do
expect
(
experiment
(
:trial_registration_with_reassurance
)).
to
track
(
:apply_trial
,
user:
user
,
namespace:
namespace
,
label:
'trials:apply'
).
with_context
(
actor:
user
).
on_next_instance
post_apply
end
end
end
context
'redirect trial user to feature'
do
context
'redirect trial user to feature'
do
...
@@ -210,7 +261,7 @@ RSpec.describe TrialsController do
...
@@ -210,7 +261,7 @@ RSpec.describe TrialsController do
it
'records the subject'
do
it
'records the subject'
do
expect
(
Experiment
).
to
receive
(
:add_subject
).
with
(
'redirect_trial_user_to_feature'
,
variant:
variant
,
subject:
namespace
)
expect
(
Experiment
).
to
receive
(
:add_subject
).
with
(
'redirect_trial_user_to_feature'
,
variant:
variant
,
subject:
namespace
)
subject
post_apply
end
end
end
end
end
end
...
@@ -219,7 +270,7 @@ RSpec.describe TrialsController do
...
@@ -219,7 +270,7 @@ RSpec.describe TrialsController do
let
(
:post_params
)
{
{
new_group_name:
'GitLab'
}
}
let
(
:post_params
)
{
{
new_group_name:
'GitLab'
}
}
it
'creates the Group'
do
it
'creates the Group'
do
expect
{
subject
}.
to
change
{
Group
.
count
}.
by
(
1
)
expect
{
post_apply
}.
to
change
{
Group
.
count
}.
by
(
1
)
end
end
end
end
...
@@ -229,7 +280,7 @@ RSpec.describe TrialsController do
...
@@ -229,7 +280,7 @@ RSpec.describe TrialsController do
expect
(
controller
).
not_to
receive
(
:experiment
).
with
(
:force_company_trial
,
user:
user
)
expect
(
controller
).
not_to
receive
(
:experiment
).
with
(
:force_company_trial
,
user:
user
)
subject
post_apply
end
end
end
end
end
end
...
@@ -241,7 +292,7 @@ RSpec.describe TrialsController do
...
@@ -241,7 +292,7 @@ RSpec.describe TrialsController do
it
'does not call the record conversion method for the experiments'
do
it
'does not call the record conversion method for the experiments'
do
expect
(
controller
).
not_to
receive
(
:record_experiment_conversion_event
).
with
(
:remove_known_trial_form_fields_welcoming
)
expect
(
controller
).
not_to
receive
(
:record_experiment_conversion_event
).
with
(
:remove_known_trial_form_fields_welcoming
)
subject
post_apply
end
end
context
'with a new Group'
do
context
'with a new Group'
do
...
@@ -250,7 +301,7 @@ RSpec.describe TrialsController do
...
@@ -250,7 +301,7 @@ RSpec.describe TrialsController do
it
{
is_expected
.
to
render_template
(
:select
)
}
it
{
is_expected
.
to
render_template
(
:select
)
}
it
'does not create the Group'
do
it
'does not create the Group'
do
expect
{
subject
}.
not_to
change
{
Group
.
count
}
expect
{
post_apply
}.
not_to
change
{
Group
.
count
}
end
end
end
end
end
end
...
...
ee/spec/views/trial_registrations/new.html.haml_spec.rb
View file @
e96846a5
...
@@ -12,27 +12,47 @@ RSpec.describe 'trial_registrations/new.html.haml' do
...
@@ -12,27 +12,47 @@ RSpec.describe 'trial_registrations/new.html.haml' do
subject
{
render
&&
rendered
}
subject
{
render
&&
rendered
}
describe
'trial_registration_with_reassurance experiment'
do
describe
'trial_registration_with_reassurance experiment'
,
:experiment
do
before
do
context
'when the experiment is enabled'
do
stub_experiments
(
trial_registration_with_reassurance:
trial_registration_with_reassurance_variant
)
let
(
:variant
)
{
:control
}
before
do
stub_experiments
(
trial_registration_with_reassurance:
variant
)
end
context
'when in the control'
do
it
{
is_expected
.
to
have_content
(
'Start a Free Ultimate Trial'
)
}
it
{
is_expected
.
not_to
have_content
(
'Free 30-day trial'
)
}
it
{
is_expected
.
not_to
have_content
(
'No credit card required.'
)
}
it
{
is_expected
.
not_to
have_selector
(
'img[alt$=" logo"]'
)
}
end
context
'when in the candidate'
do
let
(
:variant
)
{
:candidate
}
it
{
is_expected
.
not_to
have_content
(
'Start a Free Ultimate Trial'
)
}
it
{
is_expected
.
to
have_content
(
'Free 30-day trial'
)
}
it
{
is_expected
.
to
have_content
(
'No credit card required.'
)
}
it
{
is_expected
.
to
have_selector
(
'img[alt$=" logo"]'
)
}
end
end
end
context
'when in the control'
do
describe
'tracking page-render using a frontend event'
do
let_it_be
(
:trial_registration_with_reassurance_variant
)
{
:control
}
context
'when the experiment should be tracked, like when it is enabled'
do
before
do
stub_experiments
(
trial_registration_with_reassurance: :control
)
end
it
{
is_expected
.
to
have_content
(
'Start a Free Ultimate Trial'
)
}
it
{
is_expected
.
to
have_selector
(
'span[data-track-action="render"]'
)
}
it
{
is_expected
.
not_to
have_content
(
'Free 30-day trial'
)
}
end
it
{
is_expected
.
not_to
have_content
(
'No credit card required.'
)
}
it
{
is_expected
.
not_to
have_selector
(
'img[alt$=" logo"]'
)
}
end
context
'when in the candidate'
do
context
'when the experiment should not be tracked, like when it is disabled'
do
let_it_be
(
:trial_registration_with_reassurance_variant
)
{
:candidate
}
before
do
stub_feature_flags
(
trial_registration_with_reassurance:
false
)
end
it
{
is_expected
.
not_to
have_content
(
'Start a Free Ultimate Trial'
)
}
it
{
is_expected
.
not_to
have_selector
(
'span[data-track-action="render"]'
)
}
it
{
is_expected
.
to
have_content
(
'Free 30-day trial'
)
}
end
it
{
is_expected
.
to
have_content
(
'No credit card required.'
)
}
it
{
is_expected
.
to
have_selector
(
'img[alt$=" logo"]'
)
}
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment