2019-06-05 16:28:41 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module TrackingHelper
|
2021-03-26 18:09:16 +00:00
|
|
|
def tracking_attrs(label, action, property)
|
2019-08-14 19:21:58 +00:00
|
|
|
return {} unless tracking_enabled?
|
|
|
|
|
|
|
|
{
|
|
|
|
data: {
|
|
|
|
track_label: label,
|
2021-03-26 18:09:16 +00:00
|
|
|
track_action: action,
|
2019-08-14 19:21:58 +00:00
|
|
|
track_property: property
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2021-12-22 06:13:39 +00:00
|
|
|
def tracking_attrs_data(label, action, property)
|
|
|
|
tracking_attrs(label, action, property).fetch(:data, {})
|
|
|
|
end
|
|
|
|
|
2019-08-14 19:21:58 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def tracking_enabled?
|
|
|
|
Rails.env.production? &&
|
2021-06-19 00:10:16 +00:00
|
|
|
::Gitlab::Tracking.enabled?
|
2019-06-05 16:28:41 +00:00
|
|
|
end
|
|
|
|
end
|