Chord OMS
...
Gatsby
Guides

v3.x to v4.x Migration Guide

8min

Overview

Chord’s Gatsby starter relies on a companion Gatsby theme to power its interactions with the Chord ecosystem. With the release of the new of Chord’s new React-based SDK, react-autonomy, the theme will now be powered by this lower-level package.

As such, the refactored integration of the theme in the starter will contain breaking changes.

Why update?

Going forward, all new SDK features and fixes will be made to react-autonomy (and consumed in gatsby-theme-autonomy). The new implementation of our SDK also comes with some great new features!

Major Changes

Typescript support

react-autonomy and gatsby-theme-autonomy have Typescript support with type definitions.

Removed ability to import services, selectors and actions via

We have removed the ability to consume some internal parts of the Redux store in favour of better and more complete hooks.

JSdoc documentation

react-autonomy includes function documentation following the JSDoc specification.

Improved hooks and methods

Names, parameters, and behavior has been standardized across the SDK.

Environment variables

We have added and renamed some environment variables and their corresponding plugin options needed to correctly configure the theme in your starter. See the list below.

Removal of Sentry

We have removed Sentry support from our SDKs.

Migration Steps

Change your environment variables and/or update the theme configuration in your starter

In the newest version of the starter, we have renamed some and added new environment variables:

.env
ο»Ώ

While mirroring these changes is not mandatory, you will need to update the configuration passed from your starter to the gatsby-theme-autonomy in gatsby-plugin.js:

JS
ο»Ώ

Update dependencies

Update your theme package:

yarn
ο»Ώ

Update React components

Hooks and method names have changed, so this will need to be updated throughout your code. Reference the documentation to see how they’ve changed. For example:

JS
ο»Ώ

Remove dependencies on deprecated exports and deep imports

We have simplified the list of methods and hooks exported from gatsby-theme-autonomy. This means that you will no longer have access to previously exported members, like services, selectors, etc.

For example:

JS
ο»Ώ

Add product serializer

As mentioned above, some methods now have a product argument you can include to add details about the product to the Segment tracking event. gatsby-starter-autonomy/src/utils/chord/serialize.js provides a couple of convenience methods that serialize the Chord CMS default content model into the correct object shape. You can customize these functions as needed, or write your own.