Commit aebedb59 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '284598-use-an-explicit-data-keyword-argument-in-self_describing_event' into 'master'

Use an explicit `data:`  keyword argument in `self_describing_event`

See merge request gitlab-org/gitlab!48192
parents 59c728de c2da23c4
......@@ -421,7 +421,7 @@ Snowplow Micro is a Docker-based solution for testing frontend and backend event
1. Send a test Snowplow event from the Rails console:
```ruby
Gitlab::Tracking.self_describing_event('iglu:com.gitlab/pageview_context/jsonschema/1-0-0', { page_type: 'MY_TYPE' }, context: nil )
Gitlab::Tracking.self_describing_event('iglu:com.gitlab/pageview_context/jsonschema/1-0-0', data: { page_type: 'MY_TYPE' }, context: nil)
```
### Snowplow Mini
......
......@@ -28,7 +28,7 @@ class SurveyResponsesController < ApplicationController
response: params[:response]
}.compact
track_self_describing_event(SURVEY_RESPONSE_SCHEMA_URL, data)
track_self_describing_event(SURVEY_RESPONSE_SCHEMA_URL, data: data)
end
def to_number(param)
......
......@@ -23,8 +23,7 @@ RSpec.describe SurveyResponsesController do
it 'tracks a survey_response event' do
expect(controller).to receive(:track_self_describing_event).with(
SurveyResponsesController::SURVEY_RESPONSE_SCHEMA_URL,
survey_id: 1,
response: 'bar'
data: { survey_id: 1, response: 'bar' }
)
subject
......
......@@ -14,8 +14,8 @@ module Gitlab
Gitlab::Tracking.event(category, action.to_s, **args)
end
def track_self_describing_event(schema_url, event_data_json, **args)
Gitlab::Tracking.self_describing_event(schema_url, event_data_json, **args)
def track_self_describing_event(schema_url, data:, **args)
Gitlab::Tracking.self_describing_event(schema_url, data: data, **args)
end
end
......@@ -29,8 +29,8 @@ module Gitlab
product_analytics.event(category, action, label: label, property: property, value: value, context: context)
end
def self_describing_event(schema_url, event_data_json, context: nil)
snowplow.self_describing_event(schema_url, event_data_json, context: context)
def self_describing_event(schema_url, data:, context: nil)
snowplow.self_describing_event(schema_url, data: data, context: context)
end
def snowplow_options(group)
......
......@@ -15,10 +15,10 @@ module Gitlab
tracker.track_struct_event(category, action, label, property, value, context, (Time.now.to_f * 1000).to_i)
end
def self_describing_event(schema_url, event_data_json, context: nil)
def self_describing_event(schema_url, data:, context: nil)
return unless enabled?
event_json = SnowplowTracker::SelfDescribingJson.new(schema_url, event_data_json)
event_json = SnowplowTracker::SelfDescribingJson.new(schema_url, data)
tracker.track_self_describing_event(event_json, context, (Time.now.to_f * 1000).to_i)
end
......
......@@ -46,7 +46,7 @@ RSpec.describe Gitlab::Tracking::Destinations::Snowplow do
it 'sends event to tracker' do
allow(tracker).to receive(:track_self_describing_event).and_call_original
subject.self_describing_event('iglu:com.gitlab/foo/jsonschema/1-0-0', { foo: 'bar' })
subject.self_describing_event('iglu:com.gitlab/foo/jsonschema/1-0-0', data: { foo: 'bar' })
expect(tracker).to have_received(:track_self_describing_event) do |event, context, timestamp|
expect(event.to_json[:schema]).to eq('iglu:com.gitlab/foo/jsonschema/1-0-0')
......@@ -71,7 +71,7 @@ RSpec.describe Gitlab::Tracking::Destinations::Snowplow do
it 'does not send event to tracker' do
expect_any_instance_of(SnowplowTracker::Tracker).not_to receive(:track_self_describing_event)
subject.self_describing_event('iglu:com.gitlab/foo/jsonschema/1-0-0', { foo: 'bar' })
subject.self_describing_event('iglu:com.gitlab/foo/jsonschema/1-0-0', data: { foo: 'bar' })
end
end
end
......
......@@ -62,9 +62,9 @@ RSpec.describe Gitlab::Tracking do
it 'delegates to snowplow destination' do
expect_any_instance_of(Gitlab::Tracking::Destinations::Snowplow)
.to receive(:self_describing_event)
.with('iglu:com.gitlab/foo/jsonschema/1-0-0', { foo: 'bar' }, context: nil)
.with('iglu:com.gitlab/foo/jsonschema/1-0-0', data: { foo: 'bar' }, context: nil)
described_class.self_describing_event('iglu:com.gitlab/foo/jsonschema/1-0-0', { foo: 'bar' })
described_class.self_describing_event('iglu:com.gitlab/foo/jsonschema/1-0-0', data: { foo: 'bar' })
end
end
end
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