Upgrade heatmaps stile Hotjar: movimenti mouse e anteprima pagina live.

Traccia i movimenti aggregati, overlay a gradienti sull’iframe della pagina e toggle click/move in admin.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-20 23:03:12 +02:00
co-authored by Cursor
parent 8a07c5d569
commit b84321346f
26 changed files with 361 additions and 96 deletions
@@ -22,7 +22,8 @@ RSpec.describe "Admin analytics", type: :request do
device: "desktop",
cell_x: 10,
cell_y: 15,
click_count: 4
click_count: 4,
move_count: 40
)
end
@@ -31,12 +32,14 @@ RSpec.describe "Admin analytics", type: :request do
expect(response).to have_http_status(:ok)
expect(response.body).to include("/prezzi")
expect(response.body).to include("12")
expect(response.body).to include("40")
end
it "mostra la heatmap di una pagina" do
get admin_analytics_page_path, params: { page_path: "/prezzi" }
expect(response).to have_http_status(:ok)
expect(response.body).to include("admin-heatmap")
expect(response.body).to include("admin-heatmap-frame")
expect(response.body).to include("/prezzi")
end
end
+11 -1
View File
@@ -21,6 +21,15 @@ RSpec.describe "Analytics ingest", type: :request do
y: 50,
ts: Time.current.to_i * 1000
},
{
type: "move",
path: "/clubs/461d369a-104c-4d3c-8860-1518b4e95d35",
device: "desktop",
x: 40,
y: 30,
n: 12,
ts: Time.current.to_i * 1000
},
{
type: "scroll",
path: "/clubs/461d369a-104c-4d3c-8860-1518b4e95d35",
@@ -34,12 +43,13 @@ RSpec.describe "Analytics ingest", type: :request do
expect(response).to have_http_status(:accepted)
body = JSON.parse(response.body)
expect(body["accepted"]).to eq(3)
expect(body["accepted"]).to eq(4)
expect(AnalyticsEvent.count).to eq(0)
expect(AnalyticsPageStat.find_by(page_path: "/clubs/:id").pageview_count).to eq(1)
expect(AnalyticsPageStat.find_by(page_path: "/clubs/:id").max_scroll_pct).to eq(80)
expect(AnalyticsPageCell.where(page_path: "/clubs/:id").sum(:click_count)).to eq(1)
expect(AnalyticsPageCell.where(page_path: "/clubs/:id").sum(:move_count)).to eq(12)
end
it "rifiuta path esclusi" do