Skip to content

feat(docs): GA4 install on mcp.wyre.ai (env-gated) - #113

Draft
asachs01 wants to merge 1 commit into
mainfrom
feat/ga4-docs
Draft

feat(docs): GA4 install on mcp.wyre.ai (env-gated)#113
asachs01 wants to merge 1 commit into
mainfrom
feat/ga4-docs

Conversation

@asachs01

Copy link
Copy Markdown
Collaborator

GA4 install — mcp.wyre.ai docs only (env-gated)

Wires GA4 (G-V3W6M1YEHL — same property as wyre.ai + conduit.wyre.ai + conduit /docs) into msp-claude-plugins/docs/src/layouts/BaseLayout.astro. Per Aaron's D6 ruling, the install is env-gated to production builds for https://mcp.wyre.ai only.

DRAFT / DO NOT MERGE until Aaron's explicit approval + after mcp-gateway PR #190 (staging-gate) is merged and the gate is live. Same gating convention as PRs #189 / #194.

Gate

const enableGA = import.meta.env.PROD && import.meta.env.SITE === 'https://mcp.wyre.ai';

Dual-gate is intentional. The default SITE_URL in this repo's astro.config.mjs is 'https://mcp.wyre.ai', so a SITE-only check would also match local dev. The PROD half excludes dev/preview; the SITE half excludes the GitHub Pages preview build (SITE_URL=https://wyre-technology.github.io).

Build PROD SITE GA fires?
npm run dev (no envs) false https://mcp.wyre.ai (default)
npm run preview (no envs) true https://mcp.wyre.ai (default) ❌ ¹
GitHub Pages build (SITE_URL set) true https://wyre-technology.github.io
gateway Docker build (production) true https://mcp.wyre.ai

¹ Note: astro preview runs the production build locally, so PROD=true there. Since SITE would still be https://mcp.wyre.ai by default, technically GA would fire on a local astro preview with no envs — but astro preview is a development tool not a deployed surface, and adding a third gate for it would be over-engineering. If this becomes a concern, document it for the rollback playbook.

Where it lives

  • File: msp-claude-plugins/docs/src/layouts/BaseLayout.astro (the existing root wrapper used by every page).
  • Injection point: inside <head>, after <SEOHead>, before the dark-mode inline script. Renders nothing when enableGA is false (the <Fragment> evaluates to empty).

Subresource Integrity — intentionally not used

gtag.js is loaded without SRI. Google continuously regenerates that script to reflect property-configuration changes and does not publish integrity hashes for it, so pinning SRI would break GA on every upstream update. Trust model is googletagmanager.com TLS + the published canonical snippet — matches Angela's wyre.ai / conduit.wyre.ai / conduit /docs installs. Inline justifying comment in BaseLayout.astro so the next maintainer sees the reasoning.

CSP

None present in this repo — confirmed by grep across the docs/ tree. No policy update needed; the original task's "if no CSP, skip" branch applies.

Build verification

npx astro build runs clean locally — 106 pages built in 1.08s. No type errors. The conditional renders nothing in the non-prod / non-mcp.wyre.ai paths; HTML diff verified by inspecting dist/ (no gtag in the GH-Pages-style build).

Scope discipline

  • Single-purpose. Only src/layouts/BaseLayout.astro is touched.
  • No astro.config.mjs change. No new dependency. No CSP addition (none existed).
  • Other modifications in the working tree (public/og-image.png) are pre-existing WIP and not included in this PR.

Sequencing

This PR rides behind mcp-gateway PR #190 (forge staging-gate). It is NOT to be merged before #190 lands and the gate is live, per the cadre's PR-as-gate convention.

Wires Google Analytics 4 (property G-V3W6M1YEHL — same as wyre.ai,
conduit.wyre.ai, conduit /docs) into BaseLayout.astro. Dual-gated:

  enableGA = import.meta.env.PROD && import.meta.env.SITE === 'https://mcp.wyre.ai'

so GA only loads on the mcp.wyre.ai Docker build that ships to production.
Excludes local dev (PROD=false) and the GitHub Pages preview build
(SITE_URL=https://wyre-technology.github.io). Default SITE in astro.config
is 'https://mcp.wyre.ai', so the PROD half of the gate is what keeps
local dev uninstrumented.

gtag.js is loaded without Subresource Integrity by design — Google
regenerates the script continuously and never publishes integrity hashes,
so pinning SRI would break GA on every upstream update. Trust model is
googletagmanager.com TLS + the published canonical snippet (matches
Angela's wyre.ai/conduit installs). Inline justification comment in
BaseLayout.astro for the next maintainer.

No CSP found in this repo — no policy update needed.

Single-purpose PR. Draft + gated on Aaron; will not merge before
mcp-gateway PR #190 (forge staging-gate) lands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant