PhoenixKitWebAnalytics. Web. TrackController
(PhoenixKitWebAnalytics v0.2.0)
Copy Markdown
View Source
Two optional client-side entry points, for the cases the plug can't see.
Neither is needed for ordinary server-rendered traffic — that's
PhoenixKitWebAnalytics.Plug, which needs no client cooperation at all.
Both are off by default: they only accept hits when
web_analytics_beacon_enabled is on.
POST /phoenix-kit/analytics/event— custom events ("signup","add_to_cart") reported bywindow.phoenixKitAnalytics(name, props), the small snippet rendered byPhoenixKitWebAnalytics.Web.Beacon.beacon/1.GET /phoenix-kit/analytics/pixel.gif— a 1×1 GIF for pages the plug never runs for: full-page CDN caches, statically exported pages, AMP.
Trust boundary
These endpoints are public and unauthenticated. What a payload can and cannot
influence is enforced in PhoenixKitWebAnalytics.Web.BeaconPayload.
Beyond that: anyone can POST here and inflate counts, exactly as with every client-side analytics product. Leave the beacon off unless you need custom events, and put per-IP rate limiting in front of it if you do.
Both actions answer the same way whether or not the beacon is enabled — a disabled beacon is not an error the page should surface, and the response tells a caller nothing about the site's configuration.
Summary
Functions
Records a custom event (or a client-reported page view) from the beacon.
Records a page view and returns a 1×1 GIF.