Skip to content

Data and auth flows

Event pipeline

flowchart TD
  merchant[Your site]
  update[Update sophi_object]
  build[Build event payload]
  queue[Queue and debounce]
  send[Send to Sophi HTTPS]
  api[Sophi services]

  merchant -->|"assignment or SophiTracker.push"| update
  update --> build
  build --> queue
  queue --> send
  send --> api
  1. Your code sets a tracked property on window.sophi_object or calls SophiTracker.push.
  2. The SDK applies the update, then prepares one or more events from the current data layer state.
  3. Each event includes a page context, the resolved event_type, and any relevant objects (user, product, etc.). Invalid or incomplete data is skipped with a console warning.
  4. Events wait briefly (debounceMs) so rapid updates can batch; failed deliveries are retried with exponential backoff up to maxRetries.
  5. 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

sequenceDiagram
  participant Boot as SDK startup
  participant Session as Session handling
  participant API as Sophi

  Boot->>Session: Create or restore session
  Session->>API: Authenticated HTTPS request
  API-->>Session: Session credentials
  Session->>Session: Store first-party cookies
  Boot->>Boot: Activate data layer and flush initial state
  • 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.userId where applicable.

After login in your app, call SophiTracker.updateUser(externalId) then push user / other context as needed. See SophiTracker API.