start static method

Future<void> start(
  1. AgentConfiguration config
)

Initializes the agent.

The agent does not automatically start with your application. You can initialize the agent using the app key shown in your UI controller. This has to be done near your application's entry point before any other initialization routines in your application.

Once initialized, further calls to Instrumentation.start have no effect on the agent.

Warning: Be careful when using other 3rd party packages. Based on the order of initialization, conflicts might occur.

Method might throw Exception.

try {
  AgentConfiguration config = AgentConfiguration(
      appKey: appKey,
      loggingLevel: LoggingLevel.verbose,
      collectorURL: collectorURL);
  await Instrumentation.start(config);
} catch (e) {
  // handle exception
}

Implementation

static Future<void> start(AgentConfiguration config) async {
  String version = await rootBundle
      .loadString('packages/appdynamics_agent/version.txt', cache: false);
  String type = "Flutter";

  final crashCallback = config.crashReportCallback;
  if (crashCallback != null) {
    _initializeCrashCallback(crashCallback);
  }

  Map<String, dynamic> arguments = {
    "appKey": config.appKey,
    "loggingLevel": config.loggingLevel.index,
    "collectorURL": config.collectorURL,
    "screenshotURL": config.screenshotURL,
    "screenshotsEnabled": config.screenshotsEnabled,
    "crashReportingEnabled": config.crashReportingEnabled,
    "anrDetectionEnabled":
        true, // hardcoded until it's implemented on Android agent too
    "anrStackTraceEnabled":
        true, // hardcoded until it's implemented on Android agent too
    "version": version,
    "type": type,
    "enableLoggingInVSCode": config.enableLoggingInVSCode,
  }..removeWhere((key, value) => value == null);

  try {
    await channel.invokeMethod<void>('start', arguments);
  } on PlatformException catch (e) {
    throw Exception(e.details);
  }
}