@nacelle/client-js-sdk
v3.7.2
Published
## How to use
Downloads
7,205
Maintainers
Keywords
Readme
Nacelle Client SDK
How to use
npm install @nacelle/client-js-sdk
Instantiate Client
import NacelleClient from '@nacelle/client-js-sdk'
const settings = {
id: '<YOUR_NACELLE_SPACE_ID>',
token: '<YOUR_NACELLE_SPACE_TOKEN>',
locale: 'en-us',
nacelleEndpoint: 'https://hailfrequency.com/v2/graphql',
}
const client = new NacelleClient(settings)
With the client initialized you now have access to four modules, data
, checkout
, events
, and status
that will allow your app to interact with Nacelle and your data.
Register Attribution Event
Any event type can be registered as an attribution event. The first parameter is the event type and the second is the event data to attribute to future events.
client.events.onAttributionEvent('productRecommendation', (event) => ({
sourceHandles: event.sourceHandles,
recommendedHandles: event.recommendedHandles,
clickedHandle: event.clickedHandle,
}))
client.events.onAttributionEvent('search', (event) => ({
query: event.query,
resultCount: event.resultCount,
}))
The most recent attribution event data will then be attached to subsequent events that occur. For example search
data may be attributed to a productView
event.