Nt 2587 create multi router compatible automatic page view event emission#183
Merged
Lotfi Anwar L Arif (Lotfi-Arif) merged 6 commits intomainfrom Mar 24, 2026
Conversation
- Implement NextPagesAutoPageTracker component for automatic page event emission in Next.js Pages Router apps - Add payload composition utilities and types for static/dynamic enrichment - Export router adapter as isolated subpath entry point - Provide unit tests for auto page emission and payload merging - Update README with usage and enrichment examples - Extend build and test configs for router adapter support
- Add NextAppAutoPageTracker for Next.js App Router - Add ReactRouterAutoPageTracker for react-router-dom - Add TanStackRouterAutoPageTracker for @tanstack/react-router - Include tests for each tracker covering emission behavior and payload merging
Charles Hudson (phobetron)
approved these changes
Mar 24, 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.
Core Auto-Page Emission
pagePayloadandgetPagePayload, merged before callingoptimization.page(...).Router Adapters
@contentful/optimization-react-web/router/next-pages.NextPagesAutoPageTrackerfor mounting inpages/_app.tsx, with allnext/routerusage isolated to the adapter subpath.@contentful/optimization-react-web/router/next-app.NextAppAutoPageTrackerfor mounting in a client provider/layout component, with allnext/navigationusage isolated to the adapter subpath.@contentful/optimization-react-web/router/react-router.ReactRouterAutoPageTrackerfor mounting once inside thereact-router-domrouter tree.@contentful/optimization-react-web/router/tanstack-router.TanStackRouterAutoPageTrackerfor mounting once inside the TanStack router tree.Package Structure and Types
Testing
rstestcoverage for shared emitter behavior and all four router adapters.Docs and Dev Harness
Verification
typecheck,eslint,prettier, and unit tests.