Skip to content

Fix snapshot drift and SPA analytics - #34

Merged
smiggleworth merged 1 commit into
mainfrom
fix/restore-google-analytics
Aug 1, 2026
Merged

Fix snapshot drift and SPA analytics#34
smiggleworth merged 1 commit into
mainfrom
fix/restore-google-analytics

Conversation

@smiggleworth

Copy link
Copy Markdown
Contributor

Summary

  • enforce installed API, package metadata, and CLI snapshot drift in the test suite while keeping scripts deleted and package versions off rendered pages
  • disable the automatic GA4 page view and emit one manual event for initial load plus committed path/query SPA navigation
  • verify every generated document retains the GA property and does not render installed package versions

Verification

  • npm run check
  • 32 unit tests passed
  • 340/340 SSG routes generated with zero failures
  • generated-output contract passed

Browser note

The built homepage loaded in the browser, but the browser connection disconnected before the dataLayer history walkthrough could complete. Payload, immediate subscription, path/query tracking, hash suppression, fallback queuing, and outer-layout coverage are enforced by unit tests.

Copilot AI review requested due to automatic review settings August 1, 2026 13:31
@smiggleworth
smiggleworth merged commit a27774b into main Aug 1, 2026
2 checks passed
@smiggleworth
smiggleworth deleted the fix/restore-google-analytics branch August 1, 2026 13:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR moves “snapshot drift” and static-output validation from ad-hoc scripts into the Vitest suite, removes rendering of installed package versions from docs/marketing pages, and introduces SPA-aware GA4 page_view tracking (manual initial + committed path/query navigations).

Changes:

  • Replace scripts-based drift/static checks with unit/contract tests (installed API/CLI snapshot + generated output assertions).
  • Add a persistent route-analytics layout and SPA page_view emission while disabling GA4 auto page views.
  • Remove displayed package version metadata from rendered pages while retaining internal peer metadata snapshots.

Reviewed changes

Copilot reviewed 31 out of 33 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tsconfig.json Typecheck tests/** now that scripts are removed.
tests/static-output-contract.test.ts Inlines generated-style registry checks as a unit test helper.
tests/route-analytics.test.ts Adds unit coverage for SPA analytics payload/emit/route subscription behavior.
tests/package-snapshot-contract.test.ts Enforces installed vs recorded API/CLI/peer snapshot drift in tests.
tests/generated-output-contract.test.ts Adds a post-build contract test for GA config + “no version strings in HTML”.
tests/docs-catalog.test.ts Removes assertions that depended on rendered/derived package versions.
src/styles.css Removes styles tied to version/badge UI that no longer renders.
src/pages/route-analytics.tsx Implements GA4 page_view payload creation + route-driven emission.
src/pages/marketing/platform.tsx Stops rendering package versions; keeps peer-boundary table.
src/pages/marketing/components.tsx Removes version column/types from the marketing package table.
src/pages/docs/usage-guide.ts Removes version-pinned CLI string from copy; updates command list.
src/pages/docs/types.ts Removes version from PackageReference to avoid rendering versions.
src/pages/docs/release-notes.ts Updates upgrade guidance copy to reflect “installed set” language.
src/pages/docs/page.tsx Removes package badges + published versions section from docs pages.
src/pages/docs/package-versions.ts Deleted generated “versions + peers” snapshot source.
src/pages/docs/package-peers.ts Adds a peers-only snapshot used for internal contract/table data.
src/pages/docs/lucide-gallery.tsx Removes lucide version text/badge from page.
src/pages/docs/lucide-api-page.tsx Removes version text/badge from lucide API page.
src/pages/docs/content-overrides.ts Removes hardcoded/versioned copy and references to published version tables.
src/pages/docs/catalog.ts Removes dependency on package-versions and publishedVersions export; updates descriptions/TOC.
src/pages/docs/api-snapshot.ts Updates snapshot header comment (no functional change).
src/pages/docs/api-page.tsx Removes version mentions/badges from generated API pages.
src/pages/docs/api-manifest.ts Updates manifest header comment (no functional change).
src/pages/_routes.tsx Wraps all routes with RouteAnalyticsLayout (persistent outer layout).
scripts/verify-static-output.ts Deleted; replaced by generated-output contract test(s).
scripts/generated-style-contract.ts Deleted; logic moved into tests.
scripts/generate-cli-reference.ts Deleted; drift now enforced via tests.
scripts/generate-api-snapshot.ts Deleted; drift now enforced via tests.
scripts/format-generated.ts Deleted along with the generator scripts.
README.md Updates workflow/docs to reflect new test/build/drift approach.
package.json Reworks lint/test/check scripts and removes tsx dependency.
package-lock.json Removes tsx entry to match package.json.
index.html Adds GA tag with send_page_view: false configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment on lines +16 to +20
"test:unit": "vp test run --exclude tests/generated-output-contract.test.ts",
"test:static": "vp test run tests/generated-output-contract.test.ts",
"test": "npm run test:unit && npm run test:static",
"typecheck": "tsc --noEmit",
"check": "npm run fmt:check && npm run lint && npm run typecheck && npm run docs:drift && npm run test:unit && npm run build && npm run verify:static",
"check": "npm run fmt:check && npm run lint && npm run typecheck && npm run test:unit && npm run build && npm run test:static",
Comment on lines +1 to +23
import { readFileSync, readdirSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
import { docsCatalog } from '../src/pages/docs/catalog';
import { marketingRouteMetadata } from '../src/pages/marketing/_routes';

interface StaticMetadata {
readonly totalRoutes: number;
readonly successful: number;
readonly failed: number;
}

const root = process.cwd();
const dist = resolve(root, 'dist');

describe('generated output', () => {
it('contains every route and the manual GA4 page-view configuration', () => {
const metadata = JSON.parse(
readFileSync(resolve(dist, 'metadata.json'), 'utf8')
) as StaticMetadata;
const expectedRoutes =
docsCatalog.length + Object.keys(marketingRouteMetadata).length;

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.

2 participants