Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[templates/nextjs-xmcloud][sitecore-jss] Update render process in normal mode for component level personalization #1844

Merged
merged 17 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Our versioning strategy is as follows:
* `[sitecore-jss]` _GraphQLRequestClient_ now can accept custom 'headers' in the constructor or via _createClientFactory_ ([#1806](https://github.com/Sitecore/jss/pull/1806))
* `[templates/nextjs]` Removed cors header for API endpoints from _lib/next-config/plugins/cors-header_ plugin since cors is handled by API handlers / middlewares ([#1806](https://github.com/Sitecore/jss/pull/1806))
* `[sitecore-jss-nextjs]` Updates to Next.js editing integration to further support secure hosting scenarios (on XM Cloud & Vercel) ([#1832](https://github.com/Sitecore/jss/pull/1832))
* `[templates/nextjs-xmcloud]` `[sitecore-jss]` Updates the render process in normal mode for component level personalization. ([#1844](https://github.com/Sitecore/jss/pull/1844))
Copy link
Contributor

@art-alexeyenko art-alexeyenko Jul 22, 2024

Choose a reason for hiding this comment

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

One last thing: please resolve changelog merge conflicts and reformat this entry as "AB testing support".
We'll have middleware and preview mode added in addition to the current change, best to have them listed under one roof

* `[sitecore-jss]` `[nextjs-xmcloud]` DictionaryService can now use a `site` GraphQL query instead of `search` one to improve performance. This is currently only available for XMCloud deployments and is enabled with `nextjs-xmcloud` add-on by default ([#1804](https://github.com/Sitecore/jss/pull/1804))

### 🛠 Breaking Change
Expand Down
15 changes: 15 additions & 0 deletions docs/upgrades/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,18 @@
}
...
```

* To enable AB testing and component level personalization support in JSS, ensure _componentVariantIds_ are passed to _personalizeLayout_ function call:

```ts
// Get variant(s) for personalization (from path)
const personalizeData = getPersonalizedRewriteData(path);

// Modify layoutData to use specific variant(s) instead of default
// This will also set the variantId on the Sitecore context so that it is accessible here
personalizeLayout(
props.layoutData,
personalizeData.variantId,
personalizeData.componentVariantIds
);
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ class PersonalizePlugin implements Plugin {
? context.params.path.join('/')
: context.params.path ?? '/';

// Get variant for personalization (from path)
// Get variant(s) for personalization (from path)
const personalizeData = getPersonalizedRewriteData(path);

// Modify layoutData to use specific variant instead of default
// Modify layoutData to use specific variant(s) instead of default
// This will also set the variantId on the Sitecore context so that it is accessible here
personalizeLayout(props.layoutData, personalizeData.variantId);
personalizeLayout(
props.layoutData,
personalizeData.variantId,
personalizeData.componentVariantIds
);

return props;
}
Expand Down
Loading