Commit e7a57573 authored by James Fargher's avatar James Fargher

Merge branch '231533-parse-and-save-structured-event-fields-in-snowplow-collector' into 'master'

Parse and save structured event fields in snowplow collector

Closes #231533

See merge request gitlab-org/gitlab!38927
parents 15198a6c 24e09184
......@@ -40,7 +40,12 @@ module ProductAnalytics
domain_userid: params['duid'],
user_fingerprint: params['fp'],
page_referrer: params['refr'],
page_url: params['url']
page_url: params['url'],
se_category: params['se_ca'],
se_action: params['se_ac'],
se_label: params['se_la'],
se_property: params['se_pr'],
se_value: params['se_va']
}
end
......
......@@ -12,5 +12,10 @@
"lang":"en-US",
"cookie":"1",
"tz":"America/Los_Angeles",
"cs":"UTF-8"
"cs":"UTF-8",
"se_ca": "category",
"se_ac": "action",
"se_la": "label",
"se_pr": "property",
"se_va": 12.34
}
......@@ -23,7 +23,12 @@ RSpec.describe ProductAnalytics::EventParams do
br_lang: 'en-US',
br_cookies: true,
os_timezone: 'America/Los_Angeles',
doc_charset: 'UTF-8'
doc_charset: 'UTF-8',
se_category: 'category',
se_action: 'action',
se_label: 'label',
se_property: 'property',
se_value: 12.34
}
expect(subject).to include(expected_params)
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe 'ProductAnalytics::CollectorApp' do
let_it_be(:project) { create(:project) }
let(:params) { {} }
let(:raw_event) { Gitlab::Json.parse(fixture_file('product_analytics/event.json')) }
subject { get '/-/collector/i', params: params }
......@@ -17,24 +18,7 @@ RSpec.describe 'ProductAnalytics::CollectorApp' do
end
context 'correct event params' do
let(:params) do
{
aid: project.id,
p: 'web',
tna: 'sp',
tv: 'js-2.14.0',
eid: SecureRandom.uuid,
duid: SecureRandom.uuid,
sid: SecureRandom.uuid,
vid: 4,
url: 'http://example.com/products/1',
refr: 'http://example.com/products/1',
lang: 'en-US',
cookie: true,
tz: 'America/Los_Angeles',
cs: 'UTF-8'
}
end
let(:params) { raw_event.merge(aid: project.id) }
it 'repond with 200' do
expect { subject }.to change { ProductAnalyticsEvent.count }.by(1)
......
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