Commit a1791d55 authored by Steve Abrams's avatar Steve Abrams

Update generic package event tracking with usage ping

parent 39a1040e
...@@ -62,7 +62,7 @@ module API ...@@ -62,7 +62,7 @@ module API
authorize_upload!(project) authorize_upload!(project)
bad_request!('File is too large') if max_file_size_exceeded? bad_request!('File is too large') if max_file_size_exceeded?
::Gitlab::Tracking.event(self.options[:for].name, 'push_package', user: current_user, project: project, namespace: project.namespace) track_package_event('push_package', :generic, project: project, user: current_user, namespace: project.namespace)
create_package_file_params = declared_params.merge(build: current_authenticated_job) create_package_file_params = declared_params.merge(build: current_authenticated_job)
::Packages::Generic::CreatePackageFileService ::Packages::Generic::CreatePackageFileService
...@@ -96,7 +96,7 @@ module API ...@@ -96,7 +96,7 @@ module API
package = ::Packages::Generic::PackageFinder.new(project).execute!(params[:package_name], params[:package_version]) package = ::Packages::Generic::PackageFinder.new(project).execute!(params[:package_name], params[:package_version])
package_file = ::Packages::PackageFileFinder.new(package, params[:file_name]).execute! package_file = ::Packages::PackageFileFinder.new(package, params[:file_name]).execute!
::Gitlab::Tracking.event(self.options[:for].name, 'pull_package', user: current_user, project: project, namespace: project.namespace) track_package_event('pull_package', :generic, project: project, user: current_user, namespace: project.namespace)
present_carrierwave_file!(package_file.file) present_carrierwave_file!(package_file.file)
end end
......
...@@ -388,9 +388,11 @@ RSpec.describe API::GenericPackages do ...@@ -388,9 +388,11 @@ RSpec.describe API::GenericPackages do
end end
context 'event tracking' do context 'event tracking' do
let(:snowplow_gitlab_standard_context) { { project: project, namespace: project.namespace, user: user } }
subject { upload_file(params, workhorse_headers.merge(personal_access_token_header)) } subject { upload_file(params, workhorse_headers.merge(personal_access_token_header)) }
it_behaves_like 'a gitlab tracking event', described_class.name, 'push_package' it_behaves_like 'a package tracking event', described_class.name, 'push_package'
end end
it 'rejects request without a file from workhorse' do it 'rejects request without a file from workhorse' do
...@@ -542,13 +544,15 @@ RSpec.describe API::GenericPackages do ...@@ -542,13 +544,15 @@ RSpec.describe API::GenericPackages do
end end
context 'event tracking' do context 'event tracking' do
let(:snowplow_gitlab_standard_context) { { project: project, namespace: project.namespace, user: user } }
before do before do
project.add_developer(user) project.add_developer(user)
end end
subject { download_file(personal_access_token_header) } subject { download_file(personal_access_token_header) }
it_behaves_like 'a gitlab tracking event', described_class.name, 'pull_package' it_behaves_like 'a package tracking event', described_class.name, 'pull_package'
end end
it 'rejects a malicious file name request' do it 'rejects a malicious file name request' do
......
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