Skip to main content
Four host events interact with the SDK. The concepts are the same across both SDKs (read the shared overview); this page gives the exact Flutter code.

1. App launch — every time, including already-logged-in users

The most common miss: existing users who installed your app before you added ClarioDesk never hit the login flow again. Hydrate from your own session on launch and identify unconditionallyidentify() is idempotent and cheap.
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await ClarioDesk.init(apiKey: 'pk_live_…');

  final user = await yourAuth.currentUser(); // Firebase, Supabase, your store…
  if (user != null) {
    await ClarioDesk.identify(
      externalId: user.id,
      email: user.email,
      traits: {'plan': user.plan},
    );
  }

  runApp(const MyApp());
}

2. Fresh login or signup

Right after your auth succeeds:
await yourAuth.signIn(email, password);
await ClarioDesk.identify(
  externalId: user.id,
  email: user.email,
  traits: {'plan': user.plan},
);
This overwrites the label on the existing device row — no new device, no new hardware key.

3. Logout

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.

4. User switch (A → B without app restart)

await ClarioDesk.reset();
await ClarioDesk.init(apiKey: 'pk_live_…'); // fresh device for user B
await ClarioDesk.identify(externalId: userB.id, email: userB.email);
Don’t try to rebind the 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; agents see a device id but no email, and the dashboard shows an “Unverified device” badge. Fine for anonymous feedback; otherwise wire case 1.