Module: Analytics::UniqueVisitsHelper

Extended by:
ActiveSupport::Concern
Included in:
Admin::CohortsController, Admin::DevOpsReportController, Dashboard::TodosController, Projects::CycleAnalyticsController, Projects::GraphsController, Projects::PipelinesController
Defined in:
app/helpers/analytics/unique_visits_helper.rb

Instance Method Summary collapse

Instance Method Details

#track_visit(target_id) ⇒ Object


16
17
18
19
20
21
22
# File 'app/helpers/analytics/unique_visits_helper.rb', line 16

def track_visit(target_id)
  return unless Feature.enabled?(:track_unique_visits)
  return unless Gitlab::CurrentSettings.usage_ping_enabled?
  return unless visitor_id

  Gitlab::Analytics::UniqueVisits.new.track_visit(visitor_id, target_id)
end

#visitor_idObject


7
8
9
10
11
12
13
14
# File 'app/helpers/analytics/unique_visits_helper.rb', line 7

def visitor_id
  return cookies[:visitor_id] if cookies[:visitor_id].present?
  return unless current_user

  uuid = SecureRandom.uuid
  cookies[:visitor_id] = { value: uuid, expires: 24.months }
  uuid
end