Fix snapshot drift and SPA analytics - #34
Merged
Merged
Conversation
There was a problem hiding this comment.
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 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; | ||
|
|
smiggleworth
added a commit
that referenced
this pull request
Aug 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
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.