Commit d2847f16 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'revert-snowplow-getting-userid' into 'master'

Revert adding user id to snowplow

See merge request gitlab-org/gitlab!19109
parents 61cace63 a4ecef34
......@@ -102,7 +102,6 @@ export function initUserTracking() {
window.snowplow('enableActivityTracking', 30, 30);
window.snowplow('trackPageView'); // must be after enableActivityTracking
if (opts.userId) window.snowplow('setUserId', opts.userId);
if (opts.formTracking) window.snowplow('enableFormTracking');
if (opts.linkClickTracking) window.snowplow('enableLinkClickTracking');
......
......@@ -7,4 +7,4 @@
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","#{asset_url('snowplow/sp.js')}","snowplow"));
window.snowplowOptions = #{Gitlab::Tracking.snowplow_options(@group, current_user).to_json}
window.snowplowOptions = #{Gitlab::Tracking.snowplow_options(@group).to_json}
......@@ -39,7 +39,7 @@ module Gitlab
snowplow.track_self_describing_event(event_json, context, Time.now.to_i)
end
def snowplow_options(group, user)
def snowplow_options(group)
additional_features = Feature.enabled?(:additional_snowplow_tracking, group)
{
namespace: SNOWPLOW_NAMESPACE,
......@@ -47,8 +47,7 @@ module Gitlab
cookie_domain: Gitlab::CurrentSettings.snowplow_cookie_domain,
app_id: Gitlab::CurrentSettings.snowplow_site_id,
form_tracking: additional_features,
link_click_tracking: additional_features,
user_id: user&.id
link_click_tracking: additional_features
}.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end
......
......@@ -11,7 +11,6 @@ describe('Tracking', () => {
namespace: '_namespace_',
hostname: 'app.gitfoo.com',
cookieDomain: '.gitfoo.com',
userId: null,
};
snowplowSpy = jest.spyOn(window, 'snowplow');
});
......@@ -35,7 +34,6 @@ describe('Tracking', () => {
contexts: { webPage: true },
formTracking: false,
linkClickTracking: false,
userId: null,
});
});
......@@ -43,18 +41,15 @@ describe('Tracking', () => {
initUserTracking();
expect(snowplowSpy).toHaveBeenCalledWith('enableActivityTracking', 30, 30);
expect(snowplowSpy).toHaveBeenCalledWith('trackPageView');
expect(snowplowSpy).not.toHaveBeenCalledWith('setUserId');
expect(snowplowSpy).not.toHaveBeenCalledWith('enableFormTracking');
expect(snowplowSpy).not.toHaveBeenCalledWith('enableLinkClickTracking');
window.snowplowOptions = Object.assign({}, window.snowplowOptions, {
formTracking: true,
linkClickTracking: true,
userId: '1',
});
initUserTracking();
expect(snowplowSpy).toHaveBeenCalledWith('setUserId', '1');
expect(snowplowSpy).toHaveBeenCalledWith('enableFormTracking');
expect(snowplowSpy).toHaveBeenCalledWith('enableLinkClickTracking');
});
......
......@@ -19,11 +19,10 @@ describe Gitlab::Tracking do
cookieDomain: '.gitfoo.com',
appId: '_abc123_',
formTracking: true,
linkClickTracking: true,
userId: nil
linkClickTracking: true
}
expect(subject.snowplow_options(nil, nil)).to match(expected_fields)
expect(subject.snowplow_options(nil)).to match(expected_fields)
end
it 'enables features using feature flags' do
......@@ -37,7 +36,7 @@ describe Gitlab::Tracking do
linkClickTracking: false
}
expect(subject.snowplow_options('_group_', nil)).to include(addition_feature_fields)
expect(subject.snowplow_options('_group_')).to include(addition_feature_fields)
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