Commerce engine
Commerce engine
This is for:
DeveloperThe engine for powering commerce experiences.
Initialize
buildCommerceEngine
Creates a commerce engine instance.
Parameters
-
options:
CommerceEngineOptions
The commerce engine options.
Returns CommerceEngine
CommerceEngineOptions
The commerce engine options.
Properties
-
configuration:
CommerceEngineConfiguration
The commerce engine configuration options.
-
loggerOptions?:
LoggerOptions
The logger options.
-
middlewares?:
Middleware<{}, State>[]
List of additional middlewares. A middleware is a higher-order function that composes a dispatch function to return a new dispatch function. It is useful for logging actions, performing side effects like routing, or turning an asynchronous API call into a series of synchronous actions.
-
navigatorContextProvider?:
NavigatorContextProvider
An optional function returning navigation context. (referer, location, UserAgent)
-
preloadedState?:
State
The initial headless state. You may optionally specify it to hydrate the state from the server in universal apps, or to restore a previously serialized user session.
CommerceEngineConfiguration
The commerce engine configuration options.
Properties
-
analytics:
Pick<AnalyticsConfiguration, 'enabled' | 'proxyBaseUrl' | 'source' | 'trackingId'>
The commerce analytics configuration.
-
context:
ContextOptions
The commerce context options.
-
cart?:
CartInitialState
The initial cart state to restore.
-
proxyBaseUrl?:
string
The base URL to use to proxy Coveo commerce requests (e.g.,
https://example.com/commerce
).This is an advanced option that you should only set if you need to proxy Coveo commerce requests through your own server. In most cases, you should not set this option.
-
accessToken:
string
The access token to use to authenticate requests against the Coveo Cloud endpoints. Typically, this will be an API key or search token that grants the privileges to execute queries and push usage analytics data in the target Coveo Cloud organization.
-
organizationId:
string
The unique identifier of the target Coveo Cloud organization (e.g.,
mycoveocloudorganizationg8tp8wu3
) -
environment?:
PlatformCombination['env']
The environment in which the organization is hosted.
The
dev
andstg
environments are only available internally for Coveo employees (e.g., Professional Services).Defaults to
prod
. -
name?:
string
The Engine name (e.g., myEngine). Specifying your Engine name will help in debugging when using an application with multiple Redux stores.
Default: 'coveo-headless'
-
preprocessRequest?:
PreprocessRequest
Allows for augmenting a Platform request before it is sent.
-
renewAccessToken?:
() => Promise<string>
A function that fetches a new access token. The function must return a Promise that resolves to a string (the new access token).
LoggerOptions
The logger options.
Properties
-
level?:
LevelWithSilent
By default, is set to
warn
. -
logFormatter?:
(object: {}) => {}
Changes the shape of the log object. This function will be called every time one of the log methods (such as
.info
) is called. All arguments passed to the log method, except the message, will be pass to this function. By default it does not change the shape of the log object.
Middleware<{}, State>[]
List of additional middlewares. A middleware is a higher-order function that composes a dispatch function to return a new dispatch function. It is useful for logging actions, performing side effects like routing, or turning an asynchronous API call into a series of synchronous actions.
Properties
-
(call):
(api: MiddlewareAPI<D, S>): (next: (action: unknown) => unknown) => (action: unknown) => unknown;
ContextOptions
The commerce context options.
Properties
-
country:
string
-
currency:
CurrencyCodeISO4217
-
language:
string
-
view:
View
-
location?:
UserLocation
View
Properties
-
url:
string
UserLocation
Properties
-
latitude:
number
-
longitude:
number
CartItemWithMetadata[]
Properties
-
name:
string
The name of the cart item.
-
price:
number
The price of the cart item.
-
productId:
string
The unique identifier of the product.
-
quantity:
number
The quantity of the product in the cart.