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
e620feb8
Commit
e620feb8
authored
Dec 10, 2020
by
Alper Akgun
Committed by
Robert Speicher
Dec 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add social sign up options to trial registration page
Growth conversion experiment to test Google and Github Sign ons
parent
9a0c3b92
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
117 additions
and
16 deletions
+117
-16
app/helpers/auth_helper.rb
app/helpers/auth_helper.rb
+4
-0
app/views/devise/shared/_signup_box.html.haml
app/views/devise/shared/_signup_box.html.haml
+6
-1
app/views/devise/shared/_signup_omniauth_provider_list.haml
app/views/devise/shared/_signup_omniauth_provider_list.haml
+9
-0
app/views/devise/shared/_signup_omniauth_providers.haml
app/views/devise/shared/_signup_omniauth_providers.haml
+1
-11
app/views/devise/shared/_signup_omniauth_providers_top.haml
app/views/devise/shared/_signup_omniauth_providers_top.haml
+3
-0
ee/app/controllers/trials_controller.rb
ee/app/controllers/trials_controller.rb
+12
-0
ee/app/helpers/ee/trial_registration_helper.rb
ee/app/helpers/ee/trial_registration_helper.rb
+13
-0
ee/app/views/trial_registrations/new.html.haml
ee/app/views/trial_registrations/new.html.haml
+6
-1
ee/spec/controllers/trials_controller_spec.rb
ee/spec/controllers/trials_controller_spec.rb
+13
-3
ee/spec/helpers/ee/trial_registration_helper_spec.rb
ee/spec/helpers/ee/trial_registration_helper_spec.rb
+31
-0
lib/gitlab/experimentation.rb
lib/gitlab/experimentation.rb
+3
-0
spec/helpers/auth_helper_spec.rb
spec/helpers/auth_helper_spec.rb
+16
-0
No files found.
app/helpers/auth_helper.rb
View file @
e620feb8
...
...
@@ -113,6 +113,10 @@ module AuthHelper
end
end
def
experiment_enabled_button_based_providers
enabled_button_based_providers
&
%w(google_oauth2 github)
.
freeze
end
def
button_based_providers_enabled?
enabled_button_based_providers
.
any?
end
...
...
app/views/devise/shared/_signup_box.html.haml
View file @
e620feb8
-
max_first_name_length
=
max_last_name_length
=
127
-
max_username_length
=
255
-
min_username_length
=
2
-
omniauth_providers_placement
||=
:bottom
.gl-mb-3.gl-p-4.gl-border-gray-100.gl-border-1.gl-border-solid.gl-rounded-base
-
if
show_omniauth_providers
&&
omniauth_providers_placement
==
:top
=
render
'devise/shared/signup_omniauth_providers_top'
=
form_for
(
resource
,
as:
"new_
#{
resource_name
}
"
,
url:
url
,
html:
{
class:
'new_user gl-show-field-errors'
,
'aria-live'
=>
'assertive'
})
do
|
f
|
.devise-errors
=
render
'devise/shared/error_messages'
,
resource:
resource
...
...
@@ -33,5 +38,5 @@
.submit-container
=
f
.
submit
button_text
,
class:
'btn gl-button btn-success'
,
data:
{
qa_selector:
'new_user_register_button'
}
=
render
'devise/shared/terms_of_service_notice'
-
if
show_omniauth_providers
-
if
show_omniauth_providers
&&
omniauth_providers_placement
==
:bottom
=
render
'devise/shared/signup_omniauth_providers'
app/views/devise/shared/_signup_omniauth_provider_list.haml
0 → 100644
View file @
e620feb8
%label
.label-bold.d-block
=
_
(
"Create an account using:"
)
.d-flex.justify-content-between.flex-wrap
-
providers
.
each
do
|
provider
|
=
link_to
omniauth_authorize_path
(
:user
,
provider
),
method: :post
,
class:
"btn gl-button gl-display-flex gl-align-items-center gl-text-left gl-mb-2 gl-p-2 omniauth-btn oauth-login
#{
qa_class_for_provider
(
provider
)
}
"
,
id:
"oauth-login-
#{
provider
}
"
do
-
if
provider_has_icon?
(
provider
)
=
provider_image_tag
(
provider
)
%span
.ml-2
=
label_for_provider
(
provider
)
app/views/devise/shared/_signup_omniauth_providers.haml
View file @
e620feb8
.omniauth-divider.d-flex.align-items-center.text-center
=
_
(
"or"
)
%label
.label-bold.d-block
=
_
(
"Create an account using:"
)
-
providers
=
enabled_button_based_providers
.d-flex.justify-content-between.flex-wrap
-
providers
.
each
do
|
provider
|
-
has_icon
=
provider_has_icon?
(
provider
)
=
link_to
omniauth_authorize_path
(
:user
,
provider
),
method: :post
,
class:
"gl-button btn d-flex align-items-center omniauth-btn text-left oauth-login mb-2 p-2
#{
qa_class_for_provider
(
provider
)
}
"
,
id:
"oauth-login-
#{
provider
}
"
do
-
if
has_icon
=
provider_image_tag
(
provider
)
%span
.ml-2
=
label_for_provider
(
provider
)
=
render
'devise/shared/signup_omniauth_provider_list'
,
providers:
enabled_button_based_providers
app/views/devise/shared/_signup_omniauth_providers_top.haml
0 → 100644
View file @
e620feb8
=
render
'devise/shared/signup_omniauth_provider_list'
,
providers:
experiment_enabled_button_based_providers
.omniauth-divider.d-flex.align-items-center.text-center
=
_
(
"or"
)
ee/app/controllers/trials_controller.rb
View file @
e620feb8
...
...
@@ -15,6 +15,7 @@ class TrialsController < ApplicationController
def
new
record_experiment_user
(
:remove_known_trial_form_fields
,
remove_known_trial_form_fields_context
)
record_experiment_user
(
:trimmed_skip_trial_copy
)
record_experiment_user
(
:trial_registration_with_social_signin
,
trial_registration_with_social_signin_context
)
end
def
select
...
...
@@ -38,6 +39,8 @@ class TrialsController < ApplicationController
if
@result
&
.
dig
(
:success
)
record_experiment_conversion_event
(
:remove_known_trial_form_fields
)
record_experiment_conversion_event
(
:trimmed_skip_trial_copy
)
record_experiment_conversion_event
(
:trial_registration_with_social_signin
)
redirect_to
group_url
(
@namespace
,
{
trial:
true
})
else
render
:select
...
...
@@ -123,4 +126,13 @@ class TrialsController < ApplicationController
company_name_present:
current_user
.
organization
.
present?
}
end
def
trial_registration_with_social_signin_context
identities
=
current_user
.
identities
.
map
(
&
:provider
)
{
google_signon:
identities
.
include?
(
'google_oauth2'
),
github_signon:
identities
.
include?
(
'github'
)
}
end
end
ee/app/helpers/ee/trial_registration_helper.rb
0 → 100644
View file @
e620feb8
# frozen_string_literal: true
module
EE
module
TrialRegistrationHelper
def
social_signin_experiment_enabled?
::
Gitlab
.
com?
&&
omniauth_enabled?
&&
devise_mapping
.
omniauthable?
&&
button_based_providers_enabled?
&&
experiment_enabled?
(
:trial_registration_with_social_signin
)
end
end
end
ee/app/views/trial_registrations/new.html.haml
View file @
e620feb8
...
...
@@ -8,5 +8,10 @@
=
_
(
'Start a Free Gold Trial'
)
.signup-page
=
render
'devise/shared/signup_box'
,
url:
trial_registrations_path
,
button_text:
_
(
'Continue'
),
show_omniauth_providers:
false
=
render
'devise/shared/signup_box'
,
url:
trial_registrations_path
,
button_text:
_
(
'Continue'
),
show_omniauth_providers:
social_signin_experiment_enabled?
,
omniauth_providers_placement: :top
=
render
'devise/shared/sign_in_link'
ee/spec/controllers/trials_controller_spec.rb
View file @
e620feb8
...
...
@@ -12,6 +12,13 @@ RSpec.describe TrialsController do
}
end
let_it_be
(
:trial_registration_with_social_signin_context
)
do
{
google_signon:
user
.
identities
.
select
{
|
id
|
id
.
provider
==
'google_auth2'
}.
present?
,
github_signon:
user
.
identities
.
select
{
|
id
|
id
.
provider
==
'github'
}.
present?
}
end
let
(
:dev_env_or_com
)
{
true
}
let
(
:logged_in
)
{
true
}
...
...
@@ -54,9 +61,10 @@ RSpec.describe TrialsController do
response
end
it
'calls record_experiment_user for the
remove_known_trial_form_fields & trimmed_skip_trial_copy
experiments'
do
it
'calls record_experiment_user for the experiments'
do
expect
(
controller
).
to
receive
(
:record_experiment_user
).
with
(
:remove_known_trial_form_fields
,
remove_known_trial_form_fields_context
)
expect
(
controller
).
to
receive
(
:record_experiment_user
).
with
(
:trimmed_skip_trial_copy
)
expect
(
controller
).
to
receive
(
:record_experiment_user
).
with
(
:trial_registration_with_social_signin
,
trial_registration_with_social_signin_context
)
subject
end
...
...
@@ -197,9 +205,10 @@ RSpec.describe TrialsController do
let
(
:apply_trial_result
)
{
true
}
it
{
is_expected
.
to
redirect_to
(
"/
#{
namespace
.
path
}
?trial=true"
)
}
it
'calls the record conversion method for the
remove_known_trial_form_fields & trimmed_skip_trial_copy
experiments'
do
it
'calls the record conversion method for the experiments'
do
expect
(
controller
).
to
receive
(
:record_experiment_conversion_event
).
with
(
:remove_known_trial_form_fields
)
expect
(
controller
).
to
receive
(
:record_experiment_conversion_event
).
with
(
:trimmed_skip_trial_copy
)
expect
(
controller
).
to
receive
(
:record_experiment_conversion_event
).
with
(
:trial_registration_with_social_signin
)
subject
end
...
...
@@ -217,9 +226,10 @@ RSpec.describe TrialsController do
let
(
:apply_trial_result
)
{
false
}
it
{
is_expected
.
to
render_template
(
:select
)
}
it
'does not call the record conversion method for the
remove_known_trial_form_fields & trimmed_skip_trial_copy
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
)
expect
(
controller
).
not_to
receive
(
:record_experiment_conversion_event
).
with
(
:trimmed_skip_trial_copy
)
expect
(
controller
).
not_to
receive
(
:record_experiment_conversion_event
).
with
(
:trial_registration_with_social_signin
)
subject
end
...
...
ee/spec/helpers/ee/trial_registration_helper_spec.rb
0 → 100644
View file @
e620feb8
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
EE
::
TrialRegistrationHelper
do
using
RSpec
::
Parameterized
::
TableSyntax
describe
'#social_signin_experiment_enabled?'
do
before
do
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
com
)
allow
(
view
).
to
receive
(
:omniauth_enabled?
).
and_return
(
omniauth_enabled
)
allow
(
view
).
to
receive
(
:button_based_providers_enabled?
).
and_return
(
button_based_providers_enabled
)
allow
(
view
).
to
receive
(
:experiment_enabled?
).
with
(
:trial_registration_with_social_signin
).
and_return
(
experiment_enabled
)
allow
(
view
).
to
receive
(
:devise_mapping
).
and_return
(
double
(
omniauthable?:
omniauthable
))
end
subject
{
helper
.
social_signin_experiment_enabled?
}
where
com:
[
true
,
false
],
omniauth_enabled:
[
true
,
false
],
omniauthable:
[
true
,
false
],
button_based_providers_enabled:
[
true
,
false
],
experiment_enabled:
[
true
,
false
]
with_them
do
let
(
:result
)
{
com
&&
omniauth_enabled
&&
button_based_providers_enabled
&&
experiment_enabled
&&
omniauthable
}
it
{
is_expected
.
to
eq
(
result
)
}
end
end
end
lib/gitlab/experimentation.rb
View file @
e620feb8
...
...
@@ -81,6 +81,9 @@ module Gitlab
},
trimmed_skip_trial_copy:
{
tracking_category:
'Growth::Conversion::Experiment::TrimmedSkipTrialCopy'
},
trial_registration_with_social_signin:
{
tracking_category:
'Growth::Conversion::Experiment::TrialRegistrationWithSocialSigning'
}
}.
freeze
...
...
spec/helpers/auth_helper_spec.rb
View file @
e620feb8
...
...
@@ -99,6 +99,22 @@ RSpec.describe AuthHelper do
end
end
describe
'experiment_enabled_button_based_providers'
do
it
'returns the intersection set of github & google_oauth2 with enabled providers'
do
allow
(
helper
).
to
receive
(
:enabled_button_based_providers
)
{
%w(twitter github google_oauth2)
}
expect
(
helper
.
experiment_enabled_button_based_providers
).
to
eq
(
%w(github google_oauth2)
)
allow
(
helper
).
to
receive
(
:enabled_button_based_providers
)
{
%w(google_oauth2 bitbucket)
}
expect
(
helper
.
experiment_enabled_button_based_providers
).
to
eq
(
%w(google_oauth2)
)
allow
(
helper
).
to
receive
(
:enabled_button_based_providers
)
{
%w(bitbucket)
}
expect
(
helper
.
experiment_enabled_button_based_providers
).
to
be_empty
end
end
describe
'button_based_providers_enabled?'
do
before
do
allow
(
helper
).
to
receive
(
:auth_providers
)
{
[
:twitter
,
:github
]
}
...
...
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