Skip to content

Comments

Nt 2570 create a react web vanilla reference implementation based on the web sdk#147

Merged
phobetron merged 28 commits intomainfrom
NT-2570-create-a-react-web-vanilla-reference-implementation-based-on-the-web-sdk
Feb 25, 2026
Merged

Nt 2570 create a react web vanilla reference implementation based on the web sdk#147
phobetron merged 28 commits intomainfrom
NT-2570-create-a-react-web-vanilla-reference-implementation-based-on-the-web-sdk

Conversation

@Lotfi-Arif
Copy link
Contributor

@Lotfi-Arif Lotfi-Arif commented Feb 22, 2026

Summary

Adds and polishes the React Web reference implementation in implementations/web-react using @contentful/optimization-web directly (local React adapter only).

Included

  • Provider + hooks adapter pattern for SDK access/state
  • Personalization rendering (identified/unidentified + nested variants)
  • Merge-tag rich text rendering
  • Analytics event stream/count display
  • Identify/reset flow with reload persistence checks
  • SPA page-event navigation checks
  • Consent gating behavior + E2E:
    • page events allowed without consent
    • component view events gated until consent

Validation

  • pnpm lint
  • pnpm --dir implementations/web-react typecheck
  • pnpm --dir implementations/web-react test:e2e

Follow-ups

  • React Web Live Updates Parity scenarios
  • React Web Offline Queue + Recovery E2E

- Add entry fetching and error handling
- Add identify/reset user logic
- Render entries using ContentEntry and NestedContentEntry
- Wrap App in OptimizationProvider in main.tsx
- Update types for ContentfulEntry to use SDK Entry type
- Fix OptimizationProvider context value typo (isReadable → isReady)
- Add Playwright config and two e2e tests for identified and
  unidentified user variants
- Refactor App to separate auto and manually observed entries
- Implement consent controls and display personalization count
- Enable auto entry view tracking in optimization config
- Update ContentEntry and NestedContentItem to support tracking
  attributes and manual observation
- Remove unused analytics tracking from entry components
@wiz-inc-38d59fb8d7
Copy link

wiz-inc-38d59fb8d7 bot commented Feb 22, 2026

Wiz Scan Summary

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

View scan details in Wiz

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

- Add @contentful/rich-text-react-renderer and
  @contentful/rich-text-types
- Update test:e2e script to run Playwright tests directly
- Allow Playwright baseURL to be set via environment variable
- Simplify Contentful type definitions and remove unused helpers
- Update fetchEntry to use getEntry instead of getEntries
- Inline isEntry logic and remove isContentfulEntry usage
- Update RichTextNode typing in RichTextRenderer
- Delete src/config/env.ts and update imports
- Read env vars directly with fallback defaults in code
- Update README with new env handling and local mock instructions
- Refactor App to use routes and split home/page-two views.
- Emit page events on route changes using location.pathname.
- Add e2e test for navigation page events.
- Extract entry IDs and route paths to config files.
- Improve line wrapping in README for clarity
- Simplify await expect.poll usage in navigation-page-events.spec.ts
- Reorder imports and define embedded entry node type in
  RichTextRenderer
- Use nullish coalescing (??) for env var fallbacks in
  createOptimization
- Remove unused generic from ContentEntrySkeleton type
Update Playwright baseURL default to localhost:3001
- Move isRecord to utils/typeGuards and use throughout codebase
- Add getContentfulConfigError for clearer Contentful env var errors
- Support PUBLIC_OPTIMIZATION_LOG_LEVEL with sensible defaults
- Update README E2E instructions and usage examples
- Improve event display keying and RichTextRenderer spacing
- Add DEV to ImportMetaEnv typings
@Lotfi-Arif Lotfi-Arif marked this pull request as ready for review February 24, 2026 13:27
needs: [setup, changes, build]
if: needs.changes.outputs.e2e_web_react == 'true'
steps:
- uses: namespacelabs/nscloud-checkout-action@v8

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Main Pipeline' step
Uses Step
uses 'namespacelabs/nscloud-checkout-action' with ref 'v8', not a pinned commit hash
node-version-file: '.nvmrc'
package-manager-cache: false

- uses: pnpm/action-setup@v4

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Main Pipeline' step
Uses Step
uses 'pnpm/action-setup' with ref 'v4', not a pinned commit hash
- uses: pnpm/action-setup@v4

- name: Set up caches (Namespace)
uses: namespacelabs/nscloud-cache-action@v1

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Main Pipeline' step
Uses Step
uses 'namespacelabs/nscloud-cache-action' with ref 'v1', not a pinned commit hash
Comment on lines +34 to +50
function isMergeTagEntry(entry: unknown): entry is MergeTagEntry {
if (!isRecord(entry)) {
return false
}

const { sys } = entry
if (!isRecord(sys) || !isRecord(sys.contentType)) {
return false
}

const { contentType } = sys
if (!isRecord(contentType) || !isRecord(contentType.sys)) {
return false
}

return contentType.sys.id === 'nt_mergetag'
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could possibly import MergeTagValueResolver and use MergeTagValueResolver.isMergeTagEntry(...) or directly use MergeTagEntry.safeParse(...).success to avoid having to know the shape of a merge tag entry. I'd be interested if you might have any ideas for a better facility for these kind of guards that we could expose from the SDKs directly. I have ideas but I don't want to tempt you to implement them in this PR 😛

While we could also supply type guards for records, links, and other general CTFL entry stuff, we'd probably want to avoid exporting those, to reduce maintenance work for anything that isn't directly related to P13n or A7s.

Copy link
Collaborator

@phobetron phobetron left a comment

Choose a reason for hiding this comment

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

🌱

@phobetron phobetron merged commit 45d248f into main Feb 25, 2026
28 checks passed
@phobetron phobetron deleted the NT-2570-create-a-react-web-vanilla-reference-implementation-based-on-the-web-sdk branch February 25, 2026 10: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.

2 participants