Admin analytics: heatmap per device, anteprima staff e analisi costi.
Separa heatmap mobile/desktop, opt-out analytics per operatori, dashboard costi con KPI e trend mensili. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Analytics
|
||||
module Suppress
|
||||
COOKIE_NAME = "mltv_analytics_suppress"
|
||||
COOKIE_MAX_AGE = 7 * 24 * 60 * 60
|
||||
|
||||
module_function
|
||||
|
||||
def active?(cookie_value)
|
||||
cookie_value.to_s == "1"
|
||||
end
|
||||
|
||||
def enable!(cookie_jar)
|
||||
cookie_jar[COOKIE_NAME] = cookie_options(value: "1", expires: COOKIE_MAX_AGE.seconds.from_now)
|
||||
end
|
||||
|
||||
def disable!(cookie_jar)
|
||||
cookie_jar.delete(
|
||||
COOKIE_NAME,
|
||||
path: "/",
|
||||
same_site: :lax,
|
||||
secure: cookie_secure?
|
||||
)
|
||||
end
|
||||
|
||||
def cookie_options(value:, expires:)
|
||||
{
|
||||
value: value,
|
||||
expires: expires,
|
||||
path: "/",
|
||||
httponly: true,
|
||||
same_site: :lax,
|
||||
secure: cookie_secure?
|
||||
}
|
||||
end
|
||||
|
||||
def cookie_secure?
|
||||
Rails.application.config.force_ssl || Rails.env.production?
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user