identify method

Future<void> identify(
  1. Identify identify, [
  2. EventOptions? options
])

Updates user properties using operations provided via Identify API.

Note that this will only affect only future events, and don't update historical events.

To update user properties, first create an Identify object.

Example: if you wanted to set a user's gender, increment their karma count by 1, you would do:

final Identify identify = Identify()
  ..set('gender','male')
  ..add('karma', 1);
amplitude.identify(identify);

Implementation

Future<void> identify(Identify identify, [EventOptions? options]) async {
  final event = IdentifyEvent();
  event.userProperties = identify.properties;

  if (options != null) {
    event.mergeEventOptions(options);
    if (options.userId != null) {
      // TODO(xinyi): make sure setUserId() is called on native platforms
      setUserId(options.userId!);
    }
    if (options.deviceId != null) {
      // TODO(xinyi): make sure setUserId() is called on native platforms
      setDeviceId(options.deviceId!);
    }
  }

  return await _channel.invokeMethod('identify',
      {'instanceName': configuration.instanceName, 'event': event.toMap()});
}