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
- Host: GitHub
- URL: https://github.com/naturalcycles/optimove-websdk
- Owner: NaturalCycles
- Created: 2020-07-23T10:13:34.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-23T10:03:56.000Z (almost 2 years ago)
- Last Synced: 2024-10-16T05:34:11.461Z (7 months ago)
- Topics: humans, optimove, optimove-sdk
- Language: TypeScript
- Homepage:
- Size: 239 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
## optimove-websdk
> Optimove WebSDK for humans
[](https://www.npmjs.com/package/optimove-websdk)
[](https://bundlephobia.com/result?p=optimove-websdk)
[](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]')
```