Commit 48bb6fc3 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '205578-refactor-pkg-events' into 'master'

Refactor pkg event publication

See merge request gitlab-org/gitlab!41709
parents 88c77f7c 0621c581
......@@ -123,7 +123,7 @@ module API
bad_request!
end
track_event('push_package')
package_event('push_package')
::Packages::Composer::CreatePackageService
.new(authorized_user_project, current_user, declared_params)
......
......@@ -242,7 +242,7 @@ module API
delete do
authorize!(:destroy_package, project)
track_event('delete_package')
package_event('delete_package')
package.destroy
end
......
......@@ -124,7 +124,7 @@ module API
conan_package_reference: params[:conan_package_reference]
).execute!
track_event('pull_package') if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY
package_event('pull_package') if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY
present_carrierwave_file!(package_file.file)
end
......@@ -135,7 +135,7 @@ module API
def track_push_package_event
if params[:file_name] == ::Packages::Conan::FileMetadatum::PACKAGE_BINARY && params[:file].size > 0 # rubocop: disable Style/ZeroLengthPredicate
track_event('push_package')
package_event('push_package')
end
end
......
......@@ -47,6 +47,10 @@ module API
authorize_create_package!(subject)
require_gitlab_workhorse!
end
def package_event(event_name, **args)
track_event(event_name, **args)
end
end
end
end
......@@ -107,7 +107,7 @@ module API
when 'sha1'
package_file.file_sha1
else
track_event('pull_package') if jar_file?(format)
package_event('pull_package') if jar_file?(format)
present_carrierwave_file_with_head_support!(package_file.file)
end
end
......@@ -145,7 +145,7 @@ module API
when 'sha1'
package_file.file_sha1
else
track_event('pull_package') if jar_file?(format)
package_event('pull_package') if jar_file?(format)
present_carrierwave_file_with_head_support!(package_file.file)
end
......@@ -181,7 +181,7 @@ module API
when 'sha1'
package_file.file_sha1
else
track_event('pull_package') if jar_file?(format)
package_event('pull_package') if jar_file?(format)
present_carrierwave_file_with_head_support!(package_file.file)
end
......@@ -233,7 +233,7 @@ module API
when 'md5'
nil
else
track_event('push_package') if jar_file?(format)
package_event('push_package') if jar_file?(format)
file_params = {
file: params[:file],
......
......@@ -141,7 +141,7 @@ module API
package_file = ::Packages::PackageFileFinder
.new(package, params[:file_name]).execute!
track_event('pull_package')
package_event('pull_package')
present_carrierwave_file!(package_file.file)
end
......@@ -157,7 +157,7 @@ module API
put ':id/packages/npm/:package_name', requirements: NPM_ENDPOINT_REQUIREMENTS do
authorize_create_package!(user_project)
track_event('push_package')
package_event('push_package')
created_package = ::Packages::Npm::CreatePackageService
.new(user_project, current_user, params.merge(build: current_authenticated_job)).execute
......
......@@ -105,7 +105,7 @@ module API
package_file = ::Packages::CreatePackageFileService.new(package, file_params)
.execute
track_event('push_package')
package_event('push_package')
::Packages::Nuget::ExtractionWorker.perform_async(package_file.id) # rubocop:disable CodeReuse/Worker
......@@ -198,7 +198,7 @@ module API
not_found!('Package') unless package_file
track_event('pull_package')
package_event('pull_package')
# nuget and dotnet don't support 302 Moved status codes, supports_direct_download has to be set to false
present_carrierwave_file!(package_file.file, supports_direct_download: false)
......@@ -233,7 +233,7 @@ module API
.new(authorized_user_project, params[:q], search_options)
.execute
track_event('search_package')
package_event('search_package')
present ::Packages::Nuget::SearchResultsPresenter.new(search),
with: ::API::Entities::Nuget::SearchResults
......
......@@ -72,7 +72,7 @@ module API
package = packages_finder(project).by_file_name_and_sha256(filename, params[:sha256])
package_file = ::Packages::PackageFileFinder.new(package, filename, with_file_name_like: false).execute
track_event('pull_package')
package_event('pull_package')
present_carrierwave_file!(package_file.file, supports_direct_download: true)
end
......@@ -91,7 +91,7 @@ module API
get 'simple/*package_name', format: :txt do
authorize_read_package!(authorized_user_project)
track_event('list_package')
package_event('list_package')
packages = find_package_versions
presenter = ::Packages::Pypi::PackagePresenter.new(packages, authorized_user_project)
......@@ -122,7 +122,7 @@ module API
authorize_upload!(authorized_user_project)
bad_request!('File is too large') if authorized_user_project.actual_limits.exceeded?(:pypi_max_file_size, params[:content].size)
track_event('push_package')
package_event('push_package')
::Packages::Pypi::CreatePackageService
.new(authorized_user_project, current_user, declared_params)
......
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