Class: ProductAnalytics::EventParams

Inherits:
Object
  • Object
show all
Defined in:
lib/product_analytics/event_params.rb

Overview

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:

Class Method Summary collapse

Class Method Details

.has_required_params?(params) ⇒ Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/product_analytics/event_params.rb', line 52

def self.has_required_params?(params)
  params['aid'].present? && params['eid'].present?
end

.parse_event_params(params) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/product_analytics/event_params.rb', line 12

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'],
    se_category:              params['se_ca'],
    se_action:                params['se_ac'],
    se_label:                 params['se_la'],
    se_property:              params['se_pr'],
    se_value:                 params['se_va']
  }
end