identify method

Future<IdentifyResult> identify({
  1. String? tag,
  2. bool submit = true,
  3. bool automatic = false,
})

Collect and submit.

Returns the server's answer, not a receipt for one. There is no second call to make: the address lookup and the scoring happen on the request, so IdentifyResult.suspectScore and IdentifyResult.visitorId are populated by the time this resolves.

Pass submit: false to collect without sending anything. Only IdentifyResult.report is filled in then. The server's fields come back empty, and IdentifyResult.suspectScore stays null rather than 0 — nobody scored it, which is not the same as scoring it and finding nothing.

Pass automatic: true for a call the app makes on its own rather than in answer to the user (on start, on a timer, on returning to the foreground). An automatic call joins an identification already in flight instead of starting another, and waits out a transient failure instead of repeating it at once. On Android it is accepted and has no effect until the native Android SDK supports it.

Throws FingerlyConsentException while consent is not granted.

Implementation

Future<IdentifyResult> identify({
  String? tag,
  bool submit = true,
  bool automatic = false,
}) async {
  final raw = await _invoke<String>('identify', {
    'tag': tag,
    'submit': submit,
    'automatic': automatic,
  });
  final json = _decode(raw);

  if (submit) return IdentifyResult.fromJson(json);

  // Everything but the report is ignored, so nothing the native side sends
  // can pass for an answer when no server was asked.
  final report = json['report'];
  if (report is! Map<String, dynamic>) {
    throw const FingerlyException('The SDK produced an unreadable report');
  }
  return IdentifyResult.reportOnly(SignalReport.fromJson(report));
}