@suucha/web
v0.1.0
Published
Browser platform adapter for Suucha Web SDK
Readme
@suucha/web
Browser platform adapter for Suucha Web SDK.
Install
pnpm add @suucha/core @suucha/webQuick Start
import { suucha } from '@suucha/core';
import { setupWeb } from '@suucha/web';
// Initialize at app entry, before any suucha.log() calls
setupWeb({
cookieTtlDays: 30,
autoGenerateAnonymousId: true,
});
// Now suucha is ready
suucha.log('page_view');What setupWeb Does
- Reads
RegionContext(host, timezone, language) from the browser and injects it into thesuuchasingleton viasetRegionContext(). - Persists
anonymous_idto a cookie so the same visitor keeps the same ID across sessions. - Returns early on SSR (no
window) — v1.1 will add proper SSR support.
API
setupWeb(options?: WebSetupOptions): void
| Option | Default | Description |
|---|---|---|
| cookieTtlDays | 30 | Cookie TTL in days |
| autoGenerateAnonymousId | true | Persist anonymous_id to cookie |
| cookieNamespace | 'suucha' | Cookie name prefix |
getRegionContext(): RegionContext
Synchronously returns the current page's region context (used internally by setupWeb).
cookie
Lightweight cookie utilities:
import { cookie } from '@suucha/web';
cookie.set('name', 'value', { ttlDays: 7 });
cookie.get('name'); // 'value'
cookie.remove('name');License
MIT © Suucha Studio
