Skip to content

Commit

Permalink
[Nextjs][Personalize] Don't resolve site in CdpPageView when it's dis…
Browse files Browse the repository at this point in the history
…abled (#1365)

* [Nextjs][Personalize] Don't resolve site in CdpPageView when it's disabled

* Simplify
  • Loading branch information
illiakovalenko authored Mar 3, 2023
1 parent 37934e1 commit 2aef99e
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ const CdpPageView = (): JSX.Element => {
sitecoreContext: { pageState, route, variantId, site },
} = useSitecoreContext();

const siteName = site?.name || config.jssAppName;
const siteInfo = siteResolver.getByName(siteName);

/**
* Creates a page view event using the Sitecore Engage SDK.
*/
Expand Down Expand Up @@ -72,10 +69,12 @@ const CdpPageView = (): JSX.Element => {
if (disabled()) {
return;
}

const siteInfo = siteResolver.getByName(site?.name || config.jssAppName);
const language = route.itemLanguage || config.defaultLanguage;
const pageVariantId = CdpHelper.getPageVariantId(route.itemId, language, variantId as string);
createPageView(route.name, language, siteInfo, pageVariantId);
}, [pageState, route, variantId, siteInfo]);
}, [pageState, route, variantId, site]);

return <></>;
};
Expand Down

0 comments on commit 2aef99e

Please sign in to comment.