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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/tracking/service_ping_context.rb')
-rw-r--r--lib/gitlab/tracking/service_ping_context.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/tracking/service_ping_context.rb b/lib/gitlab/tracking/service_ping_context.rb
new file mode 100644
index 00000000000..393cd647e7f
--- /dev/null
+++ b/lib/gitlab/tracking/service_ping_context.rb
@@ -0,0 +1,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