Appearance
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() againWhy 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:
- Removes the chat bubble and closes its connection.
- Stops any tour that is still playing and removes launcher buttons.
- Deletes the stored visitor id and creates a new one.
- Runs
init()again with the same key and URL, unlessremountisfalseorinit()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.