Upgrade from Cloud SDK version 0.5 to 0.6
Cloud SDK version 0.6 introduces a breaking change to the names of the cookies the SDK sets in your app:
-
The
sc_{SitecoreEdgeContextId}cookie, which persists the browser IDbrowser ID, is renamed tosc_cid. -
The
sc_{SitecoreEdgeContextId}_personalizecookie, which persists the guest IDguest ID, is renamed tosc_cid_personalize.
The cookie name changes mean that when you upgrade to version 0.6, new cookies will be created in your app. The old cookies remain in web browsers. In SDK version 0.6.1 and later, the new cookies inherit the values from the old ones, if the old ones are present in the web browser. This has the following consequences:
-
Privacy policy and cookie consent banners - you must update references to the old cookie names in your privacy policy and cookie consent banners. If required by applicable regulations, you must re-obtain consent.
-
Application code - if your application references the old cookie names, you must update your code. Common places where you might reference cookie names include:
-
Cookie consent logic.
-
Cookie whitelist.
-
Server-side middleware and client-side scripts that read cookie values.
-
Privacy policy documentation.
-
Cookie banner configurations.
-
Parts of your code where you pass cookie values to other systems.
-
-
Switching SitecoreAI environments during development - if you want to switch between different SitecoreAI environments during development, you need to delete your existing
sc_cidandsc_cid_personalizecookies and create new ones with a different Context ID. For more information, see Switching environments for testing purposes.
After the changes are deployed to production, the cookie name change occurs one time for every site visitor, when they next visit the deployed website.
This walkthrough focuses on updating your application code. It describes how to:
-
In your code editor, open the root folder of your web app.
Install the latest @sitecore-cloudsdk packages
@sitecore-cloudsdk packagesThe first step to upgrading is to install the latest @sitecore-cloudsdk packages.
To install the latest packages:
-
In your code editor, in the root folder of your application where your app dependencies are installed, open the terminal.
-
To install version 0.6 of the Cloud SDK packages you currently use in your app, run the following commands:
ImportantTo ensure the new cookies inherit values from the old cookies, install SDK packages 0.6.1 or later, not 0.6.0.
NoteOnly install the packages your application uses. For example, if you don't use the
searchpackage, you don't need to install it. -
In
package.json, check that the Cloud SDK packages are now version0.6.1or later.
Update application code that references cookies
If your application contains custom code that reads or references the old cookie names, you must update those references to use the new cookie names.
To update cookie references in your application code:
-
Search your application code for any references to the old cookie name
sc_{SitecoreEdgeContextId}, and then replace it with the new cookie namesc_cid. Your code might refer to the old cookie name using a variable, such assc_${contextId}. -
Search your application code for any references to the old cookie name
sc_{SitecoreEdgeContextId}_personalize, and then replace it with the new cookie namesc_cid_personalize. Your code might refer to the old cookie name using a variable, such assc_${contextId}_personalize. -
Save your changes.
Test your implementation
After updating your application code, test that your app correctly sets the new cookies.
To test your implementation:
-
Start your app by entering the following command in your terminal:
-
In your web browser, navigate to your Next.js app, typically at
http://localhost:3000. -
In your web browser's developer tools, in Cookies, find the new cookies
sc_cidand, if you use thepersonalizepackage,sc_cid_personalize. If these cookies are present, you've successfully initialized the Cloud SDK with the new cookies. -
Check that your cookie consent banner correctly identifies and manages the new cookie names.
-
Check that your code continues to capture events and that they appear in Sitecore.
-
If your app uses the
personalizepackage, check that web personalization, interactive personalization, and A/B/n testing continue to work as expected.You've now successfully upgraded to Cloud SDK version 0.6.