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
f8f00f00
Commit
f8f00f00
authored
Mar 14, 2021
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track and rescue errors that occur when emitting Snowplow events
As a failsafe
parent
2a9367fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
lib/gitlab/tracking.rb
lib/gitlab/tracking.rb
+2
-0
spec/lib/gitlab/tracking_spec.rb
spec/lib/gitlab/tracking_spec.rb
+16
-7
No files found.
lib/gitlab/tracking.rb
View file @
f8f00f00
...
@@ -29,6 +29,8 @@ module Gitlab
...
@@ -29,6 +29,8 @@ module Gitlab
snowplow
.
event
(
category
,
action
,
label:
label
,
property:
property
,
value:
value
,
context:
contexts
)
snowplow
.
event
(
category
,
action
,
label:
label
,
property:
property
,
value:
value
,
context:
contexts
)
product_analytics
.
event
(
category
,
action
,
label:
label
,
property:
property
,
value:
value
,
context:
contexts
)
product_analytics
.
event
(
category
,
action
,
label:
label
,
property:
property
,
value:
value
,
context:
contexts
)
rescue
=>
error
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
error
,
snowplow_category:
category
,
snowplow_action:
action
)
end
end
def
self_describing_event
(
schema_url
,
data
:,
context:
nil
)
def
self_describing_event
(
schema_url
,
data
:,
context:
nil
)
...
...
spec/lib/gitlab/tracking_spec.rb
View file @
f8f00f00
...
@@ -36,12 +36,12 @@ RSpec.describe Gitlab::Tracking do
...
@@ -36,12 +36,12 @@ RSpec.describe Gitlab::Tracking do
end
end
describe
'.event'
do
describe
'.event'
do
before
do
allow_any_instance_of
(
Gitlab
::
Tracking
::
Destinations
::
Snowplow
).
to
receive
(
:event
)
allow_any_instance_of
(
Gitlab
::
Tracking
::
Destinations
::
ProductAnalytics
).
to
receive
(
:event
)
end
shared_examples
'delegates to destination'
do
|
klass
|
shared_examples
'delegates to destination'
do
|
klass
|
before
do
allow_any_instance_of
(
Gitlab
::
Tracking
::
Destinations
::
Snowplow
).
to
receive
(
:event
)
allow_any_instance_of
(
Gitlab
::
Tracking
::
Destinations
::
ProductAnalytics
).
to
receive
(
:event
)
end
it
"delegates to
#{
klass
}
destination"
do
it
"delegates to
#{
klass
}
destination"
do
other_context
=
double
(
:context
)
other_context
=
double
(
:context
)
...
@@ -70,8 +70,17 @@ RSpec.describe Gitlab::Tracking do
...
@@ -70,8 +70,17 @@ RSpec.describe Gitlab::Tracking do
end
end
end
end
include_examples
'delegates to destination'
,
Gitlab
::
Tracking
::
Destinations
::
Snowplow
it_behaves_like
'delegates to destination'
,
Gitlab
::
Tracking
::
Destinations
::
Snowplow
include_examples
'delegates to destination'
,
Gitlab
::
Tracking
::
Destinations
::
ProductAnalytics
it_behaves_like
'delegates to destination'
,
Gitlab
::
Tracking
::
Destinations
::
ProductAnalytics
it
'tracks errors'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_and_raise_for_dev_exception
).
with
(
an_instance_of
(
ContractError
),
snowplow_category:
nil
,
snowplow_action:
'some_action'
)
described_class
.
event
(
nil
,
'some_action'
)
end
end
end
describe
'.self_describing_event'
do
describe
'.self_describing_event'
do
...
...
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