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
c57eda43
Commit
c57eda43
authored
Mar 10, 2021
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove snowplow API helper
- Part of Snowplow standardization effort
parent
5defc140
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
33 deletions
+13
-33
ee/lib/api/dependencies.rb
ee/lib/api/dependencies.rb
+1
-1
lib/api/generic_packages.rb
lib/api/generic_packages.rb
+2
-2
lib/api/helpers.rb
lib/api/helpers.rb
+0
-11
lib/api/helpers/packages/dependency_proxy_helpers.rb
lib/api/helpers/packages/dependency_proxy_helpers.rb
+1
-1
lib/api/helpers/packages_helpers.rb
lib/api/helpers/packages_helpers.rb
+2
-1
spec/lib/api/helpers/packages/dependency_proxy_helpers_spec.rb
...lib/api/helpers/packages/dependency_proxy_helpers_spec.rb
+7
-3
spec/lib/api/helpers_spec.rb
spec/lib/api/helpers_spec.rb
+0
-14
No files found.
ee/lib/api/dependencies.rb
View file @
c57eda43
...
...
@@ -36,7 +36,7 @@ module API
get
':id/dependencies'
do
authorize!
:read_dependencies
,
user_project
track_event
(
'view_dependencies'
)
::
Gitlab
::
Tracking
.
event
(
self
.
options
[
:for
].
name
,
'view_dependencies'
)
dependency_params
=
declared_params
(
include_missing:
false
).
merge
(
project:
user_project
)
dependencies
=
dependencies_by
(
dependency_params
)
...
...
lib/api/generic_packages.rb
View file @
c57eda43
...
...
@@ -62,7 +62,7 @@ module API
authorize_upload!
(
project
)
bad_request!
(
'File is too large'
)
if
max_file_size_exceeded?
track_event
(
'push_package'
)
::
Gitlab
::
Tracking
.
event
(
self
.
options
[
:for
].
name
,
'push_package'
)
create_package_file_params
=
declared_params
.
merge
(
build:
current_authenticated_job
)
::
Packages
::
Generic
::
CreatePackageFileService
...
...
@@ -94,7 +94,7 @@ module API
package
=
::
Packages
::
Generic
::
PackageFinder
.
new
(
project
).
execute!
(
params
[
:package_name
],
params
[
:package_version
])
package_file
=
::
Packages
::
PackageFileFinder
.
new
(
package
,
params
[
:file_name
]).
execute!
track_event
(
'pull_package'
)
::
Gitlab
::
Tracking
.
event
(
self
.
options
[
:for
].
name
,
'pull_package'
)
present_carrierwave_file!
(
package_file
.
file
)
end
...
...
lib/api/helpers.rb
View file @
c57eda43
...
...
@@ -540,17 +540,6 @@ module API
end
end
def
track_event
(
action
=
action_name
,
**
args
)
category
=
args
.
delete
(
:category
)
||
self
.
options
[
:for
].
name
raise
"invalid category"
unless
category
::
Gitlab
::
Tracking
.
event
(
category
,
action
.
to_s
,
**
args
)
rescue
=>
error
Gitlab
::
AppLogger
.
warn
(
"Tracking event failed for action:
#{
action
}
, category:
#{
category
}
, message:
#{
error
.
message
}
"
)
end
def
increment_counter
(
event_name
)
feature_name
=
"usage_data_
#{
event_name
}
"
return
unless
Feature
.
enabled?
(
feature_name
)
...
...
lib/api/helpers/packages/dependency_proxy_helpers.rb
View file @
c57eda43
...
...
@@ -10,7 +10,7 @@ module API
def
redirect_registry_request
(
forward_to_registry
,
package_type
,
options
)
if
forward_to_registry
&&
redirect_registry_request_available?
track_event
(
"
#{
package_type
}
_request_forward"
)
::
Gitlab
::
Tracking
.
event
(
self
.
options
[
:for
].
name
,
"
#{
package_type
}
_request_forward"
)
redirect
(
registry_url
(
package_type
,
options
))
else
yield
...
...
lib/api/helpers/packages_helpers.rb
View file @
c57eda43
...
...
@@ -50,7 +50,8 @@ module API
def
track_package_event
(
event_name
,
scope
,
**
args
)
::
Packages
::
CreateEventService
.
new
(
nil
,
current_user
,
event_name:
event_name
,
scope:
scope
).
execute
track_event
(
event_name
,
**
args
)
category
=
args
.
delete
(
:category
)
||
self
.
options
[
:for
].
name
::
Gitlab
::
Tracking
.
event
(
category
,
event_name
.
to_s
,
**
args
)
end
end
end
...
...
spec/lib/api/helpers/packages/dependency_proxy_helpers_spec.rb
View file @
c57eda43
...
...
@@ -12,6 +12,10 @@ RSpec.describe API::Helpers::Packages::DependencyProxyHelpers do
subject
{
helper
.
redirect_registry_request
(
forward_to_registry
,
package_type
,
options
)
{
helper
.
fallback
}
}
before
do
allow
(
helper
).
to
receive
(
:options
).
and_return
(
for:
API
::
NpmInstancePackages
)
end
shared_examples
'executing fallback'
do
it
'redirects to package registry'
do
expect
(
helper
).
to
receive
(
:registry_url
).
never
...
...
@@ -23,13 +27,14 @@ RSpec.describe API::Helpers::Packages::DependencyProxyHelpers do
end
shared_examples
'executing redirect'
do
it
'redirects to package registry'
do
expect
(
helper
).
to
receive
(
:track_event
).
with
(
'npm_request_forward'
).
once
it
'redirects to package registry'
,
:snowplow
do
expect
(
helper
).
to
receive
(
:registry_url
).
once
expect
(
helper
).
to
receive
(
:redirect
).
once
expect
(
helper
).
to
receive
(
:fallback
).
never
subject
expect_snowplow_event
(
category:
'API::NpmInstancePackages'
,
action:
'npm_request_forward'
)
end
end
...
...
@@ -64,7 +69,6 @@ RSpec.describe API::Helpers::Packages::DependencyProxyHelpers do
let
(
:package_type
)
{
pkg_type
}
it
'raises an error'
do
allow
(
helper
).
to
receive
(
:track_event
)
expect
{
subject
}.
to
raise_error
(
ArgumentError
,
"Can't build registry_url for package_type
#{
package_type
}
"
)
end
end
...
...
spec/lib/api/helpers_spec.rb
View file @
c57eda43
...
...
@@ -175,20 +175,6 @@ RSpec.describe API::Helpers do
end
end
describe
'#track_event'
do
it
"creates a gitlab tracking event"
,
:snowplow
do
subject
.
track_event
(
'my_event'
,
category:
'foo'
)
expect_snowplow_event
(
category:
'foo'
,
action:
'my_event'
)
end
it
"logs an exception"
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:warn
).
with
(
/Tracking event failed/
)
subject
.
track_event
(
'my_event'
,
category:
nil
)
end
end
describe
'#increment_unique_values'
do
let
(
:value
)
{
'9f302fea-f828-4ca9-aef4-e10bd723c0b3'
}
let
(
:event_name
)
{
'g_compliance_dashboard'
}
...
...
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