Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c2da23c4
Commit
c2da23c4
authored
Nov 19, 2020
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an explicit `data:` keyword argument in `self_describing_event`
parent
c0c3f829
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
14 deletions
+13
-14
doc/development/product_analytics/snowplow.md
doc/development/product_analytics/snowplow.md
+1
-1
ee/app/controllers/survey_responses_controller.rb
ee/app/controllers/survey_responses_controller.rb
+1
-1
ee/spec/controllers/survey_responses_controller_spec.rb
ee/spec/controllers/survey_responses_controller_spec.rb
+1
-2
lib/gitlab/tracking.rb
lib/gitlab/tracking.rb
+4
-4
lib/gitlab/tracking/destinations/snowplow.rb
lib/gitlab/tracking/destinations/snowplow.rb
+2
-2
spec/lib/gitlab/tracking/destinations/snowplow_spec.rb
spec/lib/gitlab/tracking/destinations/snowplow_spec.rb
+2
-2
spec/lib/gitlab/tracking_spec.rb
spec/lib/gitlab/tracking_spec.rb
+2
-2
No files found.
doc/development/product_analytics/snowplow.md
View file @
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
...
...
ee/app/controllers/survey_responses_controller.rb
View file @
c2da23c4
...
...
@@ -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
)
...
...
ee/spec/controllers/survey_responses_controller_spec.rb
View file @
c2da23c4
...
...
@@ -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
...
...
lib/gitlab/tracking.rb
View file @
c2da23c4
...
...
@@ -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
)
...
...
lib/gitlab/tracking/destinations/snowplow.rb
View file @
c2da23c4
...
...
@@ -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
...
...
spec/lib/gitlab/tracking/destinations/snowplow_spec.rb
View file @
c2da23c4
...
...
@@ -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
...
...
spec/lib/gitlab/tracking_spec.rb
View file @
c2da23c4
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment