# @nacelle/client-js-sdk

> ## How to use

Latest version **3.7.2** (published 2023-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nacelle/client-js-sdk
pnpm add @nacelle/client-js-sdk
yarn add @nacelle/client-js-sdk
bun add @nacelle/client-js-sdk
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.7.2 |
| Published | 2023-04-06 |
| First published | 2020-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 939.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Levi Whalen |
| Maintainers | dave.king.nacelle, nacelle-support, jeffrichie, darrik-moberg, stuckya, badiolaignacio, dzouras, andrew-nacelle, nwrichmond, brianvanderson, cbodtorf, krisq, curbol, irnoble, jongeyer, nacelle-bot |

## Links

- npm: https://www.npmjs.com/package/@nacelle/client-js-sdk
- npm.io page: https://npm.io/package/@nacelle/client-js-sdk

## Dependencies (3)

- [graphql](https://npm.io/package/graphql.md) ^14.6.0
- [isomorphic-unfetch](https://npm.io/package/isomorphic-unfetch.md) ^3.1.0
- [exponential-backoff](https://npm.io/package/exponential-backoff.md) ^3.1.0

## Recent versions

- 3.7.2 (latest) — 2023-04-06
- 3.7.0-cache.1 (cache) — 2021-11-09
- 3.6.0-next.0 (next) — 2021-10-20
- 3.4.3-dyanmic-modules.0 (dynamic-modules) — 2021-08-18
- 2.2.5 (vega) — 2020-09-22
- 2.0.1 (dev) — 2020-08-10
- 2.0.0 (beta) — 2020-08-05
- 3.7.1 — 2022-02-16
- 3.7.0 — 2022-02-11
- 3.7.0-cache.0 — 2021-11-09
- 3.6.0 — 2021-11-01
- 3.5.1 — 2021-10-26
- 3.4.2-next.2 — 2021-10-20
- 3.5.0 — 2021-09-29
- 3.4.5 — 2021-09-29
- … 51 more at https://npm.io/package/@nacelle/client-js-sdk/versions

## README

# Nacelle Client SDK

## How to use

```console
npm install @nacelle/client-js-sdk
```

### Instantiate Client

```javascript
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.

```javascript
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.

---
_Source: https://npm.io/package/@nacelle/client-js-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
