Commit e20004c4 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'tracking-attrs-no-dev' into 'master'

Tracking attrs no dev

Closes #10124

See merge request gitlab-org/gitlab-ee!13942
parents 68a838d5 f53b3166
...@@ -6,7 +6,7 @@ module EE ...@@ -6,7 +6,7 @@ module EE
override :tracking_attrs override :tracking_attrs
def tracking_attrs(label, event, property) def tracking_attrs(label, event, property)
return {} unless snowplow_enabled? return {} unless tracking_enabled?
{ {
data: { data: {
...@@ -19,8 +19,9 @@ module EE ...@@ -19,8 +19,9 @@ module EE
private private
def snowplow_enabled? def tracking_enabled?
::Gitlab::CurrentSettings.snowplow_enabled? Rails.env.production? &&
::Gitlab::CurrentSettings.snowplow_enabled?
end end
end end
end end
...@@ -4,16 +4,32 @@ require 'spec_helper' ...@@ -4,16 +4,32 @@ require 'spec_helper'
describe EE::TrackingHelper do describe EE::TrackingHelper do
describe '#tracking_attrs' do describe '#tracking_attrs' do
it 'returns a hash of snowplow data attrs if snowplow is enabled' do using RSpec::Parameterized::TableSyntax
stub_application_setting(snowplow_enabled: true)
expect(helper.tracking_attrs('a', 'b', 'c')).to eq(data: { track_label: 'a', track_event: 'b', track_property: 'c' }) let(:input) { %w(a b c) }
let(:results) do
{
no_data: {},
with_data: { data: { track_label: 'a', track_event: 'b', track_property: 'c' } }
}
end end
it 'returns an empty hash if snowplow is disabled' do where(:snowplow_enabled, :environment, :result) do
stub_application_setting(snowplow_enabled: false) true | 'production' | :with_data
false | 'production' | :no_data
true | 'development' | :no_data
false | 'development' | :no_data
true | 'test' | :no_data
false | 'test' | :no_data
end
with_them do
it 'returns a hash' do
stub_application_setting(snowplow_enabled: snowplow_enabled)
allow(Rails).to receive(:env).and_return(environment.inquiry)
expect(helper.tracking_attrs('a', 'b', 'c')).to eq({}) expect(helper.tracking_attrs(*input)).to eq(results[result])
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment