Skip to content

reset and startTour ​

reset ​

Call reset() when the user signs out.

ts
import { reset } from "@justonecx/sdk";

await reset();                    // clear identity, start a new anonymous visitor, run init() again
await reset({ remount: false });  // clear only, do not run init() again

Why it matters: the visitor id is a permanent id in localStorage. On a shared browser, the next person who signs in would otherwise inherit the previous person's open chat and other visitor state.

reset() does these steps:

  1. Removes the chat bubble and closes its connection.
  2. Stops any tour that is still playing and removes launcher buttons.
  3. Deletes the stored visitor id and creates a new one.
  4. Runs init() again with the same key and URL, unless remount is false or init() never ran.

A new chat bubble appears after reset(). This is by design.

startTour ​

Replay a tour from your own button, for example a "Show me around" item in a help menu.

ts
import { startTour } from "@justonecx/sdk";

startTour("tour-id");

startTour plays the tour immediately. It ignores the tour's targeting, frequency cap and completion state. The tour id is in the URL of the tour's edit page in the dashboard.

A tour can also show its own persistent launcher button. Enable it in the tour editor, on the Launcher tab. The launcher calls startTour for you.

JustOneCX