Skip to content

🐞 fix(tracking): Support view tracking for OptimizedEntry wrappers#321

Merged
Charles Hudson (phobetron) merged 1 commit into
mainfrom
NT-3484_fix-react-sdk-view-tracking
Jun 16, 2026
Merged

🐞 fix(tracking): Support view tracking for OptimizedEntry wrappers#321
Charles Hudson (phobetron) merged 1 commit into
mainfrom
NT-3484_fix-react-sdk-view-tracking

Conversation

@phobetron

@phobetron Charles Hudson (phobetron) commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

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.

What changed

  • 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.

Validation

  • 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]

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-inc-38d59fb8d7

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Low
Software Management Finding Software Management Findings -
Total 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@phobetron Charles Hudson (phobetron) merged commit 3a78701 into main Jun 16, 2026
39 of 40 checks passed
@phobetron Charles Hudson (phobetron) deleted the NT-3484_fix-react-sdk-view-tracking branch June 16, 2026 18:27
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