init static method

Future<void> init(
  1. OptionsConfiguration optionsConfiguration, {
  2. AppRunner? appRunner,
  3. SentryOptions? options,
})

Initializes the SDK passing a AppRunner callback allows to run the app within its own error zone (runZonedGuarded)

You should use optionsConfiguration instead of passing sentryOptions yourself. sentryOptions is mainly intendet for use by other Sentry clients such as SentryFlutter.

Implementation

static Future<void> init(
  OptionsConfiguration optionsConfiguration, {
  AppRunner? appRunner,
  SentryOptions? options,
}) async {
  final sentryOptions = options ?? SentryOptions();
  await _initDefaultValues(sentryOptions, appRunner);

  await optionsConfiguration(sentryOptions);

  if (sentryOptions.dsn == null) {
    throw ArgumentError('DSN is required.');
  }

  await _init(sentryOptions, appRunner);
}