fix[sdks][personalization]: ENG-13927 dedupe personalization and A/B helper scripts across Content components - #4884
floating-dynamo wants to merge 4 commits into
Conversation
…helper scripts across Content components
🦋 Changeset detectedLatest commit: 0d16e7e The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
View your CI Pipeline Execution ↗ for commit a499dde
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 322b96d. Configure here.
|
@floating-dynamo The code review found 3 issues on ENG-13927-dedup-scripts. The first two would break Qwik in production.
|
Yes thanks for pointing out, looking into these |
…cripts and keep helper script for bound symbol content
There was a problem hiding this comment.
Builder reviewed your changes and found 2 potential issues 🔴
Review Details
Incremental Code Review Summary
This update adds a helper to detect whether Symbol content is embedded in its parent or supplied through bindings, with tests for both cases. It also adds a Qwik code-generation rewrite that gives the optional BuilderScriptsContext read a default value. The broader change continues to provide opt-in helper-script deduplication across nested Content trees.
The Symbol distinction is a useful refinement, but the update introduces two confirmed compatibility issues. Risk: Standard — this affects SSR behavior and public SDK exports. 🔴 HIGH: ContentVariants now unconditionally consumes React context despite being generated as an RSC server component. 🟡 MEDIUM: the React Native-specific export override does not expose the newly advertised BuilderScripts export. These should be addressed before merge.
🧪 Browser testing: Skipped — dev server unavailable; dependency setup fails while building isolated-vm, and no dev command is configured. Retried once; server remained stopped.
… script server-only in BuilderScripts
There was a problem hiding this comment.
Builder reviewed your changes — no new findings
Review Details
Incremental Code Review Summary
This update adds the missing BuilderScripts import and export to the React Native-specific SDK entrypoint, resolving the prior React Native API-availability issue. Two independent code reviews found no new actionable defects in the current changes, including the React SSR-versus-hydration helper behavior. The React Native review thread has been resolved.
The prior RSC issue remains unchanged: ContentVariants is still an RSC server component that unconditionally invokes useContext, so its existing review comment remains open. I have not reposted it. Risk: Standard — the feature affects SSR script injection across SDK targets; the outstanding high-severity RSC finding remains blocking.
🧪 Browser testing: Skipped — setup fails building isolated-vm; proxy is stopped and no dev command is configured. Restart was attempted once and the server remained unavailable.

Motivation
Contentwith a Variant Container or A/B test inlined its own copy of the helper scripts (~6.8KB each), so pages with a multiple content components shipped the same scripts several times.BuilderScriptswrapper that emits the helpers once for everyContentinside it (nested wrappers emit nothing), and stopped inlined symbols from adding a second copy inside a singleContent.Link to JIRA ticket (if applicable):
https://builder-io.atlassian.net/browse/ENG-13927
Screenshot/Clip
Clip - https://clips.agent-native.com/share/7KXcQCxC20ir?ref=clip_share
Note
Medium Risk
Changes when variant/personalization init scripts run across SSR and hydration; mis-wrapping pages could leave helpers missing, while incorrect symbol inlining logic could skip scripts for bound symbols.
Overview
Adds an opt-in
BuilderScriptswrapper that inlines the personalization (builderio-init-personalization-variants-fns) and A/B test (builderio-init-variants-fns) helper scripts once for all nestedContentcomponents, instead of repeating ~6.8KB perContent. NestedBuilderScriptsemit nothing; context-based dedupe applies to React, Vue, Svelte, Solid, and Qwik—Next.js RSC, Angular, and React Native still render children only and eachContentkeeps emitting as before.Contentnow skips those init scripts when a parentBuilderScriptshas already setscriptsEmitted. Separately, symbol blocks passisContentInlinedInParentso nestedContentdoes not re-emit personalization helpers when the symbol JSON is already in the parent (bound/dynamic symbol content still fetches and may emit). Docs and React README describe the layout pattern; Qwik gets a defaultuseContextfor optionalBuilderScripts.Reviewed by Cursor Bugbot for commit 0d16e7e. Bugbot is set up for automated code reviews on this repo. Configure here.