From 8e1ab2d5d6ee0e31bf4333e1162a9b93436aa387 Mon Sep 17 00:00:00 2001 From: sahani-deriv Date: Mon, 9 Dec 2024 16:08:00 +0800 Subject: [PATCH 1/2] update analytics and deriv_datadog --- .../analytics/lib/sdk/datadog/core/enums.dart | 21 ++++++----- .../lib/sdk/datadog/sdk/deriv_datadog.dart | 20 +++++------ packages/analytics/pubspec.yaml | 2 +- .../deriv_datadog/lib/sdk/deriv_datadog.dart | 36 ++++++++++--------- packages/deriv_datadog/pubspec.yaml | 2 +- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/packages/analytics/lib/sdk/datadog/core/enums.dart b/packages/analytics/lib/sdk/datadog/core/enums.dart index 20f4d4e46..b56262e4b 100644 --- a/packages/analytics/lib/sdk/datadog/core/enums.dart +++ b/packages/analytics/lib/sdk/datadog/core/enums.dart @@ -89,20 +89,19 @@ enum RumUserActionType { custom } -/// A mapper class to map [RumUserActionType] to [datadog.RumUserActionType]. -Map rumUserActionTypeMapper = - { - RumUserActionType.tap: datadog.RumUserActionType.tap, - RumUserActionType.scroll: datadog.RumUserActionType.scroll, - RumUserActionType.swipe: datadog.RumUserActionType.swipe, - RumUserActionType.custom: datadog.RumUserActionType.custom, +/// A mapper class to map [RumUserActionType] to [datadog.RumActionType]. +Map rumUserActionTypeMapper = + { + RumUserActionType.tap: datadog.RumActionType.tap, + RumUserActionType.scroll: datadog.RumActionType.scroll, + RumUserActionType.swipe: datadog.RumActionType.swipe, + RumUserActionType.custom: datadog.RumActionType.custom, }; /// Extension on [RumUserActionType]. extension RumUserActionTypeExtension on RumUserActionType { - /// The consent getter method is an extension to the [datadog.RumUserActionType] - /// enum that returns the corresponding [datadog.RumUserActionType] value for + /// The consent getter method is an extension to the [datadog.RumActionType] + /// enum that returns the corresponding [datadog.RumActionType] value for /// the given [RumUserActionType] value. - datadog.RumUserActionType get rumUserActionType => - rumUserActionTypeMapper[this]!; + datadog.RumActionType get rumUserActionType => rumUserActionTypeMapper[this]!; } diff --git a/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart b/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart index e3d91efff..ae61420d6 100644 --- a/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart +++ b/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart @@ -36,23 +36,22 @@ class DerivDatadog implements BaseAnalytics { @override Future setup(DerivDatadogConfiguration configuration) async { try { - final datadog.RumConfiguration rumConfiguration = - datadog.RumConfiguration( + final datadog.DatadogRumConfiguration rumConfiguration = + datadog.DatadogRumConfiguration( applicationId: configuration.applicationId, sessionSamplingRate: configuration.sessionSamplingRate ?? 100, - tracingSamplingRate: configuration.tracingSamplingRate ?? 100, + traceSampleRate: configuration.tracingSamplingRate ?? 100, ); - final datadog.DdSdkConfiguration datadogConfiguration = - datadog.DdSdkConfiguration( + final datadog.DatadogConfiguration datadogConfiguration = + datadog.DatadogConfiguration( clientToken: configuration.clientToken, env: configuration.env, - serviceName: configuration.serviceName, + service: configuration.serviceName, site: configuration.site?.site ?? DatadogSite.us1.site, - trackingConsent: configuration.trackingConsent.consent, nativeCrashReportEnabled: configuration.nativeCrashReportEnabled ?? true, - loggingConfiguration: datadog.LoggingConfiguration(), + loggingConfiguration: datadog.DatadogLoggingConfiguration(), rumConfiguration: rumConfiguration, ); @@ -72,7 +71,8 @@ class DerivDatadog implements BaseAnalytics { return platformOriginalOnError?.call(e, st) ?? false; }; - await _datadogSDK.initialize(datadogConfiguration); + await _datadogSDK.initialize( + datadogConfiguration, configuration.trackingConsent.consent); _datadogSDK.updateConfigurationInfo( LateConfigurationProperty.trackErrors, true); return true; @@ -101,7 +101,7 @@ class DerivDatadog implements BaseAnalytics { required String name, Map attributes = const {}, }) => - _datadogSDK.rum?.addUserAction( + _datadogSDK.rum?.addAction( type.rumUserActionType, name, attributes, diff --git a/packages/analytics/pubspec.yaml b/packages/analytics/pubspec.yaml index 689249387..e130a9780 100644 --- a/packages/analytics/pubspec.yaml +++ b/packages/analytics/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: firebase_core: ^3.5.0 firebase_analytics: ^11.3.2 rudder_sdk_flutter: ^2.6.0 - datadog_flutter_plugin: ^1.6.2 + datadog_flutter_plugin: ^2.9.0 flutter: sdk: flutter diff --git a/packages/deriv_datadog/lib/sdk/deriv_datadog.dart b/packages/deriv_datadog/lib/sdk/deriv_datadog.dart index 5d15c70c1..a3ac22548 100644 --- a/packages/deriv_datadog/lib/sdk/deriv_datadog.dart +++ b/packages/deriv_datadog/lib/sdk/deriv_datadog.dart @@ -36,8 +36,8 @@ class DerivDatadog implements BaseDerivDatadog { String name, [ Map attributes = const {}, ]) => - _datadogSDK.rum?.addUserAction( - datadog.RumUserActionType.tap, + _datadogSDK.rum?.addAction( + datadog.RumActionType.tap, name, attributes, ); @@ -47,8 +47,8 @@ class DerivDatadog implements BaseDerivDatadog { String name, [ Map attributes = const {}, ]) => - _datadogSDK.rum?.addUserAction( - datadog.RumUserActionType.scroll, + _datadogSDK.rum?.addAction( + datadog.RumActionType.scroll, name, attributes, ); @@ -58,8 +58,8 @@ class DerivDatadog implements BaseDerivDatadog { String name, [ Map attributes = const {}, ]) { - _datadogSDK.rum?.addUserAction( - datadog.RumUserActionType.swipe, + _datadogSDK.rum?.addAction( + datadog.RumActionType.swipe, name, attributes, ); @@ -70,8 +70,8 @@ class DerivDatadog implements BaseDerivDatadog { String name, [ Map attributes = const {}, ]) => - _datadogSDK.rum?.addUserAction( - datadog.RumUserActionType.custom, + _datadogSDK.rum?.addAction( + datadog.RumActionType.custom, name, attributes, ); @@ -92,24 +92,28 @@ class DerivDatadog implements BaseDerivDatadog { DerivDatadogConfiguration configuration, datadog.AppRunner runner, ) async { - final datadog.RumConfiguration rumConfiguration = datadog.RumConfiguration( + final datadog.DatadogRumConfiguration rumConfiguration = + datadog.DatadogRumConfiguration( applicationId: configuration.applicationId, sessionSamplingRate: configuration.sessionSamplingRate ?? 100, - tracingSamplingRate: configuration.tracingSamplingRate ?? 100, + traceSampleRate: configuration.tracingSamplingRate ?? 100, ); - final datadog.DdSdkConfiguration datadogConfiguration = - datadog.DdSdkConfiguration( + final datadog.DatadogConfiguration datadogConfiguration = + datadog.DatadogConfiguration( clientToken: configuration.clientToken, env: configuration.env, - serviceName: configuration.serviceName, + service: configuration.serviceName, site: configuration.site?.site ?? DatadogSite.us1.site, - trackingConsent: configuration.trackingConsent.consent, nativeCrashReportEnabled: configuration.nativeCrashReportEnabled ?? true, - loggingConfiguration: datadog.LoggingConfiguration(), + loggingConfiguration: datadog.DatadogLoggingConfiguration(), rumConfiguration: rumConfiguration, ); - await datadog.DatadogSdk.runApp(datadogConfiguration, runner); + await datadog.DatadogSdk.runApp( + datadogConfiguration, + configuration.trackingConsent.consent, + runner, + ); } } diff --git a/packages/deriv_datadog/pubspec.yaml b/packages/deriv_datadog/pubspec.yaml index 14c9a2898..4a48f37e5 100644 --- a/packages/deriv_datadog/pubspec.yaml +++ b/packages/deriv_datadog/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter - datadog_flutter_plugin: ^1.3.2 + datadog_flutter_plugin: ^2.9.0 dev_dependencies: flutter_test: From 96d5cfd0e092ed77224ac73227cafff318ad201a Mon Sep 17 00:00:00 2001 From: sahani-deriv Date: Mon, 9 Dec 2024 16:25:23 +0800 Subject: [PATCH 2/2] add sourceError callback --- .../analytics/lib/sdk/datadog/sdk/deriv_datadog.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart b/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart index ae61420d6..cfbc9fdd5 100644 --- a/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart +++ b/packages/analytics/lib/sdk/datadog/sdk/deriv_datadog.dart @@ -106,4 +106,15 @@ class DerivDatadog implements BaseAnalytics { name, attributes, ); + + /// Logs Source Error + void onSourceError( + String message, [ + Map attributes = const {}, + ]) => + _datadogSDK.rum?.addErrorInfo( + message, + datadog.RumErrorSource.source, + attributes: attributes, + ); }