Aggiunge heatmaps first-party (click/scroll) con pagina admin Analytics.
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>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateAnalyticsTables < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
create_table :analytics_events, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
|
||||
t.string :page_path, null: false
|
||||
t.string :device, null: false
|
||||
t.string :event_type, null: false
|
||||
t.decimal :x_pct, precision: 6, scale: 2
|
||||
t.decimal :y_pct, precision: 6, scale: 2
|
||||
t.decimal :scroll_pct, precision: 6, scale: 2
|
||||
t.datetime :occurred_at, null: false
|
||||
t.timestamps
|
||||
end
|
||||
add_index :analytics_events, :occurred_at
|
||||
add_index :analytics_events, %i[event_type occurred_at]
|
||||
|
||||
create_table :analytics_page_cells, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
|
||||
t.date :day, null: false
|
||||
t.string :page_path, null: false
|
||||
t.string :device, null: false
|
||||
t.integer :cell_x, null: false
|
||||
t.integer :cell_y, null: false
|
||||
t.integer :click_count, null: false, default: 0
|
||||
t.timestamps
|
||||
end
|
||||
add_index :analytics_page_cells,
|
||||
%i[day page_path device cell_x cell_y],
|
||||
unique: true,
|
||||
name: "index_analytics_page_cells_unique"
|
||||
|
||||
create_table :analytics_page_stats, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
|
||||
t.date :day, null: false
|
||||
t.string :page_path, null: false
|
||||
t.string :device, null: false
|
||||
t.integer :pageview_count, null: false, default: 0
|
||||
t.integer :scroll_samples, null: false, default: 0
|
||||
t.integer :scroll_sum_pct, null: false, default: 0
|
||||
t.integer :max_scroll_pct, null: false, default: 0
|
||||
t.timestamps
|
||||
end
|
||||
add_index :analytics_page_stats,
|
||||
%i[day page_path device],
|
||||
unique: true,
|
||||
name: "index_analytics_page_stats_unique"
|
||||
end
|
||||
end
|
||||
Generated
+40
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2026_08_20_191000) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2026_08_20_200000) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
@@ -51,6 +51,45 @@ ActiveRecord::Schema[7.2].define(version: 2026_08_20_191000) do
|
||||
t.index ["username"], name: "index_admin_accounts_on_username", unique: true
|
||||
end
|
||||
|
||||
create_table "analytics_events", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "page_path", null: false
|
||||
t.string "device", null: false
|
||||
t.string "event_type", null: false
|
||||
t.decimal "x_pct", precision: 6, scale: 2
|
||||
t.decimal "y_pct", precision: 6, scale: 2
|
||||
t.decimal "scroll_pct", precision: 6, scale: 2
|
||||
t.datetime "occurred_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["event_type", "occurred_at"], name: "index_analytics_events_on_event_type_and_occurred_at"
|
||||
t.index ["occurred_at"], name: "index_analytics_events_on_occurred_at"
|
||||
end
|
||||
|
||||
create_table "analytics_page_cells", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.date "day", null: false
|
||||
t.string "page_path", null: false
|
||||
t.string "device", null: false
|
||||
t.integer "cell_x", null: false
|
||||
t.integer "cell_y", null: false
|
||||
t.integer "click_count", default: 0, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["day", "page_path", "device", "cell_x", "cell_y"], name: "index_analytics_page_cells_unique", unique: true
|
||||
end
|
||||
|
||||
create_table "analytics_page_stats", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.date "day", null: false
|
||||
t.string "page_path", null: false
|
||||
t.string "device", null: false
|
||||
t.integer "pageview_count", default: 0, null: false
|
||||
t.integer "scroll_samples", default: 0, null: false
|
||||
t.integer "scroll_sum_pct", default: 0, null: false
|
||||
t.integer "max_scroll_pct", default: 0, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["day", "page_path", "device"], name: "index_analytics_page_stats_unique", unique: true
|
||||
end
|
||||
|
||||
create_table "app_announcements", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "kind", default: "info", null: false
|
||||
t.string "severity", default: "info", null: false
|
||||
|
||||
Reference in New Issue
Block a user