Skip to main content

Web SDK

@arsel.sa/web-sdk provides events, identity and web push for the browser. Around 6 kB gzipped, no runtime dependencies, shipped as ESM and UMD. Events and identity work with notifications denied, blocked, or never requested.

Requirements​

BrowsersChrome/Edge 79+, Firefox 72+, Safari 16.4+, and mobile equivalents
TransportYour page must be served over HTTPS for push (http://localhost is the browser's one exemption). The API baseUrl must be HTTPS too, except localhost for a local backend.
BundlersAny, or none
Runtime depsNone

Push support is narrower than events: events work everywhere the SDK loads.

Install​

npm install @arsel.sa/web-sdk

Or from a script tag, which exposes the same surface on window.Arsel. unpkg and jsDelivr serve the UMD build from npm. Pin the version and add an SRI hash so a compromised CDN cannot run arbitrary script on your pages:

<script src="https://unpkg.com/@arsel.sa/web-sdk@1.3.1/dist/arsel.umd.cjs"
integrity="sha384-…" crossorigin="anonymous"></script>

Or copy node_modules/@arsel.sa/web-sdk/dist/arsel.umd.cjs into your static assets and serve it from your own origin.

Initialize​

import Arsel from '@arsel.sa/web-sdk';

await Arsel.init({
clientKey: 'pub_…',
baseUrl: 'https://api.arsel.sa',
});

Arsel.track('product.viewed', { sku: 'A-1023', price: 149.99 });

// On login. Everything tracked beforehand merges onto this contact.
Arsel.identify({ externalId: user.id });

clientKey is the organization's publishable pub_ key and is safe in page source. Never put your secret be_ API key in client code. See Authentication.

A web client key is bound to an origin allowlist: requests from domains you have not registered are rejected.

Web push also needs a service worker file on your site, at a path the browser can reach. VAPID keys and the rest of the org-side setup are in Setting up push.

Full documentation​

The reference is the SDK's repository, Arsel-SA/arsel-web-sdk (MIT), versioned with the code you install.

QuickstartInstall → initialize → service worker → first event, end to end
API referenceEvery method, option, and thrown error
Web pushThe service worker, VAPID rotation, browser support
IdentityAnonymous → identified, merges, reset() vs optOut()
EventsProperties, limits, sessions, durability
Data collectionExactly what is stored, and where
TroubleshootingSymptom → cause → fix
Migrating from CleverTapCall-by-call mapping
Changelog