@manojskidos/skilink-web-sdk
v0.1.1
Published
Skilink Web SDK — track events, identify users, unify cross-device identity from browsers.
Maintainers
Readme
Skilink Web SDK
Tiny, dependency-free web SDK for sending events and identifying users to the Skilink customer engagement platform. Mirrors the iOS SDK identity model so users registering on iOS or web land in the same record.
- ~5 KB minified + gzipped (single file, no deps).
- 5-method public API:
init,track,identify,setUser,reset. - Automatic anonymous-to-known identity merge on login (
identify). - Optional auto-pageview tracking (SPA-aware via
history.pushStatepatching). - Resilient: failed events queue in
localStorageand retry on next page load.
Install
Script tag (zero-build pages)
<script src="https://cdn.your-host.com/skilink.min.js"></script>
<script>
Skilink.init({ apiKey: 'YOUR_PUBLIC_API_KEY' });
</script>npm
npm install @infyu/skilink-web-sdkimport Skilink from '@infyu/skilink-web-sdk';
Skilink.init({ apiKey: 'YOUR_PUBLIC_API_KEY' });API
Skilink.init(options)
Call once on page load. Idempotent.
| Option | Type | Default | Notes |
|------------------|-----------|------------------------------------|-------------------------------------------------|
| apiKey | string | required | Your Skilink client key. |
| apiHost | string | https://skilink-api.skidos.com | Override for staging. |
| autoPageviews | boolean | true | Set false to track pageviews manually. |
On first visit, init POSTs /api/web-sdk/user-tracking/generate-luid and
persists the returned anonymous luid in localStorage. Subsequent visits
skip the call.
Skilink.track(eventName, attributes?)
Fire an event. Best-effort — never throws. If the network is down, the event
is queued in localStorage and replayed on the next page load.
Skilink.track('signup_clicked', { plan: 'pro', referrer: 'homepage' });Skilink.identify(cuid, traits?)
Link the current anonymous browser session to a known user. Triggers the backend's identity-merge flow: historical anonymous events get re-pointed to the known user's record (matches what the iOS SDK does on login).
// After your registration form succeeds:
await Skilink.identify(user.id, {
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
});Calling identify with the same cuid is safe — the backend detects the
existing match and updates traits without re-merging.
Skilink.setUser(traits)
Update profile fields without changing identity. Use this for incremental profile enrichment after registration.
Skilink.setUser({ company: 'Acme Inc.', plan: 'enterprise' });Skilink.reset()
Call on logout. Clears the cuid binding so subsequent events go back to
anonymous attribution. The luid persists, so the same browser is still
recognized as the same anonymous visitor.
function onLogout() {
Skilink.reset();
}Recipe: registration funnel
// 1. Page load — anonymous tracking starts immediately.
Skilink.init({ apiKey: 'k_live_...' });
// 2. User enters the funnel.
Skilink.track('signup_started');
// 3. User submits the form. Identity is now known.
const user = await api.signup(formData);
await Skilink.identify(user.id, {
email: user.email,
firstName: user.firstName,
lastName: user.lastName
});
// 4. Subsequent events are attributed to the known user.
Skilink.track('signup_completed', { plan: user.plan });Recipe: cross-device identity (iOS + web)
If a user registers on iOS and later visits your web app while logged in:
// On a page where you know who the user is server-side, re-identify them.
// The backend uses the same identity flow whether the call comes from iOS
// or web, so the user's events stay unified across devices.
Skilink.init({ apiKey: 'k_live_...' });
Skilink.identify(SERVER_KNOWN_USER_ID, {
email: SERVER_KNOWN_EMAIL
});How identity works
| State | What's persisted | Sent on every event |
|----------------------------------|---------------------------------|-------------------------------|
| First visit | luid (issued by server) | userId = luid, luid |
| After identify(cuid) | luid + cuid | userId = cuid, cuid, luid|
| After reset() | luid only | userId = luid, luid |
The same payload shape is used by the iOS SDK, so a user's events from iOS and web flow through the same backend pipeline.
Privacy
- Storage: only
localStorage(no cookies, no third-party tracking). - No fingerprinting — language and timezone come from standard browser APIs the user already exposes to every site.
- No precise location — never prompts for
navigator.geolocation. - Network: only POSTs to your configured
apiHost. No third-party calls.
Browser support
Modern evergreens (Chrome, Edge, Firefox, Safari). Built with target: es2018,
so async/await + spread/rest work natively without polyfills.
Development
npm install
npm test # run unit tests
npm run build # produces dist/skilink.{min,esm,cjs}.jsLicense
UNLICENSED — internal Infyu / Skidos use.
