Welcome to mirror list, hosted at ThFree Co, Russian Federation.

service_ping_context.rb « tracking « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 393cd647e7f9c44b2250b5b0d14dfe6f980d28f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module Gitlab
  module Tracking
    class ServicePingContext
      SCHEMA_URL = 'iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-0'
      ALLOWED_SOURCES = %i[redis_hll].freeze

      def initialize(data_source:, event:)
        unless ALLOWED_SOURCES.include?(data_source)
          raise ArgumentError, "#{data_source} is not acceptable data source for ServicePingContext"
        end

        @payload = {
          data_source: data_source,
          event_name: event
        }
      end

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