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
4898697d
Commit
4898697d
authored
Jan 25, 2022
by
Eugie Limpin
Committed by
Markus Koller
Jan 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track events for logged_out_marketing_header experiment
parent
95f81a81
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
3 deletions
+74
-3
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+9
-0
app/services/groups/create_service.rb
app/services/groups/create_service.rb
+11
-0
app/views/layouts/header/_default.html.haml
app/views/layouts/header/_default.html.haml
+3
-3
spec/controllers/registrations_controller_spec.rb
spec/controllers/registrations_controller_spec.rb
+22
-0
spec/services/groups/create_service_spec.rb
spec/services/groups/create_service_spec.rb
+29
-0
No files found.
app/controllers/registrations_controller.rb
View file @
4898697d
...
...
@@ -35,6 +35,7 @@ class RegistrationsController < Devise::RegistrationsController
persist_accepted_terms_if_required
(
new_user
)
set_role_required
(
new_user
)
track_experiment_event
(
new_user
)
if
pending_approval?
NotificationService
.
new
.
new_instance_access_request
(
new_user
)
...
...
@@ -223,6 +224,14 @@ class RegistrationsController < Devise::RegistrationsController
def
context_user
current_user
end
def
track_experiment_event
(
new_user
)
# Track signed up event to relate it with click "Sign up" button events from
# the experimental logged out header with marketing links. This allows us to
# have a funnel of visitors clicking on the header and those visitors
# signing up and becoming users
experiment
(
:logged_out_marketing_header
,
actor:
new_user
).
track
(
:signed_up
)
if
new_user
.
persisted?
end
end
RegistrationsController
.
prepend_mod_with
(
'RegistrationsController'
)
app/services/groups/create_service.rb
View file @
4898697d
...
...
@@ -61,6 +61,8 @@ module Groups
delay
=
Namespaces
::
InviteTeamEmailService
::
DELIVERY_DELAY_IN_MINUTES
Namespaces
::
InviteTeamEmailWorker
.
perform_in
(
delay
,
group
.
id
,
current_user
.
id
)
end
track_experiment_event
end
def
remove_unallowed_params
...
...
@@ -112,6 +114,15 @@ module Groups
@group
.
shared_runners_enabled
=
@group
.
parent
.
shared_runners_enabled
@group
.
allow_descendants_override_disabled_shared_runners
=
@group
.
parent
.
allow_descendants_override_disabled_shared_runners
end
def
track_experiment_event
return
unless
group
.
persisted?
# Track namespace created events to relate them with signed up events for
# the same experiment. This will let us associate created namespaces to
# users that signed up from the experimental logged out header.
experiment
(
:logged_out_marketing_header
,
actor:
current_user
).
track
(
:namespace_created
,
namespace:
group
)
end
end
end
...
...
app/views/layouts/header/_default.html.haml
View file @
4898697d
...
...
@@ -139,15 +139,15 @@
-
experiment
(
:logged_out_marketing_header
,
actor:
nil
)
do
|
e
|
-
e
.
candidate
do
%li
.nav-item.gl-display-none.gl-sm-display-block
=
link_to
_
(
'Sign up now'
),
new_user_registration_path
,
class:
'gl-button btn btn-default btn-sign-in'
=
link_to
_
(
'Sign up now'
),
new_user_registration_path
,
class:
'gl-button btn btn-default btn-sign-in'
,
data:
{
track_action:
'click_button'
,
track_experiment:
e
.
name
,
track_label:
'sign_up_now'
}
%li
.nav-item.gl-display-none.gl-sm-display-block
=
link_to
_
(
'Login'
),
new_session_path
(
:user
,
redirect_to_referer:
'yes'
)
=
render
'layouts/header/sign_in_register_button'
,
class:
'gl-sm-display-none'
-
e
.
try
(
:trial_focused
)
do
%li
.nav-item.gl-display-none.gl-sm-display-block
=
link_to
_
(
'Get a free trial'
),
'https://about.gitlab.com/free-trial/'
,
class:
'gl-button btn btn-default btn-sign-in'
=
link_to
_
(
'Get a free trial'
),
'https://about.gitlab.com/free-trial/'
,
class:
'gl-button btn btn-default btn-sign-in'
,
data:
{
track_action:
'click_button'
,
track_experiment:
e
.
name
,
track_label:
'get_a_free_trial'
}
%li
.nav-item.gl-display-none.gl-sm-display-block
=
link_to
_
(
'Sign up'
),
new_user_registration_path
=
link_to
_
(
'Sign up'
),
new_user_registration_path
,
data:
{
track_action:
'click_button'
,
track_experiment:
e
.
name
,
track_label:
'sign_up'
}
%li
.nav-item.gl-display-none.gl-sm-display-block
=
link_to
_
(
'Login'
),
new_session_path
(
:user
,
redirect_to_referer:
'yes'
)
=
render
'layouts/header/sign_in_register_button'
,
class:
'gl-sm-display-none'
...
...
spec/controllers/registrations_controller_spec.rb
View file @
4898697d
...
...
@@ -456,6 +456,28 @@ RSpec.describe RegistrationsController do
subject
end
describe
'logged_out_marketing_header experiment'
,
:experiment
do
before
do
stub_experiments
(
logged_out_marketing_header: :candidate
)
end
it
'tracks signed_up event'
do
expect
(
experiment
(
:logged_out_marketing_header
)).
to
track
(
:signed_up
).
on_next_instance
subject
end
context
'when registration fails'
do
let_it_be
(
:user_params
)
{
{
user:
base_user_params
.
merge
({
username:
''
})
}
}
it
'does not track signed_up event'
do
expect
(
experiment
(
:logged_out_marketing_header
)).
not_to
track
(
:signed_up
)
subject
end
end
end
end
describe
'#destroy'
do
...
...
spec/services/groups/create_service_spec.rb
View file @
4898697d
...
...
@@ -289,4 +289,33 @@ RSpec.describe Groups::CreateService, '#execute' do
end
end
end
describe
'logged_out_marketing_header experiment'
,
:experiment
do
let
(
:service
)
{
described_class
.
new
(
user
,
group_params
)
}
subject
{
service
.
execute
}
before
do
stub_experiments
(
logged_out_marketing_header: :candidate
)
end
it
'tracks signed_up event'
do
expect
(
experiment
(
:logged_out_marketing_header
)).
to
track
(
:namespace_created
,
namespace:
an_instance_of
(
Group
)
).
on_next_instance
.
with_context
(
actor:
user
)
subject
end
context
'when group has not been persisted'
do
let
(
:service
)
{
described_class
.
new
(
user
,
group_params
.
merge
(
name:
'<script>alert("Attack!")</script>'
))
}
it
'does not track signed_up event'
do
expect
(
experiment
(
:logged_out_marketing_header
)).
not_to
track
(
:namespace_created
)
subject
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