3.7.2 • Published 3 years ago
@nacelle/client-js-sdk
Licence
MIT
Version
3.7.2
Deps
3
Size
939 kB
Vulns
0
Weekly
0
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.