Class: Gitlab::Tracking::ServicePingContext

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/tracking/service_ping_context.rb

Constant Summary collapse

SCHEMA_URL =
'iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-1'
REDISHLL_SOURCE =
:redis_hll
REDIS_SOURCE =
:redis
ALLOWED_SOURCES =
[REDISHLL_SOURCE, REDIS_SOURCE].freeze

Instance Method Summary collapse

Constructor Details

#initialize(data_source:, event: nil) ⇒ ServicePingContext

Returns a new instance of ServicePingContext.



12
13
14
15
16
17
18
# File 'lib/gitlab/tracking/service_ping_context.rb', line 12

def initialize(data_source:, event: nil)
  check_configuration(data_source, event)

  @payload = { data_source: data_source }

  payload[:event_name] = event
end

Instance Method Details

#to_contextObject



20
21
22
# File 'lib/gitlab/tracking/service_ping_context.rb', line 20

def to_context
  SnowplowTracker::SelfDescribingJson.new(SCHEMA_URL, payload)
end

#to_hObject



24
25
26
27
28
29
# File 'lib/gitlab/tracking/service_ping_context.rb', line 24

def to_h
  {
    schema: SCHEMA_URL,
    data: @payload
  }
end