Commit 034491df authored by Kerri Miller's avatar Kerri Miller

Merge branch '205578-refactor-pkg-event-guest-naming' into 'master'

Refactor package event guest event handling

See merge request gitlab-org/gitlab!48311
parents d17ec16d 0c1a5d1f
......@@ -25,7 +25,7 @@ class Packages::Event < ApplicationRecord
enum originator_type: { user: 0, deploy_token: 1, guest: 2 }
def self.allowed_event_name(event_scope, event_type, originator)
return unless event_allowed?(event_scope, event_type, originator)
return unless event_allowed?(event_type)
# remove `package` from the event name to avoid issues with HLLRedisCounter class parsing
"i_package_#{event_scope}_#{originator}_#{event_type.gsub(/_packages?/, "")}"
......@@ -33,8 +33,7 @@ class Packages::Event < ApplicationRecord
# Remove some of the events, for now, so we don't hammer Redis too hard.
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/280770
def self.event_allowed?(event_scope, event_type, originator)
return false if originator.to_sym == :guest
def self.event_allowed?(event_type)
return true if UNIQUE_EVENTS_ALLOWED.include?(event_type.to_sym)
false
......
......@@ -4,7 +4,9 @@ module Packages
class CreateEventService < BaseService
def execute
if Feature.enabled?(:collect_package_events_redis) && redis_event_name
::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(current_user.id, redis_event_name)
unless guest?
::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(current_user.id, redis_event_name)
end
end
if Feature.enabled?(:collect_package_events) && Gitlab::Database.read_write?
......@@ -45,5 +47,9 @@ module Packages
:guest
end
end
def guest?
originator_type == :guest
end
end
end
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