Four moments in your app’s lifecycle interact with the SDK. Wire all four and
the integration is complete. The code below is platform-agnostic; see the
per-SDK lifecycle guides for exact syntax
(Flutter, React Native).
1. App launch — every time
The most common integration miss: users who installed your app before you
added ClarioDesk never go through login again, so an “identify on login” hook
alone leaves them as unlabeled devices.
Hydrate from your own persisted session on launch and identify
unconditionally. identify() is idempotent (same values = no-op write) and
cheap (one signed POST, ~5–25 ms).
await ClarioDesk.init(apiKey: 'pk_live_…');
final user = await yourAuth.currentUser();
if (user != null) {
await ClarioDesk.identify(externalId: user.id, email: user.email);
}
2. Fresh login or signup
Right after your auth succeeds, call identify(). This overwrites the label on
the existing device row — no new device is registered, no new key is
generated. The same device now carries the new user’s metadata.
3. Logout
Call reset() before signing the user out of your own app.
await ClarioDesk.reset();
await yourAuth.signOut();
reset() best-effort revokes the device server-side, wipes the hardware key,
and clears local caches. The next init() registers a brand-new device —
important on shared devices.
4. User switch (A → B without restart)
Same as logout + login: reset(), then init() for a fresh device, then
identify() for user B.
Don’t try to “rebind” an existing device to a new user. reset() + new device
is the correct boundary — each device row carries an independent ticket history.
What if I never call identify()?
Tickets still work. The device row exists and agents see a device id but no
email — the dashboard shows an “Unverified device” badge. Useful for
anonymous-feedback flows; otherwise wire case 1 above and you’re covered.