init static method
Future<void>
init(
- OptionsConfiguration optionsConfiguration, {
- AppRunner? appRunner,
- @internal bool callAppRunnerInRunZonedGuarded = true,
- @internal RunZonedGuardedOnError? runZonedGuardedOnError,
- @internal SentryOptions? options,
Initializes the SDK
passing a AppRunner callback allows to run the app within its own error
zone (runZonedGuarded
)
Implementation
static Future<void> init(
OptionsConfiguration optionsConfiguration, {
AppRunner? appRunner,
@internal bool callAppRunnerInRunZonedGuarded = true,
@internal RunZonedGuardedOnError? runZonedGuardedOnError,
@internal SentryOptions? options,
}) async {
final sentryOptions = options ?? SentryOptions();
await _initDefaultValues(sentryOptions);
try {
final config = optionsConfiguration(sentryOptions);
if (config is Future) {
await config;
}
} catch (exception, stackTrace) {
sentryOptions.logger(
SentryLevel.error,
'Error in options configuration.',
exception: exception,
stackTrace: stackTrace,
);
if (sentryOptions.automatedTestMode) {
rethrow;
}
}
if (sentryOptions.dsn == null) {
throw ArgumentError('DSN is required.');
}
await _init(sentryOptions, appRunner, callAppRunnerInRunZonedGuarded,
runZonedGuardedOnError);
}