Web
@usercurrent/sdk-web
Browser TypeScript with an offline queue. Collection is opt-in until you set consent. Slots render fallback-first and report an exposure for what they showed.
import { init } from '@usercurrent/sdk-web';
import { renderSlot } from '@usercurrent/sdk-web/slots';
const uc = init({
endpoint: 'https://events.example.com',
key: 'pk_live_...',
defaults: { upgrade_banner: { text: 'Compare plans.' } },
});
// Call from your consent UI, with the choices the visitor made
uc.setConsent({ analytics: true, personalization: true });
uc.identify('u_4821', { plan: 'trial' });
uc.track('pricing_page_viewed');
const banner = document.querySelector('#upgrade-banner');
// Fallback-first: the default renders at once, the decision replaces it only if it differs
renderSlot(uc, banner, 'upgrade_banner', (decision, el) => {
el.textContent = String(decision.props.text);
});