setUserId method

Future<void> setUserId(
  1. String? userId, {
  2. bool? startNewSession,
})

If your app has its own login system that you want to track users with, you can set the userId.

Implementation

Future<void> setUserId(String? userId, {bool? startNewSession}) async {
  Map<String, dynamic> properties = _baseProperties();
  properties['userId'] = userId;
  if (startNewSession != null) {
    properties['startNewSession'] = startNewSession;
  }

  return await _channel.invokeMethod('setUserId', jsonEncode(properties));
}