diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /lib/product_analytics/event_params.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'lib/product_analytics/event_params.rb')
-rw-r--r-- | lib/product_analytics/event_params.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/product_analytics/event_params.rb b/lib/product_analytics/event_params.rb new file mode 100644 index 00000000000..d938fe1f594 --- /dev/null +++ b/lib/product_analytics/event_params.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module ProductAnalytics + # Converts params from Snowplow tracker to one compatible with + # GitLab ProductAnalyticsEvent model. The field naming corresponds + # with snowplow event model. Only project_id is GitLab specific. + # + # For information on what each field is you can check next resources: + # * Snowplow tracker protocol: https://github.com/snowplow/snowplow/wiki/snowplow-tracker-protocol + # * Canonical event model: https://github.com/snowplow/snowplow/wiki/canonical-event-model + class EventParams + def self.parse_event_params(params) + { + project_id: params['aid'], + platform: params['p'], + collector_tstamp: Time.zone.now, + event_id: params['eid'], + v_tracker: params['tv'], + v_collector: Gitlab::VERSION, + v_etl: Gitlab::VERSION, + os_timezone: params['tz'], + name_tracker: params['tna'], + br_lang: params['lang'], + doc_charset: params['cs'], + br_features_pdf: Gitlab::Utils.to_boolean(params['f_pdf']), + br_features_flash: Gitlab::Utils.to_boolean(params['f_fla']), + br_features_java: Gitlab::Utils.to_boolean(params['f_java']), + br_features_director: Gitlab::Utils.to_boolean(params['f_dir']), + br_features_quicktime: Gitlab::Utils.to_boolean(params['f_qt']), + br_features_realplayer: Gitlab::Utils.to_boolean(params['f_realp']), + br_features_windowsmedia: Gitlab::Utils.to_boolean(params['f_wma']), + br_features_gears: Gitlab::Utils.to_boolean(params['f_gears']), + br_features_silverlight: Gitlab::Utils.to_boolean(params['f_ag']), + br_colordepth: params['cd'], + br_cookies: Gitlab::Utils.to_boolean(params['cookie']), + dvce_created_tstamp: params['dtm'], + br_viewheight: params['vp'], + domain_sessionidx: params['vid'], + domain_sessionid: params['sid'], + domain_userid: params['duid'], + user_fingerprint: params['fp'], + page_referrer: params['refr'], + page_url: params['url'] + } + end + + def self.has_required_params?(params) + params['aid'].present? && params['eid'].present? + end + end +end |