Breaking changes - Introduced version 2.0.0 of the commercetools Frontend SDK
Version 2.0.0 of the SDK contains breaking changes.
Version 2.0.0 of the commercetools Frontend SDK introduces new features and bug fixes. We recommend upgrading to Version 2.0.0 of the SDK to ensure you get the newest features, improvements, and fixes.
For a step-by-step guide about how to update your SDK version, see the following:
Breaking changes
- Commerce related events were removed and moved to the Composable Commerce integration.
- In the
page
API, thegetPage
method now returns a union type ofPageResponse
andRedirectResponse
instead of only aPageResponse
. - In the
Page
type, thesections
property changed from aSection
array to an object with optionalfooter
,head
, andmain
properties of aSection
type. - In the
Page
type, thestate
changed from a string to"default" | "published" | "draft" | "scheduled"
. - All
page
API and event-related types changed to interfaces. - In the
SDK.configure
method, theextensionVersion
argument is now required. - In the
SDK.callAction
method, theskipQueue
parameter was replaced with an optionalparallel
argument, with a default oftrue
. - All synchronous cookie handling functionality was removed. The
rememberMeCookieAsync
object was renamed torememberMeCookie
and this is now the default functionality. - The previously deprecated
Extension
class was removed, this should be replaced withIntegration
. - The
posixLocale
property was deprecated and removed. - Getters for the
endpoint
,locale
,currency
, andcustomHeaderValue
properties on the SDK class changed to functions. - In the
Event
class, theisDefaultPrevented
,isCancelled
, andisPropagationStopped
properties were removed. - In the
SDK.callActon
method, the payload argument of theSDK.callActon
is no longerunknown
. Instead, the argument must be of typeAcceptedPayloadTypes
. - On the
FetchError
class, the constructor argument now accepts an options argument with the requirederror
property of typestring | Error
. - On the
ActionError
class, theactionName
property was removed and the constructor now only accepts a single options argument with the requirederror
property of typestring | Error
. - On the
PageError
class, thepath
property was removed, and the constructor now only takes a single options argument with the requirederror
property of typestring | Error
. - In
BaseEvents
, theerrorCaught
event property offrontasticRequestId?: string
was added to atracing
object.
New features
The
BaseEvents
file replaces theStandardEvents
one and adds the following events:actionCalled
: triggered when an action is called.pageApiMethodCalled
: triggered when apage
API method is called.fetchCalled
: triggered when an action or apage
API method is called.actionFetchSuccessful
: triggered when an action returns successfully.pageApiFetchSuccessful
: triggered when apage
API method returns successfully.fetchSuccessful
: triggered when an action or apage
API method returns successfully.actionErrorCaught
: triggered when an action error occurs.pageApiErrorCaught
: triggered apage
API method error occurs.
To prevent accidental storage or logging, the SDK now redacts sensitive JSON and URL data for internal events. You can override this by passing one of the following to the new
redactionHandlingOverride
property in theSDK.configure
method:All actions are now executed asynchronously by default. You can override this and execute actions sequentially by passing
parallel: false
to theSDK.callAction
argument or integration action.All cookie handling methods are now asyncronous and compatible with
cookieHandlingOverride
.On the
Page
object, thestate
property is now more verbosely typed as"default" | "published" | "draft" | "scheduled"
.All
get
,set
, and#privateProperty
syntax was replaced with classic TypeScriptprivate
modifiers and design patterns, which improves compatibility with libraries such as React Native.
Bug fixes
- In the
Page
type, thesections
property was changed from aSection
array to an object with optionalfooter
,head
, andmain
properties of aSection
type. - In the
page
API, thegetPage
method now returns a union type ofPageResponse
|
RedirectResponse
type instead of only aPageResponse
. - In the
SDK.configure
method, theextensionVersion
argument is now correctly marked as required. - Error messages were improved and no longer contain repeated text.
- In the event of a successful fetch with an unserializable response, the internal fetcher now catches and reports an error, as expected.