Raccoglie eventi aggregati dietro consenso cookie, senza PII né tracking su admin/regia/live/replay; GA4 resta invariato. Co-authored-by: Cursor <cursoragent@cursor.com>
15 lines
360 B
Ruby
15 lines
360 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AnalyticsPageStat < ApplicationRecord
|
|
self.table_name = "analytics_page_stats"
|
|
|
|
validates :day, :page_path, :device, presence: true
|
|
validates :device, inclusion: { in: AnalyticsEvent::DEVICES }
|
|
|
|
def avg_scroll_pct
|
|
return 0 if scroll_samples.to_i <= 0
|
|
|
|
(scroll_sum_pct.to_f / scroll_samples).round
|
|
end
|
|
end
|