runApp static method
Future<void>
runApp(
- DatadogConfiguration configuration,
- TrackingConsent trackingConsent,
- AppRunner runner
A helper function that will initialize Datadog and setup error reporting
See also, DatadogRum.handleFlutterError, DatadogTrackingHttpClient
Implementation
static Future<void> runApp(
DatadogConfiguration configuration,
TrackingConsent trackingConsent,
AppRunner runner,
) async {
WidgetsFlutterBinding.ensureInitialized();
final originalOnError = FlutterError.onError;
FlutterError.onError = (details) {
DatadogSdk.instance.rum?.handleFlutterError(details);
originalOnError?.call(details);
};
final platformOriginalOnError = PlatformDispatcher.instance.onError;
PlatformDispatcher.instance.onError = (e, st) {
DatadogSdk.instance.rum?.addErrorInfo(
e.toString(),
RumErrorSource.source,
stackTrace: st,
);
return platformOriginalOnError?.call(e, st) ?? false;
};
await DatadogSdk.instance.initialize(configuration, trackingConsent);
DatadogSdk.instance
.updateConfigurationInfo(LateConfigurationProperty.trackErrors, true);
runner();
}