initialize method

  1. @override
Future<PlatformInitializationResult> initialize(
  1. DatadogConfiguration configuration,
  2. TrackingConsent trackingConsent, {
  3. LogCallback? logCallback,
  4. required InternalLogger internalLogger,
})
override

Implementation

@override
Future<PlatformInitializationResult> initialize(
  DatadogConfiguration configuration,
  TrackingConsent trackingConsent, {
  LogCallback? logCallback,
  required InternalLogger internalLogger,
}) async {
  bool logsInitialized = false;
  try {
    if (configuration.loggingConfiguration != null) {
      DdLogsWeb.initLogs(configuration);
      logsInitialized = true;
    }
  } catch (e) {
    internalLogger.warn('DatadogSdk failed to initialize logging: $e');
    internalLogger
        .warn('Did you remember to add "datadog-logs" to your scripts?');
  }

  bool rumInitialized = false;
  try {
    if (configuration.rumConfiguration != null) {
      final rumWeb = DdRumPlatform.instance as DdRumWeb;
      rumWeb.initialize(
        configuration,
        configuration.rumConfiguration!,
        internalLogger,
      );
      rumInitialized = true;
    }
  } catch (e) {
    internalLogger.warn('DatadogSdk failed to initialize RUM: $e');
    internalLogger
        .warn('Did you remember to add "datadog-rum-slim" to your scripts?');
  }

  return PlatformInitializationResult(
      logs: logsInitialized, rum: rumInitialized);
}