debian-mirror-gitlab/app/controllers/concerns/product_analytics_tracking.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.2 KiB
Ruby
Raw Normal View History

2022-05-07 20:08:51 +05:30
# frozen_string_literal: true
module ProductAnalyticsTracking
include Gitlab::Tracking::Helpers
include RedisTracking
extend ActiveSupport::Concern
class_methods do
def track_event(*controller_actions, name:, conditions: nil, destinations: [:redis_hll], &block)
custom_conditions = [:trackable_html_request?, *conditions]
after_action only: controller_actions, if: custom_conditions do
route_events_to(destinations, name, &block)
end
end
end
private
def route_events_to(destinations, name, &block)
track_unique_redis_hll_event(name, &block) if destinations.include?(:redis_hll)
2022-07-23 23:45:48 +05:30
if destinations.include?(:snowplow) && event_enabled?(name)
2022-05-07 20:08:51 +05:30
Gitlab::Tracking.event(self.class.to_s, name, namespace: tracking_namespace_source, user: current_user)
end
end
2022-07-23 23:45:48 +05:30
def event_enabled?(event)
events_to_ff = {
g_analytics_valuestream: :route_hll_to_snowplow,
2022-08-13 15:12:31 +05:30
i_search_paid: :route_hll_to_snowplow_phase2,
i_search_total: :route_hll_to_snowplow_phase2,
i_search_advanced: :route_hll_to_snowplow_phase2
2022-07-23 23:45:48 +05:30
}
Feature.enabled?(events_to_ff[event.to_sym], tracking_namespace_source)
end
2022-05-07 20:08:51 +05:30
end