Problem
Stacks now gates remote integrations through APP_ENV in stacksjs/stacks#2792. Included server adapters receive the normalized environment and can attach it to events. The AnalyticsHQ browser tracker has no equivalent metadata contract.
public/script.js currently reads only data-site, data-respect-dnt, and data-vitals from its script tag. Adding data-environment in Stacks today would look configured but be ignored by the tracker.
Proposed contract
Support one optional script attribute:
<script defer src="https://analyticshq.org/script.js" data-site="APP_ID" data-environment="staging"></script>When present, attach the value to every pageview, custom event, and Web Vitals payload. When absent, preserve existing payloads and behavior.
The tracker should treat this as metadata only. It must not decide whether reporting is enabled. Stacks performs its environment allowlist check before injecting the script.
Acceptance criteria
data-environmentis read once from the current tracker script.- Pageviews, custom events, and Web Vitals carry the same value.
- Missing attributes preserve current payloads.
- Tests cover the three event paths and escaping or validation at the ingest boundary.
- Tracking documentation lists the attribute.
Related: stacksjs/stacks#2792
Blocked Stacks slice: stacksjs/stacks@6b9ae20