Saltar al contenido principal
Version: Plataforma actual

Public Methods

After initialization, use window.upsurge. Calls made earlier belong in window.UpsurgeQueue as arrays whose first item is the method name.

Lifecycle​

init(): void​

Initializes session state, auto-capture, the event queue, and eligible feature runtimes. Queued initialization calls invoke this automatically.

flush(): Promise<FlushResult>​

Sends queued events immediately. The result contains processed, succeeded, and failed counts.

const result = await window.upsurge.flush();
if (result.failed > 0) {
console.warn('Some Upsurge events failed', result);
}

shutdown(): Promise<void>​

Stops capture, flushes pending events, and destroys active feature runtimes. Call it before permanently replacing the tracker in a long-lived application.

isInitialized(): boolean​

Returns whether initialization completed and tracking is active.

Generic tracking​

track(eventType, properties?): void​

Queues a supported canonical event.

window.upsurge.track('page_view', { page_category: 'sale' });

trackCustom(eventName, properties?): void​

Queues the canonical custom event and places your name in properties.event_name.

window.upsurge.trackCustom('hero_cta_clicked', {
placement: 'home_hero',
});

Identity and session​

identify(userId, traits?): void​

Associates subsequent events with a merchant-scoped authenticated user ID. Do not use an email address as the ID or put raw personal data in traits.

reset(): void​

Clears the identified user and rotates the session for a logout or account switch. It retains the current random or fingerprint-derived device ID; use clearFingerprint() when consent withdrawal also requires replacing a fingerprint-derived ID.

Identity getters​

getUserId(), getSessionId(), and getDeviceId() return current runtime identifiers. The SDK always creates a random device ID; opt-in fingerprinting can replace it with a fingerprint-derived ID.

Overlay lifecycle​

  • refreshOverlays() destroys current overlay triggers and fetches configuration for the current URL.
  • resetOverlays() destroys active overlay runtime state without fetching replacement configuration.

SPA navigation refreshes overlay configuration automatically when autoTrackSpaNavigation is enabled.

Commerce and product methods​

Typed helper payloads are documented in Event tracking. Widget runtimes emit most overlay, quiz, and chatbot lifecycle events automatically; avoid duplicating those calls in storefront code.