Commit c2da23c4 authored by Alishan Ladhani's avatar Alishan Ladhani

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

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