finalInit static method

Future<void> finalInit()

最终初始化,等用户同意隐私合规后,再调用这个接口;需要和delayInit配套使用

Implementation

static Future<void> finalInit() async {
  if (_isDelayInit == false) {
    options.logger(APMLogLevel.warning, 'warning! rmonitor is not delay init!');
    return ;
  }
  if (_isFinalInited == true) {
    options.logger(APMLogLevel.warning, 'warning! rmonitor is final inited!');
    return;
  }

  try {
    if (_delayInitTasks != null) {
      for (final task in _delayInitTasks!) {
        await task.run();
      }
      _delayInitTasks = null;

      int startTimestamp = await Bugly.channel.invokeMethod(ChannelMethodName.getLastEnterFlutterTimestamp);
      if (startTimestamp == 0) {
        startTimestamp = new DateTime.now().millisecondsSinceEpoch;
      }
      AppSession.instance.handlerDelayInit(startTimestamp);
    }
  } catch (e) {
    logger(APMLogLevel.error, 'rmonitor finalInit error: $e');
  }

  _isFinalInited = true;
  options.logger(APMLogLevel.info, 'rmonitor final init finish!');
}