[Personalization] Serialization of CommerceTrackingData gives unexpected results when using scoped configuration

Fixed in

EPiServer.Personalization.Commerce 3.0.6


Mar 01, 2019


Apr 15, 2019


Closed, Fixed and tested



We use a custom contract resolver inheriting CamelCasePropertyNamesContractResolver to serialize tracking data to JSON. Even though we use different instances of our contract resolver the CamelCasePropertyNamesContractResolver uses an internal static cache of resolved JsonContracts and shares them between resolver instances.

When a contract for a tracking type is resolved the Site and ClientToken values for the current scope are used in the JSON data and, because of the cache, in all future tracking data of that type. If the site consists of more than one web app the web apps may have cached values from different scopes leading to a, from the outside, seemingly random behavior in regards to what values are included in the JSON.

The Newtonsoft team have chosen not to “fix” it (it’s not really a bug, it’s inconsistent behavior) in later versions because that would be a major breaking change. Therefore, upgrading the Newtonsoft.Json version is not a viable workaround.