getVisitorId static method

Future<String?> getVisitorId({
  1. Object? tags,
  2. String? linkedId,
})

Returns the visitorId generated by the native Fingerprint Pro client Support tags Support linkedId Throws a FingerprintProError if identification request fails for any reason

Implementation

static Future<String?> getVisitorId({Object? tags, String? linkedId}) async {
  if (!_isInitialized) {
    throw Exception(
        'You need to initialize the FPJS Client first by calling the "initFpjs" method');
  }

  try {
    FingerprintJSAgent fp = await (_fpPromise as Future<FingerprintJSAgent>);
    var result = await promiseToFuture(
        fp.get(FingerprintJSGetOptions(linkedId: linkedId, tag: tags)));
    return result.visitorId;
  } catch (e) {
    if (e is WebException) {
      throw unwrapWebError(e);
    } else {
      throw UnknownError(e.toString());
    }
  }
}