identify method
Identify the current end-user. All subsequent telemetry is attributed to it.
Implementation
Future<void> identify(
String distinctId, {
String? email,
String? name,
String? phone,
Map<String, Object?>? traits,
}) async {
_id.distinctId = distinctId;
if (traits != null) _id.traits.addAll(traits);
if (email != null) _id.email = email;
if (name != null) _id.name = name;
if (phone != null) _id.phone = phone;
// Remember the user on device so future launches restore this identity
// instead of starting anonymous (see NexusIdentity + Nexus._loadIdentity).
await IdentityStore.save(
distinctId: distinctId,
email: _id.email,
name: _id.name,
phone: _id.phone,
traits: _id.traits,
);
await _http.post('/partner/sessions/identify', {
'distinctId': distinctId,
'email': ?email,
'name': ?name,
'phone': ?phone,
'traits': ?traits,
});
await track();
}