Data and auth flows
Overview of the event pipeline, auth flow, and session lifecycle for the Sophi Web Object SDK.
Event pipeline
Loading diagram…
- Your code sets a tracked property on
window.sophi_objector callsSophiTracker.push. - The SDK applies the update, then prepares one or more events from the current data layer state.
- Each event includes a
pagecontext, the resolvedevent_type, and any relevant objects (user,product, etc.). Invalid or incomplete data is skipped with a console warning. - Events wait briefly (
debounceMs) so rapid updates can batch; failed deliveries are retried with exponential backoff up tomaxRetries. - Delivery uses the active session established at startup: payloads are sent to Sophi over HTTPS as JSON.
When the visitor hides or leaves the tab, the SDK attempts a best-effort flush (for example via the browser’s unload / beacon mechanisms) so late events are less likely to be lost.
Auth and session
Loading diagram…
- Session creation is deduplicated while a request is already in flight.
- On logout or user switch, session state and cookies are cleared so the next activity uses a fresh session.
- When an anonymous visitor logs in, the SDK coordinates with Sophi so the existing anonymous activity can be linked to your
config.userIdwhere applicable.
After login in your app, call SophiTracker.updateUser(externalId) then push user / other context as needed. See SophiTracker API.
Related
Types reference
TypeScript type definitions for all Sophi Web Object data structures including PageObject, UserObject, ProductObject, BasketObject, and EventEnvelope.
Validation
Before an event is sent, @usesophi/sophi-web-object runs client-side field validation; failures log a console.warn and the event is skipped without any network request.