identify method

  1. @override
Future<void> identify(
  1. CustomerIdentity newIdentity
)
override

Migrates the current session to a new CustomerIdentity.

Use this after the customer signs in to your app: the SDK swaps the active CustomerIdentity in config and — if currently connected — reconnects so the new identity is applied on the next channel join.

Continuity: within an active session, the guest ID assigned during the prior anonymous session is preserved across the migration so conversation history follows the customer when they sign in. However, ChataptorConfig.sessionIdleTimeout takes precedence — when the persisted session has been idle past the configured timeout, the upcoming connect inside identify clears the guest session first and the identified customer joins on a fresh anonymous-then-identified thread.

State requirements: must be called when the connection is either Connected or Disconnected. Throws ChataptorStateError when invoked during Connecting or Reconnecting — those states represent in-flight transitions where a concurrent disconnect / reconnect would race with the in-flight connect sequence.

When newIdentity equals the current customer (value equality), identify is a no-op and resolves immediately.

Safe to call before connect: only the configuration is updated; no premature reconnect is triggered.

Implementation

@override
Future<void> identify(CustomerIdentity newIdentity) async {
  recorded.identifyCalls.add(newIdentity);
}