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
091de7cb
Commit
091de7cb
authored
Aug 20, 2020
by
Dallas Reedy
Committed by
Kamil Trzciński
Aug 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track clicks of the “Contact sales” & “Upgrade” buttons
parent
4ec05df7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
6 deletions
+70
-6
ee/app/helpers/billing_plans_helper.rb
ee/app/helpers/billing_plans_helper.rb
+12
-0
ee/app/views/shared/billings/_billing_plan.html.haml
ee/app/views/shared/billings/_billing_plan.html.haml
+2
-2
ee/spec/helpers/billing_plans_helper_spec.rb
ee/spec/helpers/billing_plans_helper_spec.rb
+33
-0
lib/gitlab/experimentation.rb
lib/gitlab/experimentation.rb
+10
-4
spec/lib/gitlab/experimentation_spec.rb
spec/lib/gitlab/experimentation_spec.rb
+13
-0
No files found.
ee/app/helpers/billing_plans_helper.rb
View file @
091de7cb
...
...
@@ -31,6 +31,18 @@ module BillingPlansHelper
purchase_link_action
==
'upgrade'
end
def
experiment_tracking_data_for_button_click
(
button_label
)
return
{}
unless
Gitlab
::
Experimentation
.
enabled?
(
:contact_sales_btn_in_app
)
{
track:
{
event:
'click_button'
,
label:
button_label
,
property:
experiment_tracking_category_and_group
(
:contact_sales_btn_in_app
)
}
}
end
def
plan_feature_short_list
(
plan
)
return
[]
unless
plan
.
features
...
...
ee/app/views/shared/billings/_billing_plan.html.haml
View file @
091de7cb
...
...
@@ -35,7 +35,7 @@
.card-footer.p-3
.float-right
{
class:
(
"invisible"
unless
purchase_link
.
action
==
'upgrade'
||
is_current_plan
)
}
-
if
show_contact_sales_button?
(
purchase_link
.
action
)
=
link_to
s_
(
'BillingPlan|Contact sales'
),
"
#{
contact_sales_url
}
?test=inappcontactsales
#{
plan
.
code
}
"
,
class:
"btn btn-success btn-inverted"
=
link_to
s_
(
'BillingPlan|Contact sales'
),
"
#{
contact_sales_url
}
?test=inappcontactsales
#{
plan
.
code
}
"
,
class:
"btn btn-success btn-inverted"
,
data:
{
**
experiment_tracking_data_for_button_click
(
'contact_sales'
)
}
-
upgrade_button_class
=
"disabled"
if
is_current_plan
&&
!
namespace
.
trial_active?
-
cta_class
=
'-new'
if
use_new_purchase_flow?
(
namespace
)
=
link_to
s_
(
'BillingPlan|Upgrade'
),
plan_purchase_or_upgrade_url
(
namespace
,
plan
,
current_plan
),
class:
"btn btn-success
#{
upgrade_button_class
}
billing-cta-purchase
#{
cta_class
}
"
=
link_to
s_
(
'BillingPlan|Upgrade'
),
plan_purchase_or_upgrade_url
(
namespace
,
plan
,
current_plan
),
class:
"btn btn-success
#{
upgrade_button_class
}
billing-cta-purchase
#{
cta_class
}
"
,
data:
{
**
experiment_tracking_data_for_button_click
(
'upgrade'
)
}
ee/spec/helpers/billing_plans_helper_spec.rb
View file @
091de7cb
...
...
@@ -94,4 +94,37 @@ RSpec.describe BillingPlansHelper do
it
{
is_expected
.
to
eq
(
result
)
}
end
end
describe
'#experiment_tracking_data_for_button_click'
do
let
(
:button_label
)
{
'some_label'
}
let
(
:experiment_enabled
)
{
false
}
subject
{
helper
.
experiment_tracking_data_for_button_click
(
button_label
)
}
before
do
stub_experiment
(
contact_sales_btn_in_app:
experiment_enabled
)
end
context
'when the experiment is not enabled'
do
it
{
is_expected
.
to
eq
({})
}
end
context
'when the experiment is enabled'
do
let
(
:experiment_enabled
)
{
true
}
before
do
allow
(
helper
).
to
receive
(
:experiment_tracking_category_and_group
).
with
(
:contact_sales_btn_in_app
).
and_return
(
"Category:control_group"
)
end
it
'returns a hash to be used as data-attributes in a view'
do
is_expected
.
to
eq
({
track:
{
event:
'click_button'
,
label:
button_label
,
property:
'Category:control_group'
}
})
end
end
end
end
lib/gitlab/experimentation.rb
View file @
091de7cb
...
...
@@ -78,7 +78,7 @@ module Gitlab
included
do
before_action
:set_experimentation_subject_id_cookie
,
unless: :dnt_enabled?
helper_method
:experiment_enabled?
helper_method
:experiment_enabled?
,
:experiment_tracking_category_and_group
end
def
set_experimentation_subject_id_cookie
...
...
@@ -118,6 +118,10 @@ module Gitlab
::
Experiment
.
add_user
(
experiment_key
,
tracking_group
(
experiment_key
),
current_user
)
end
def
experiment_tracking_category_and_group
(
experiment_key
)
"
#{
tracking_category
(
experiment_key
)
}
:
#{
tracking_group
(
experiment_key
,
'_group'
)
}
"
end
private
def
dnt_enabled?
...
...
@@ -144,7 +148,7 @@ module Gitlab
{
category:
tracking_category
(
experiment_key
),
action:
action
,
property:
"
#{
tracking_group
(
experiment_key
)
}
_group"
,
property:
tracking_group
(
experiment_key
,
"_group"
)
,
label:
experimentation_subject_id
,
value:
value
}.
compact
...
...
@@ -154,10 +158,12 @@ module Gitlab
Experimentation
.
experiment
(
experiment_key
).
tracking_category
end
def
tracking_group
(
experiment_key
)
def
tracking_group
(
experiment_key
,
suffix
=
nil
)
return
unless
Experimentation
.
enabled?
(
experiment_key
)
experiment_enabled?
(
experiment_key
)
?
GROUP_EXPERIMENTAL
:
GROUP_CONTROL
group
=
experiment_enabled?
(
experiment_key
)
?
GROUP_EXPERIMENTAL
:
GROUP_CONTROL
suffix
?
"
#{
group
}#{
suffix
}
"
:
group
end
def
forced_enabled?
(
experiment_key
)
...
...
spec/lib/gitlab/experimentation_spec.rb
View file @
091de7cb
...
...
@@ -295,6 +295,19 @@ RSpec.describe Gitlab::Experimentation do
end
end
end
describe
'#experiment_tracking_category_and_group'
do
let_it_be
(
:experiment_key
)
{
:test_something
}
subject
{
controller
.
experiment_tracking_category_and_group
(
experiment_key
)
}
it
'returns a string with the experiment tracking category & group joined with a ":"'
do
expect
(
controller
).
to
receive
(
:tracking_category
).
with
(
experiment_key
).
and_return
(
'Experiment::Category'
)
expect
(
controller
).
to
receive
(
:tracking_group
).
with
(
experiment_key
,
'_group'
).
and_return
(
'experimental_group'
)
expect
(
subject
).
to
eq
(
'Experiment::Category:experimental_group'
)
end
end
end
describe
'.enabled?'
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