viakite
Dashboard

SDKs/Web/reset()

reset()

Forget the user on sign-out

reset() forgets the user you set with identify() in this tab. Call it when someone signs out, so the next person on the same browser isn't counted as them.

Signature

ts
1function reset(): void;

It takes no parameters and returns nothing.

Examples

src/auth.ts
1import { reset } from "@viakite/sdk";
2
3export async function signOut() {
4 await fetch("/api/sign-out", { method: "POST" });
5 reset();
6}
auth.js
1async function signOut() {
2 await fetch("/api/sign-out", { method: "POST" });
3 viakite.reset();
4}

How it works

  • It clears the user id held in memory. Events after it carry no user id.
  • It sends nothing by itself.
  • It affects this tab only. Other tabs keep their id until they reload or call reset() too.
  • A full page load forgets the id anyway, because the id is never stored on the device. reset() matters in a single-page app, where signing out doesn't reload the page.
  • Called before init(), it waits and runs once init() does, in the order it was called.

reset() never throws, and logs nothing in debug mode.

Next steps