🐞 fix(tracking): Support view tracking for OptimizedEntry wrappers#321
Merged
Charles Hudson (phobetron) merged 1 commit intoJun 16, 2026
Merged
Conversation
This PR fixes automatic view tracking for React SDK `OptimizedEntry` wrappers that render with `display: contents`, and cleans up the React Web SDK reference implementation so it uses `OptimizedEntry` as the single source of entry metadata. - Added Web SDK support for tracking `display: contents` entry wrappers: - normal elements still use `IntersectionObserver` directly; - single rendered child wrappers observe that child while reporting the logical wrapper; - multi-child/text entries use Range-based aggregate visibility. - Refactored React reference entry rendering to remove manual entry metadata assembly. - Added React-style `OptimizedEntry` props for configurable Web SDK tracking attributes. - Kept derived entry metadata owned by `OptimizedEntry`. - Tightened E2E assertions so manual view tracking is not mistaken for automatic tracking. - Updated Web SDK bundle size budgets to match the measured output. - `pnpm lint` - `pnpm --filter @contentful/optimization-web typecheck` - `pnpm --filter @contentful/optimization-web test:unit` - `pnpm --filter @contentful/optimization-web build` - `pnpm --filter @contentful/optimization-web size:check` - `pnpm build:pkgs` - `pnpm --filter @contentful/optimization-react-web typecheck` - `pnpm --filter @contentful/optimization-react-web test:unit` - `pnpm --filter @contentful/optimization-react-web build` - `pnpm --filter @contentful/optimization-react-web size:check` - `pnpm implementation:run -- react-web-sdk implementation:install` - `pnpm implementation:run -- react-web-sdk typecheck` - `pnpm implementation:run -- react-web-sdk build` - `pnpm implementation:run -- react-web-sdk implementation:test:e2e:run` React reference E2E: `84 passed`. [[NT-3484](https://contentful.atlassian.net/browse/NT-3484)]
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
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
This PR fixes automatic view tracking for React SDK
OptimizedEntrywrappers that render withdisplay: contents, and cleans up the React Web SDK reference implementation so it usesOptimizedEntryas the single source of entry metadata.What changed
display: contentsentry wrappers:IntersectionObserverdirectly;OptimizedEntryprops for configurable Web SDK tracking attributes.OptimizedEntry.Validation
pnpm lintpnpm --filter @contentful/optimization-web typecheckpnpm --filter @contentful/optimization-web test:unitpnpm --filter @contentful/optimization-web buildpnpm --filter @contentful/optimization-web size:checkpnpm build:pkgspnpm --filter @contentful/optimization-react-web typecheckpnpm --filter @contentful/optimization-react-web test:unitpnpm --filter @contentful/optimization-react-web buildpnpm --filter @contentful/optimization-react-web size:checkpnpm implementation:run -- react-web-sdk implementation:installpnpm implementation:run -- react-web-sdk typecheckpnpm implementation:run -- react-web-sdk buildpnpm implementation:run -- react-web-sdk implementation:test:e2e:runReact reference E2E:
84 passed.[NT-3484]