12 November 2024
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
pageAPI, thegetPagemethod now returns a union type ofPageResponseandRedirectResponseinstead of only aPageResponse. - In the
Pagetype, thesectionsproperty changed from aSectionarray to an object with optionalfooter,head, andmainproperties of aSectiontype. - In the
Pagetype, thestatechanged from a string to"default" | "published" | "draft" | "scheduled". - All
pageAPI and event-related types changed to interfaces. - In the
SDK.configuremethod, theextensionVersionargument is now required. - In the
SDK.callActionmethod, theskipQueueparameter was replaced with an optionalparallelargument, with a default oftrue. - All synchronous cookie handling functionality was removed. The
rememberMeCookieAsyncobject was renamed torememberMeCookieand this is now the default functionality. - The previously deprecated
Extensionclass was removed, this should be replaced withIntegration. - The
posixLocaleproperty was deprecated and removed. - Getters for the
endpoint,locale,currency, andcustomHeaderValueproperties on the SDK class changed to functions. - In the
Eventclass, theisDefaultPrevented,isCancelled, andisPropagationStoppedproperties were removed. - In the
SDK.callActonmethod, the payload argument of theSDK.callActonis no longerunknown. Instead, the argument must be of typeAcceptedPayloadTypes. - On the
FetchErrorclass, the constructor argument now accepts an options argument with the requirederrorproperty of typestring | Error. - On the
ActionErrorclass, theactionNameproperty was removed and the constructor now only accepts a single options argument with the requirederrorproperty of typestring | Error. - On the
PageErrorclass, thepathproperty was removed, and the constructor now only takes a single options argument with the requirederrorproperty of typestring | Error. - In
BaseEvents, theerrorCaughtevent property offrontasticRequestId?: stringwas added to atracingobject.
New features
-
The
BaseEventsfile replaces theStandardEventsone and adds the following events:actionCalled: triggered when an action is called.pageApiMethodCalled: triggered when apageAPI method is called.fetchCalled: triggered when an action or apageAPI method is called.actionFetchSuccessful: triggered when an action returns successfully.pageApiFetchSuccessful: triggered when apageAPI method returns successfully.fetchSuccessful: triggered when an action or apageAPI method returns successfully.actionErrorCaught: triggered when an action error occurs.pageApiErrorCaught: triggered apageAPI 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
redactionHandlingOverrideproperty in theSDK.configuremethod: -
All actions are now executed asynchronously by default. You can override this and execute actions sequentially by passing
parallel: falseto theSDK.callActionargument or integration action. -
All cookie handling methods are now asyncronous and compatible with
cookieHandlingOverride. -
On the
Pageobject, thestateproperty is now more verbosely typed as"default" | "published" | "draft" | "scheduled". -
All
get,set, and#privatePropertysyntax was replaced with classic TypeScriptprivatemodifiers and design patterns, which improves compatibility with libraries such as React Native.
Bug fixes
- In the
Pagetype, thesectionsproperty was changed from aSectionarray to an object with optionalfooter,head, andmainproperties of aSectiontype. - In the
pageAPI, thegetPagemethod now returns a union type ofPageResponse|RedirectResponsetype instead of only aPageResponse. - In the
SDK.configuremethod, theextensionVersionargument 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.