feat(analytics): restore Google Analytics and overseer frontend tracking - #331
feat(analytics): restore Google Analytics and overseer frontend tracking#331ety001 wants to merge 6 commits into
Conversation
Match wallet-legacy gtag injection and overseer.collect route/user_action/login events, relaying overseer through the server so browsers do not hit api.steemit.com.
…s CSRF The csrf_token cookie was only issued by /api/auth/challenge (login flow), so anonymous visitors' overseer route events were silently rejected 403. The proxy now mints a rolling stateless HMAC token (Web Crypto, byte-identical to the Node generator) on every document response; shared CSRF_SECRET keeps it valid across instances and self-heals after secret rotation.
Match wallet-legacy server-html.jsx (and condenser PR #4010): plain script tags rendered by the server layout so gtag loads at parse time with no hydration dependency. Both scripts carry the per-request CSP nonce. SPA pageviews stay in a small client component using next/navigation's usePathname — next-intl's throws outside NextIntlClientProvider during SSR, and the resulting error recovery silently swallowed the sibling scripts.
Post-review audit fixes (added to this PR)Full audit of the original commits found and fixed four issues: 1. Anonymous tracking was silently dropped (CSRF cookie never issued)The 2. gtag injected via
|
Pages were already dynamic as a side effect of the CSP-nonce headers() call in the layout; this makes the invariant explicit (condenser #4012 parity) so a future refactor of the nonce mechanism can never silently turn routes static and freeze or drop the runtime GOOGLE_ANALYTICS_ID.
collectOverseer reused withFailover, so a dead overseer upstream with multiple STEEM_RPC_URL entries would retry every URL per event (a warn per URL per event) and rotate the shared currentUrlIndex, moving real chain traffic to a different RPC. Analytics now makes one attempt against the current RPC and gives up; the warn-once flag already bounds logging.
|
Follow-up closed: With this, every actionable finding from the audit is fixed; remaining items are the accepted trade-offs listed above. |
Summary
GOOGLE_ANALYTICS_ID/SDC_GOOGLE_ANALYTICS_ID(legacyserver-html.jsx/JsPlugins.js), including SPA pageviews and CSP allowlists for GTM/GA.route,user_action,user_login) with the same measurement/tags/fields as wallet-legacy, relayed via/api/analytics/overseerso browsers do not callapi.steemit.comdirectly.Test plan
GOOGLE_ANALYTICS_ID— no gtag script, pages still load under CSPGOOGLE_ANALYTICS_IDto a validG-/UA-id — script loads, SPA navigations fire pageviewsrouteevents (tag +is_login+user_indexpermlink)user_actionpayloads match legacyuser_loginwithout delaying the response