initialize method

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

Implementation

@override
Future<PlatformInitializationResult> initialize(
  DdSdkConfiguration configuration, {
  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.webInitialize(configuration);
      await rumWeb.initialize(
          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);
}