optimove-websdk
v1.2.2
Published
Optimove WebSDK for humans
Downloads
355
Readme
optimove-websdk
Optimove WebSDK for humans
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.gionic://
,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
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]')