An open API service indexing awesome lists of open source software.

https://github.com/naturalcycles/optimove-websdk

Optimove WebSDK for humans
https://github.com/naturalcycles/optimove-websdk

humans optimove optimove-sdk

Last synced: about 2 months ago
JSON representation

Optimove WebSDK for humans

Awesome Lists containing this project

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', '[email protected]')

// Skip await freely, if it's more convenient
void sdk.registerUser('someCustomerId', '[email protected]')

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