PhoenixKitWebAnalytics.Routes (PhoenixKitWebAnalytics v0.2.0)

Copy Markdown View Source

Route macros for the module's six admin pages and two public collection endpoints. Returned from PhoenixKitWebAnalytics.route_module/0; PhoenixKit splices the admin routes inside its own live_session :phoenix_kit_admin (auth + admin layout applied automatically) and the public ones near the top of the host router.

Both a localized (/:locale/admin/...) and a non-localized set are defined, as PhoenixKit requires — each route needs a unique :as.

Why the collection endpoints skip :browser

generate/1 pipes through :phoenix_kit_api (JSON, no session, no CSRF) rather than :browser. The beacon posts with navigator.sendBeacon, which cannot carry a CSRF token, and the pixel is an <img> request — neither has a session to fetch or a form to protect. See PhoenixKitWebAnalytics.Web.TrackController for the trust boundary that replaces it.

Summary

Functions

Localized admin routes (inside the /:locale scope).

Non-localized admin routes.

Public collection endpoints — the optional beacon and pixel.

Functions

admin_locale_routes()

Localized admin routes (inside the /:locale scope).

admin_routes()

Non-localized admin routes.

generate(url_prefix)

Public collection endpoints — the optional beacon and pixel.

These are specific (non-catch-all) paths, so they belong in generate/1.