Commit 8820b856 authored by Alishan Ladhani's avatar Alishan Ladhani

Add `source` to Snowplow StandardContext

parent bfce8bed
......@@ -4,6 +4,7 @@ module Gitlab
module Tracking
class StandardContext
GITLAB_STANDARD_SCHEMA_URL = 'iglu:com.gitlab/gitlab_standard/jsonschema/1-0-2'.freeze
GITLAB_RAILS_SOURCE = 'gitlab-rails'.freeze
def initialize(namespace: nil, project: nil, **data)
@namespace = namespace
......@@ -23,6 +24,10 @@ module Gitlab
'development'
end
def source
GITLAB_RAILS_SOURCE
end
private
def to_h
......
......@@ -9,7 +9,7 @@ RSpec.describe Gitlab::Tracking::StandardContext do
let(:snowplow_context) { subject.to_context }
describe '#to_context' do
context 'with no arguments' do
context 'default fields' do
context 'environment' do
shared_examples 'contains environment' do |expected_environment|
it 'contains environment' do
......@@ -37,6 +37,10 @@ RSpec.describe Gitlab::Tracking::StandardContext do
include_examples 'contains environment', 'production'
end
end
it 'contains source' do
expect(snowplow_context.to_json.dig(:data, :source)).to eq(described_class::GITLAB_RAILS_SOURCE)
end
end
context 'with extra data' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment