# optimove-websdk

> Optimove WebSDK for humans

Latest version **1.2.2** (published 2021-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install optimove-websdk
pnpm add optimove-websdk
yarn add optimove-websdk
bun add optimove-websdk
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2021-08-24 |
| First published | 2020-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12.13.1 |
| Dependencies | 2 |
| Unpacked size | 103.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Natural Cycles Team |
| Maintainers | cervicalmucus |

## Links

- npm: https://www.npmjs.com/package/optimove-websdk
- Repository: https://github.com/NaturalCycles/optimove-websdk
- Homepage: https://github.com/NaturalCycles/optimove-websdk#readme
- Issues: https://github.com/NaturalCycles/optimove-websdk/issues
- npm.io page: https://npm.io/package/optimove-websdk

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0
- [@naturalcycles/js-lib](https://npm.io/package/@naturalcycles/js-lib.md) ^14.20.0

## Recent versions

- 1.2.2 (latest) — 2021-08-24
- 1.2.1 — 2021-04-28
- 1.2.0 — 2021-04-04
- 1.1.6 — 2020-11-25
- 1.1.5 — 2020-08-17
- 1.1.4 — 2020-08-11
- 1.1.3 — 2020-08-11
- 1.1.2 — 2020-07-23
- 1.1.1 — 2020-07-23
- 1.1.0 — 2020-07-23
- 1.0.1 — 2020-07-23
- 1.0.0 — 2020-07-23

## README

## optimove-websdk

> Optimove WebSDK for humans

[![npm](https://img.shields.io/npm/v/optimove-websdk/latest.svg)](https://www.npmjs.com/package/optimove-websdk)
[![min.gz size](https://badgen.net/bundlephobia/minzip/optimove-websdk)](https://bundlephobia.com/result?p=optimove-websdk)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# Why

> Because Optimove is complicated™

# Features

- Promisified API
- Reasonable defaults
- Typescript types built-in
- Bundled, so e.g. ad-blockers won't block it just by url name
- Loads config with hard-coded `https://` schema, which allows it to work under e.g `ionic://`,
  `capacitor://`, `file://`, etc schemas
- Allows to not care about `optimoveSDK.initialize`, since it's called lazily on first usage.
- Allows to (hopefully) not care about "is it loaded yet?" problem
- ~~Zero dependencies~~ (1 small tree-shakeable dependency), exports ESM / 🌲-shakeable
- Automatically handles `snakeToCamel`, `camelToSnake` case conversions when reporting events and
  custom properties

# Usage

```typescript
import { OptimoveWebSK } from 'optimove-websdk'

const sdk = new OptimoveWebSDK({
  tenantToken: 'lalala',
  configVersion: '1.0.0',
})

// Will lazily initialize SDK on the first call (hence the `await`)
await sdk.registerUser('someCustomerId', 'some@email.com')

// Skip await freely, if it's more convenient
void sdk.registerUser('someCustomerId', 'some@email.com')

// Low-level API is available via `window.optimoveSDK` too (Window interface is augmented with its types already)
window.optimoveSDK.API.registerUser('someCustomerId', 'some@email.com')
```

---
_Source: https://npm.io/package/optimove-websdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
