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
0b1ed7c4
Commit
0b1ed7c4
authored
Sep 23, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track the sent and accepted events
For the invitation reminders experiment
parent
f327577b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
6 deletions
+99
-6
app/controllers/invites_controller.rb
app/controllers/invites_controller.rb
+17
-4
app/mailers/emails/members.rb
app/mailers/emails/members.rb
+9
-0
spec/controllers/invites_controller_spec.rb
spec/controllers/invites_controller_spec.rb
+39
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+34
-2
No files found.
app/controllers/invites_controller.rb
View file @
0b1ed7c4
...
...
@@ -13,13 +13,14 @@ class InvitesController < ApplicationController
respond_to
:html
def
show
track_experiment
(
'opened'
)
track_
new_user_invite_
experiment
(
'opened'
)
accept
if
skip_invitation_prompt?
end
def
accept
if
member
.
accept_invite!
(
current_user
)
track_experiment
(
'accepted'
)
track_new_user_invite_experiment
(
'accepted'
)
track_invitation_reminders_experiment
(
'accepted'
)
redirect_to
invite_details
[
:path
],
notice:
_
(
"You have been granted %{member_human_access} access to %{title} %{name}."
)
%
{
member_human_access:
member
.
human_access
,
title:
invite_details
[
:title
],
name:
invite_details
[
:name
]
}
else
...
...
@@ -105,13 +106,25 @@ class InvitesController < ApplicationController
end
end
def
track_experiment
(
action
)
def
track_
new_user_invite_
experiment
(
action
)
return
unless
params
[
:new_user_invite
]
property
=
params
[
:new_user_invite
]
==
'experiment'
?
'experiment_group'
:
'control_group'
track_experiment
(
:invite_email
,
action
,
property
)
end
def
track_invitation_reminders_experiment
(
action
)
return
unless
Gitlab
::
Experimentation
.
enabled?
(
:invitation_reminders
)
property
=
Gitlab
::
Experimentation
.
enabled_for_attribute?
(
:invitation_reminders
,
member
.
invite_email
)
?
'experimental_group'
:
'control_group'
track_experiment
(
:invitation_reminders
,
action
,
property
)
end
def
track_experiment
(
experiment_key
,
action
,
property
)
Gitlab
::
Tracking
.
event
(
Gitlab
::
Experimentation
::
EXPERIMENTS
[
:invite_email
][
:tracking_category
]
,
Gitlab
::
Experimentation
.
experiment
(
experiment_key
).
tracking_category
,
action
,
property:
property
,
label:
Digest
::
MD5
.
hexdigest
(
member
.
to_global_id
.
to_s
)
...
...
app/mailers/emails/members.rb
View file @
0b1ed7c4
...
...
@@ -77,6 +77,15 @@ module Emails
Gitlab
::
Tracking
.
event
(
Gitlab
::
Experimentation
::
EXPERIMENTS
[
:invite_email
][
:tracking_category
],
'sent'
,
property:
'control_group'
)
end
end
if
member
.
invite_to_unknown_user?
&&
Gitlab
::
Experimentation
.
enabled?
(
:invitation_reminders
)
Gitlab
::
Tracking
.
event
(
Gitlab
::
Experimentation
.
experiment
(
:invitation_reminders
).
tracking_category
,
'sent'
,
property:
Gitlab
::
Experimentation
.
enabled_for_attribute?
(
:invitation_reminders
,
member
.
invite_email
)
?
'experimental_group'
:
'control_group'
,
label:
Digest
::
MD5
.
hexdigest
(
member
.
to_global_id
.
to_s
)
)
end
end
def
member_invite_accepted_email
(
member_source_type
,
member_id
)
...
...
spec/controllers/invites_controller_spec.rb
View file @
0b1ed7c4
...
...
@@ -29,6 +29,43 @@ RSpec.describe InvitesController, :snowplow do
end
end
shared_examples
"tracks the 'accepted' event for the invitation reminders experiment"
do
before
do
stub_experiment
(
invitation_reminders:
true
)
allow
(
Gitlab
::
Experimentation
).
to
receive
(
:enabled_for_attribute?
).
with
(
:invitation_reminders
,
member
.
invite_email
).
and_return
(
experimental_group
)
end
context
'when in the control group'
do
let
(
:experimental_group
)
{
false
}
it
"tracks the 'accepted' event"
do
request
expect_snowplow_event
(
category:
'Growth::Acquisition::Experiment::InvitationReminders'
,
label:
md5_member_global_id
,
property:
'control_group'
,
action:
'accepted'
)
end
end
context
'when in the experimental group'
do
let
(
:experimental_group
)
{
true
}
it
"tracks the 'accepted' event"
do
request
expect_snowplow_event
(
category:
'Growth::Acquisition::Experiment::InvitationReminders'
,
label:
md5_member_global_id
,
property:
'experimental_group'
,
action:
'accepted'
)
end
end
end
describe
'GET #show'
do
subject
(
:request
)
{
get
:show
,
params:
params
}
...
...
@@ -89,6 +126,7 @@ RSpec.describe InvitesController, :snowplow do
end
end
it_behaves_like
"tracks the 'accepted' event for the invitation reminders experiment"
it_behaves_like
'invalid token'
end
...
...
@@ -150,6 +188,7 @@ RSpec.describe InvitesController, :snowplow do
end
end
it_behaves_like
"tracks the 'accepted' event for the invitation reminders experiment"
it_behaves_like
'invalid token'
end
...
...
spec/mailers/notify_spec.rb
View file @
0b1ed7c4
...
...
@@ -1508,12 +1508,44 @@ RSpec.describe Notify do
)
end
describe
'
group invitation
'
do
describe
'
invitations
'
do
let
(
:owner
)
{
create
(
:user
).
tap
{
|
u
|
group
.
add_user
(
u
,
Gitlab
::
Access
::
OWNER
)
}
}
let
(
:group_member
)
{
invite_to_group
(
group
,
inviter:
inviter
)
}
let
(
:inviter
)
{
owner
}
subject
{
described_class
.
member_invited_email
(
'group'
,
group_member
.
id
,
group_member
.
invite_token
)
}
subject
{
described_class
.
member_invited_email
(
'Group'
,
group_member
.
id
,
group_member
.
invite_token
)
}
shared_examples
"tracks the 'sent' event for the invitation reminders experiment"
do
before
do
stub_experiment
(
invitation_reminders:
true
)
allow
(
Gitlab
::
Experimentation
).
to
receive
(
:enabled_for_attribute?
).
with
(
:invitation_reminders
,
group_member
.
invite_email
).
and_return
(
experimental_group
)
end
it
"tracks the 'sent' event"
,
:snowplow
do
subject
.
deliver_now
expect_snowplow_event
(
category:
'Growth::Acquisition::Experiment::InvitationReminders'
,
label:
Digest
::
MD5
.
hexdigest
(
group_member
.
to_global_id
.
to_s
),
property:
experimental_group
?
'experimental_group'
:
'control_group'
,
action:
'sent'
)
end
end
describe
'tracking for the invitation reminders experiment'
do
context
'when invite email is in the experimental group'
do
let
(
:experimental_group
)
{
true
}
it_behaves_like
"tracks the 'sent' event for the invitation reminders experiment"
end
context
'when invite email is in the control group'
do
let
(
:experimental_group
)
{
false
}
it_behaves_like
"tracks the 'sent' event for the invitation reminders experiment"
end
end
context
'when invite_email_experiment is disabled'
do
before
do
...
...
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