Commit a95c85ad authored by Steve Abrams's avatar Steve Abrams

Add event tracking to Maven API

Add snowplow event tracking to Maven API
to track push and pull of packages
parent d6e31b67
...@@ -27,7 +27,7 @@ module API ...@@ -27,7 +27,7 @@ module API
if %w(md5 sha1).include?(format) if %w(md5 sha1).include?(format)
[name, format] [name, format]
else else
[file_name, nil] [file_name, format]
end end
end end
...@@ -46,6 +46,10 @@ module API ...@@ -46,6 +46,10 @@ module API
project_path = path.rpartition('/').first project_path = path.rpartition('/').first
Project.find_by_full_path(project_path) Project.find_by_full_path(project_path)
end end
def jar_file?(format)
format == 'jar'
end
end end
desc 'Download the maven package file at instance level' do desc 'Download the maven package file at instance level' do
...@@ -79,7 +83,9 @@ module API ...@@ -79,7 +83,9 @@ module API
package_file.file_md5 package_file.file_md5
when 'sha1' when 'sha1'
package_file.file_sha1 package_file.file_sha1
when nil else
track_event('pull_package') if jar_file?(format)
present_carrierwave_file!(package_file.file) present_carrierwave_file!(package_file.file)
end end
end end
...@@ -117,7 +123,9 @@ module API ...@@ -117,7 +123,9 @@ module API
package_file.file_md5 package_file.file_md5
when 'sha1' when 'sha1'
package_file.file_sha1 package_file.file_sha1
when nil else
track_event('pull_package') if jar_file?(format)
present_carrierwave_file!(package_file.file) present_carrierwave_file!(package_file.file)
end end
end end
...@@ -155,12 +163,14 @@ module API ...@@ -155,12 +163,14 @@ module API
package_file.file_md5 package_file.file_md5
when 'sha1' when 'sha1'
package_file.file_sha1 package_file.file_sha1
when nil else
track_event('pull_package') if jar_file?(format)
present_carrierwave_file!(package_file.file) present_carrierwave_file!(package_file.file)
end end
end end
desc 'Upload the maven package file' do desc 'Workhorse authorize the maven package file upload' do
detail 'This feature was introduced in GitLab 11.3' detail 'This feature was introduced in GitLab 11.3'
end end
params do params do
...@@ -215,7 +225,11 @@ module API ...@@ -215,7 +225,11 @@ module API
.new(package, file_name).execute! .new(package, file_name).execute!
verify_package_file(package_file, uploaded_file) verify_package_file(package_file, uploaded_file)
when nil when 'md5'
nil
else
track_event('push_package') if jar_file?(format)
file_params = { file_params = {
file: uploaded_file, file: uploaded_file,
size: params['file.size'], size: params['file.size'],
......
This diff is collapsed.
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