Code Monkey home page Code Monkey logo

datadog_flutter's Introduction

Pub

Use the Official Datadog Flutter SDK Instead of This Package

This package has been deprecated in favor of the official Datadog Flutter SDK. Please see the announcement or skip ahead to the new, official repo.

Datadog Flutter

Community implementation of native bindings for Datadog's SDK. This is not an official package.

Setup

  1. Generate a client token from Datadog through the Settings > API panel (under Client Tokens). If you're using RUM, do not toggle between the RUM platform client tokens.
  2. Initialize:
    await DatadogFlutter.initialize(
      clientToken: myDatadogClientToken,
      serviceName: 'my-app-name',
      environment: 'production',
    )
  3. Associate RUM and log events (optional):
    await DatadogFlutter.setUserInfo(id: <YOUR_USER_ID>);
  4. Acknowledge TrackingConsent at initialization or later within your application. Events will not be logged until trackingConsent is .granted. This value can be updated via DatadogFlutter.updateTrackingConsent.

⚠️ Your Podfile must have use_frameworks! (Flutter includes this by default) and your minimum iOS target must be >= 11. This is a requirement from the Datadog SDK.

Flutter Web Caveats

The Datadog scripts need to be inserted in your index.html document. Please add both the logging script and the RUM script to their own <script> tags. DO NOT add the .init on .onReady code.

Logging

In its default implementation, log data will only be transmitted to Datadog through Logger records. print statements are not guaranteed to be captured.

ddLogger = DatadogLogger(loggerName: 'orders');
// optionally set a value for HOST
// ddLogger.addAttribute('hostname', <DEVICE IDENTIFIER>);

ddLogger.addTag('restaurant_type', 'pizza');
ddLogger.removeTag('restaurant_type');

// add attribute to every log
ddLogger.addAttribute('toppings', 'extra_cheese');

// add atttributes to some logs
ddLogger.log('time to cook pizza', Level.FINE, attributes: {
  'durationInMilliseconds': timer.elapsedMilliseconds,
});

Flutter Web Caveats

  • addTag and removeTag are not invoked and resolve silently when using Flutter web. This is a missing feature in Datadog's JS SDK.

Real User Monitoring

RUM adds support for error, event, and screen tracking. The integration requires additional configuration for each service.

  1. Supply an application ID to initialize:
    await DatadogFlutter.initialize(
      clientToken: myDatadogClientToken,
      serviceName: 'my-app-name',
      environment: 'production',
      iosRumApplicationId: myiOSRumApplicationId,
      androidRumApplicationId: myAndroidRumApplicationId,
      webRumApplicationId: myWebRumApplicationId,
    )
  2. Automatically track screens:
    MaterialApp(
      // ...your material config...
      home: HomeScreen(),
      navigatorObservers: [
        DatadogObserver(),
      ],
    );
  3. Automatically report errors (on iOS deployments be sure to upload your dSYMs):
    void main() async {
      // Capture Flutter errors automatically:
      FlutterError.onError = DatadogRum.instance.addFlutterError;
    
      // Catch errors without crashing the app:
      runZonedGuarded(() {
        runApp(MyApp());
      }, (error, stackTrace) {
        DatadogRum.instance.addError(error, stackTrace);
      });
    }
  4. Manually track additional events (please note that Android will only report RUMAction.custom events):
    GestureDetector(onTap: () {
      DatadogRum.instance.addUserAction('EventTapped');
    })
  5. Manually track additional errors:
    try {
      throw StateError();
    } catch (e, st) {
      DatadogRum.instance.addError(e, st);
    }
  6. Manually track network requests or resources:
    await DatadogRum.startResourceLoading(
      aUniqueIdentifier,
      url: 'https://example.com',
      method: RUMResources.get,
    );
    await DatadogRum.stopResourceLoading(
      aUniqueIdentifier,
      statusCode: 500,
      errorMessage: 'Internal Server Error' ,
    )

Flutter Web Caveats

  • addUserAction ignores the action when using Flutter web.
  • updateTrackingConsent is not invoked and fails silently when using Flutter web. This is a missing feature in Datadog's JS SDK.
  • stopView is not invoked and fails silently when using Flutter web. This is a missing feature in Datadog's JS SDK.
  • startUserAction and stopStopUserAction are not invoked and fail silently when using Flutter web. This is a missing feature in Datadog's JS SDK.
  • startResourceLoading and stopResourceLoading are not invoked and resolve silently when using Flutter web. This is a missing feature in Datadog's JS SDK.
  • setUserInfo does not support custom attributes when using Flutter web. This is due to Dart's method of strongly typing JS. Only name, id, and email are supported.

Tracing

Associate your HTTP requests with your backend service. Be sure to setup (usually immediately after DatadogFlutter.initialize):

await DatadogTracing.initialize();

For one-off requests, instantiate a fresh client:

final httpClient = DatadogTracingHttpClient();
// make requests
final response = await httpClient.get(Uri(string: 'http://example.com');

For frameworks that use an internal client like Brick, compose the client:

RestProvider(
  client: DatadogTracingHttpClient();
)
// or compose if another client is already being used:
RestProvider(
  client: DatadogTracingHttpClient(GZipHttpClient());
)

FAQ

How do I disable logging when I'm developing locally?

By default, the DatadogFlutter default constructor will send all logs from Logger to Datadog. To ignore, set bindOnRecord:

DatadogLogger(bindOnRecord: false)

And log conditionally later:

Logger.root.onRecord.listen((record) async {
  if (shouldSendToDatadog) {
    ddLogger.onRecordCallback(record)
  } else {
    print(record);
  }
});

datadog_flutter's People

Contributors

anshul-arora avatar ashok2004 avatar btrautmann avatar charafau avatar dominic-cot avatar indrekots avatar james-airspace avatar masterwok avatar quirijngb avatar triztian avatar tshedor avatar xgouchet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datadog_flutter's Issues

`setUserInfo` `extraInfo` is not working on iOS.

We are using extraInfo to provide information such as region to datadog, to be available for all logs.

This is working fine on Android, but on iOS the information is not appearing in the log.

id is working, it is just the information in extraInfo that is missing.

Our code looks something like this:

  await DatadogFlutter.setUserInfo(
      id: identity.id.toString(),
      extraInfo: {
        'property`': value1,
        'property2': value2.toString(),
        'property3': value3.name
      });

Update

Looked into this a bit more, and have found the issue.

     case "setUserInfo":
        let attributes = encodeAttributes(args?["attributes"] as? String)
        Datadog.setUserInfo(
          id: args?["id"] as? String,
          name: args?["name"] as? String,
          email: args?["email"] as? String,
          extraInfo: attributes ?? [AttributeKey : AttributeValue]()
        )
        result(true)

Trying to get the extraInfo argument using the attributes key.
Happy to create a PR to fix this if it would help?

Unable to send logs

I have checked with datadog support team - configuration looks good howver no logs are landing in datadog: logs, route observation, network observations, errors, nothing.
My log service looks like this:

import 'package:datadog_flutter/datadog_flutter.dart';
import 'package:datadog_flutter/datadog_logger.dart';
import 'package:datadog_flutter/datadog_observer.dart';
import 'package:datadog_flutter/datadog_rum.dart';
import 'package:datadog_flutter/datadog_tracing.dart';
import 'package:senio_assist/infrastructure/env_variables.dart';
import 'package:logging/logging.dart';

class LoggingService {
  DatadogObserver getNavigationObserver() => DatadogObserver();
  DatadogRum get instance => DatadogRum.instance;
  static final _logger = DatadogLogger(loggerName: 'Root Logger');

  static init() async {
    await DatadogFlutter.initialize(
      clientToken: EnvVariables.datadogKey,
      serviceName: 'MyApp',
      environment: EnvVariables.env,
      iosRumApplicationId: 'MyApp',
      androidRumApplicationId: 'MyApp',
      trackingConsent: TrackingConsent.granted,
      useEUEndpoints: true,
    );

    await DatadogTracing.initialize();
    Logger.root.onRecord.listen(_logger.onRecordCallback);
    // FlutterError.onError = DatadogRum.instance.addFlutterError;
  }

  DatadogTracingHttpClient? httpClient() {
    return DatadogTracingHttpClient();
  }

  log(String name, {level = Level.INFO}) {
    _logger.log(name, level);
  }

  addUserAction(
    String name, {
    RUMAction action = RUMAction.custom,
    Map<String, dynamic> attributes = const <String, dynamic>{},
  }) {
    instance.addUserAction(name, action: action, attributes: attributes);
  }

  onAuth(String userId) async {
    await DatadogFlutter.setUserInfo(id: userId);
    _logger.addAttribute('hostname', userId);
    await instance.addAttribute('hostname', userId);
  }
}

I call init() in main before any activity

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  DevHttpOverrides.init();
  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarBrightness: Brightness.light,
      statusBarIconBrightness: Brightness.dark));

  ...
  await LoggingService.init();

  runZonedGuarded<Future<void>>(() async {

any ideas why i am not able to send logs?

extrainfo is not displayed in session's attributes

Hello, while trying to do:

 await DatadogFlutter.setUserInfo(
        id: '42',
        name: 'John',
        extraInfo: {'surname': 'Doe'});
  },

On datadog, I cannot manage to find any extra info in the attributes of the the session, neither in the user part, neither in the json. The id and the name are properly displayed.

In the application settings, the app is of type javascript, I already tried the other types out of curiosity.

Regards

Bug: Manually Network Resource Not working

@tshedor Please look into this issue.

No Network resource recorded in datadog sessions explorer or did i miss anything here?

child: TextButton(
            onPressed: () {
              recordDatadogResource("/path/to/api", "/path/to/api", "get");
              stopDatadogResource("/path/to/api", 200);
            },
            child: Text('Log to Datadog'),
          )

Methods:

Future<void> recordDatadogResource(String key, String path, String method) async{
   await DatadogRum.startResourceLoading(
     key,
     url: path,
     method: method,
   );
 }

Future<void> stopDatadogResource(String path, int status, {String errorMessage = ''}) async {
   await DatadogRum.stopResourceLoading(
     path.toString(),
     statusCode: status,
     errorMessage: errorMessage,
   );
 }

Screenshot 2021-07-10 at 5 04 13 AM

Web Datadog Flutter error `Unsupported operation: Platform._operatingSystem`

When building/running on DataDog web, this line of code triggers a Unsupported operation: Platform._operatingSystem error. No such error on mobile.

await DatadogFlutter.setUserInfo(id: _user['email']);

Every other part of the Flutter configuration works just fine, including:

await DatadogTracing.initialize();

  FlutterError.onError = DatadogRum.instance.addFlutterError;
  Logger.root.level = Level.FINEST;

  runZonedGuarded(() {
    runApp(const MyApp());
  }, (error, stackTrace) {
    DatadogRum.instance.addError(error, stackTrace);
  });
final _logger = DatadogLogger(loggerName: 'Root Logger');
Logger.root.onRecord.listen(_logger.onRecordCallback);
_logger.addAttribute('hostname', 'production');```

as well as the DatadogFlutter.initialize (and yes, I am initializing a RUM web id).

I have a clean bill of health from my flutter doctor
```Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-arm, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.65.0)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

• No issues found!```

Here are my deps:
```environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  google_fonts: 2.1.1
  provider: ^6.0.0
  intl: ^0.17.0
  smooth_page_indicator: ^1.0.0+2
  amazon_cognito_identity_dart_2: ^1.0.5
  flutter_dotenv: ^5.0.2
  jiffy: ^5.0.0
  modal_bottom_sheet: ^2.0.0
  collection: ^1.15.0
  byte_flow: ^1.0.0
  hive: ^2.0.6
  hive_flutter: ^1.1.0
  scrollable_positioned_list: ^0.2.3
  scroll_to_index: ^2.1.1
  sticky_headers: ^0.2.0
  datadog_flutter: ^1.5.2
  connectivity_plus: ^2.2.1
  flutter_easyloading: ^3.0.3
  flutter_datetime_picker: ^1.5.1
  universal_platform: ^1.0.0+1

dev_dependencies:
  dart_code_metrics: ^4.11.0
  flutter_launcher_icons: "^0.9.2"
  flutter_test:
    sdk: flutter```

Anything pop out at the team, as to why the `setUserInfo` API would be breaking things on web?

Constantly see: "A RUM event was detected, but no view is active" in console

Hello,

I have closed prev issue since i have new details (#64).
Problem is that I am warning that i see comes out of nowhere (I am using DataObserver in my navigation observers)

START VIEW: /home
I/flutter ( 7029): Connected to websocket.
V/Datadog ( 7029): Batch [9038 bytes] sent successfully (LogsOkHttpUploader).
V/Datadog ( 7029): Batch [3854 bytes] sent successfully (TracesOkHttpUploader).
W/Datadog ( 7029): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.
W/Datadog ( 7029): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.
V/Datadog ( 7029): Batch [985 bytes] sent successfully (RumOkHttpUploader).
W/Datadog ( 7029): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.
W/Datadog ( 7029): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.
V/Datadog ( 7029): Batch [9038 bytes] sent successfully (LogsOkHttpUploader).
V/Datadog ( 7029): Batch [3853 bytes] sent successfully (TracesOkHttpUploader).
V/Datadog ( 7029): Batch [984 bytes] sent successfully (RumOkHttpUploader).
W/Datadog ( 7029): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.
W/Datadog ( 7029): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.
W/Datadog ( 7029): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.
W/Datadog ( 7029): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.
W/Datadog ( 7029): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.
W/Datadog ( 7029): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.
W/Datadog ( 7029): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.

As you can see from logs above acitve page is /home but it is not detected!
Sometimes after refresh of the app this error is gone for some time and events get logged but sometimes it is starting to show again. Feels like it looses active page....

p.s. I am not even trying to add any event when this message appears...

I dont understand the purpose of this

Hi

I have datadog for my backend/frontend but I don't see how this will add some information there from the apps we had in flutter, can you show some screenshots or samples of what these logs will look like and how they will be displayed on Data Dog?

Thanks

Runtime Error: flavorName Variable Not Found in AndroidPlugin

@tshedor i found this issue yesterday, but i modified made it worked but now reporting as this issue raise for all other devs

Runtime Error:
stack trace:

E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042): Failed to handle method call
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042): kotlin.KotlinNullPointerException
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at com.greenbits.datadog_flutter.DatadogFlutterPlugin.onMethodCall(DatadogFlutterPlugin.kt:78)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 8042):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter ( 8042): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(error, null, null, kotlin.KotlinNullPointerException
E/flutter ( 8042):      at com.greenbits.datadog_flutter.DatadogFlutterPlugin.onMethodCall(DatadogFlutterPlugin.kt:78)
E/flutter ( 8042):      at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter ( 8042):      at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter ( 8042):      at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/flutter ( 8042):      at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 8042):      at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter ( 8042):      at android.os.Looper.loop(Looper.java:160)
E/flutter ( 8042):      at android.app.ActivityThread.main(ActivityThread.java:6669)
E/flutter ( 8042):      at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 8042):      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/flutter ( 8042):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter ( 8042): )
E/flutter ( 8042): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581:7)
E/flutter ( 8042): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
E/flutter ( 8042): <asynchronous suspension>
E/flutter ( 8042): #2      DatadogFlutter.initialize (package:datadog_flutter/datadog_flutter.dart:27:5)
E/flutter ( 8042): <asynchronous suspension>

RootCause:
variable name mismatch in datadog_flutter.dart and DatadogFlutterPlugin.kt:78

datadog_flutter.dart:31 'flavorName': flavorName
and call.argument("flavor")!!,

Expected flavor variable by DatadogFlutterPlugin but datadog_flutter.dart passing flavorName not flavor

Android API 31 Crash

When trying to run this package on Android API 31 and above a crash occurs. This is caused by an issue internal to the Datadog SDK: DataDog/dd-sdk-android#709.

This issue should be resolved by bumping com.datadoghq:dd-sdk-android from version 1.8.1 to 1.11.1.

Beta2 still doesn't compile on Flutter 3

hi! looks like there's stll an error when using Flutter 3

e: /Users/rafal.wachol/.pub-cache/hosted/pub.dartlang.org/datadog_flutter-2.0.0-beta.2/android/src/main/kotlin/com/greenbits/datadog_flutter/DatadogFlutterPlugin.kt: (35, 5): Unresolved reference: context
e: /Users/rafal.wachol/.pub-cache/hosted/pub.dartlang.org/datadog_flutter-2.0.0-beta.2/android/src/main/kotlin/com/greenbits/datadog_flutter/DatadogFlutterPlugin.kt: (63, 20): Unresolved reference: context

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':datadog_flutter:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Looks like companion object was removed together with context variable:

Disable [DEBUG] messages

Hi there,
first of all, kudos to you, awesome plugin. Till now we were using some bizarre custom endpoint in our backend logging to an InfluxDB instance, and the difference with Datadog is like night and day.

I was wondering whether is possible to disable the printing of [DATADOG SDK] messages. If right now is not possible, including a bool field to the initializer params which enabled or disabled that logging would be great. We rely quite a lot on the console output in order to debug our app and these (a little bit verbose) messages make our traces difficult to read. Moreover, I'm getting tracing-related messages ([DATADOG SDK] 🐶 → 18:46:53.725 [DEBUG] 💡 (tracing) No upload. Batch to upload: NO, System conditions: ✅) although we are not using the tracing service. Is that normal? Thanks!

Unable to send log (Android)

Hi,

I am trying to connect my flutter app with datadog using this package. On iOS work fine, but on Android can't connect to datadog. No send logs and RUM not work, nothing happens.

Init datadog:

await DatadogFlutter.initialize(
     clientToken: token,
     serviceName: "MyApp - ${GeneralPlatform.isAndroid ? "Android" : "iOS"}",
     environment: Env.environment.currentMode.toString(),
     trackingConsent: TrackingConsent.granted,
     androidRumApplicationId: "MY ANDROID RUM ID",
     iosRumApplicationId: "MY IOS RUM ID",
     flavorName: Env.environment.currentMode.toString(),
     useEUEndpoints: true
   );

Send log:

DatadogLogger().log("TEST LOG", Level.SEVERE);

The only error I see in logcat is this:

W/OkHttp  (28387): unable to load android socket classes
W/OkHttp  (28387): java.lang.NoSuchMethodException: com.android.org.conscrypt.OpenSSLSocketImpl.setUseSessionTickets [boolean]
W/OkHttp  (28387): 	at java.lang.Class.getMethod(Class.java:2072)
W/OkHttp  (28387): 	at java.lang.Class.getDeclaredMethod(Class.java:2050)
W/OkHttp  (28387): 	at okhttp3.internal.platform.android.AndroidSocketAdapter.<init>(AndroidSocketAdapter.kt:34)
W/OkHttp  (28387): 	at okhttp3.internal.platform.android.StandardAndroidSocketAdapter.<init>(StandardAndroidSocketAdapter.kt:31)
W/OkHttp  (28387): 	at okhttp3.internal.platform.android.StandardAndroidSocketAdapter$Companion.buildIfSupported(StandardAndroidSocketAdapter.kt:57)
W/OkHttp  (28387): 	at okhttp3.internal.platform.android.StandardAndroidSocketAdapter$Companion.buildIfSupported$default(StandardAndroidSocketAdapter.kt:50)
W/OkHttp  (28387): 	at okhttp3.internal.platform.AndroidPlatform.<init>(AndroidPlatform.kt:44)
W/OkHttp  (28387): 	at okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported(AndroidPlatform.kt:239)
W/OkHttp  (28387): 	at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:211)
W/OkHttp  (28387): 	at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:179)
W/OkHttp  (28387): 	at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:180)
W/OkHttp  (28387): 	at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:219)
W/OkHttp  (28387): 	at okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:955)
W/OkHttp  (28387): 	at com.datadog.android.core.internal.CoreFeature.<clinit>(CoreFeature.kt:72)
W/OkHttp  (28387): 	at com.datadog.android.Datadog.setUserInfo(Datadog.kt:293)
W/OkHttp  (28387): 	at com.greenbits.datadog_flutter.DatadogFlutterPlugin.onMethodCall(DatadogFlutterPlugin.kt:212)
W/OkHttp  (28387): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
W/OkHttp  (28387): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/OkHttp  (28387): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
W/OkHttp  (28387): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/OkHttp  (28387): 	at android.os.MessageQueue.next(MessageQueue.java:339)
W/OkHttp  (28387): 	at android.os.Looper.loop(Looper.java:199)
W/OkHttp  (28387): 	at android.app.ActivityThread.main(ActivityThread.java:8258)
W/OkHttp  (28387): 	at java.lang.reflect.Method.invoke(Native Method)
W/OkHttp  (28387): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
W/OkHttp  (28387): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

Also I verified that I have Internet Permission in my manifest.

MissingPluginException

Hi there,

We're investigating adding datadog_flutter to our add-to-app Flutter application, and running into the following issue when invoking initialize:

2022-03-03 09:59:05.136 3583-3670/com.example.application I/flutter: [D]  GlobaErrorHandler.error  ERROR: MissingPluginException(No implementation found for method initWithClientToken on channel plugins.greenbits.com/datadog_flutter)
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: <asynchronous suspension>
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: #1      DatadogFlutter.initialize (package:datadog_flutter/datadog_flutter.dart:32:5)
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: <asynchronous suspension>
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: #2      DatadogLoggingService.init (package:core/src/logging/datadog_logging_service.dart:21:5)
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: <asynchronous suspension>
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: #3      main.<anonymous closure> (package:app_embedded/main.dart:38:7)
2022-03-03 09:59:05.384 3583-3670/com.example.application I/flutter: <asynchronous suspension>

I've cloned the repository and pointed our pubspec.yaml to my local copy via a path ref, and placed logs in both onAttachedToEngine and registerWith but neither seem to be invoked which would explain the MissingPluginException.

This is seen running on a Pixel 3 running API 30 (emulator).

flutter doctor output
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.6.4 20G417 darwin-x64, locale en-US)
    • Flutter version 2.8.1 at /Users/brandontrautmann/fvm/versions/2.8.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (3 months ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/brandontrautmann/Library/Android/sdk
    • Platform android-31, build-tools 30.0.3
    • ANDROID_SDK_ROOT = /Users/brandontrautmann/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio Archives/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.64.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (4 available)
    • sdk gphone x86 64 (mobile) • emulator-5554                        • android-x64    • Android 11 (API 30) (emulator)
    • iPhone 13 (mobile)         • 8ADFB0F5-C636-4F54-AB0E-325A9E60878A • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2
      (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • macOS 11.6.4 20G417 darwin-x64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 98.0.4758.109

• No issues found!

Status of 'Official' Datadog SDK Integration

Hi there amazing developers!

Our company is building out a mobile application with Flutter, and we were pleasantly surprised to find that Dutchie has a 'quasi-official' Flutter implementation for Datadog, that Datadog officially approves of and is planning to turn their package into an official Datadog SDK with Flutter, as explained in this YouTube video.

That was in late October 2021, and I was wondering if there was an update in the 'transition' to official status?

Runtime Exception: Method call failed while Initialization

final ddLogger = DatadogLogger(loggerName: 'xyz');
Service Name is missing

**call.method == "loggerCreateLogger" -> {
       val builder = Logger.Builder()
               .setNetworkInfoEnabled(true)
104:               .setServiceName(call.argument<String>("serviceName")!!)**

Stack Trace:

E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589): Failed to handle method call
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589): kotlin.KotlinNullPointerException
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at com.greenbits.datadog_flutter.DatadogFlutterPlugin.onMethodCall(DatadogFlutterPlugin.kt:104)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.greenbits.com/datadog_flutter( 6589):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

@tshedor i think we are missing serviceName argument for this call.argument("serviceName")!!

Kotlin version mismatch due to a Flutter 2.10.0 breaking change

Case
In our project, this plugin throws an error that the Kotlin version is mismatched. This is likely due to a breaking change in the Flutter SDK, in which a version bump is required. Our project targets the sdkVersion 31.

Reproduce steps
To reproduce, run flutter upgrade in the stable branch and upgrade to 2.10.0. Then, try to build the app.

Expected behavior
It should throw multiple errors in which building failed due to classes compiling with the wrong version.

Possible Fix
This is temporarily fixed by changing the ext.kotlin_version to 1.6.10 (according to the breaking change page, it should working starting version +1.5.13).

Odd mappings of log levels happening on Android

Hi there! We're working on integrating this flutter plugin into our codebase and noticing an oddity around Android's log levels once logs land in the datadog backend.

In short, all of our info logs are being mapped to debug. I first confirmed that we are definitely logging them as info to the public log function of the dart API, and then isolated the problematic mapping to these lines in the Android side of the plugin. It looks like debug is being mapped to verbose, info is being mapped to debug, and notice is being mapped to info.

Additionally, on the dart side within datadog_logger, passing Level.INFO would interestingly get mapped to notice based on its value, so we were downgrading our Level.INFO priorities to Level.CONFIG to fall into the info bucket, but now we realize this won't work because info is being mapped to debug on the Android side.

We confirmed that everything works as expected on iOS, assuming we do the downgrading to Level.CONFIG mentioned above. Here's where iOS correctly maps the value sent by dart to the native SDK methods.

So we are hoping to bring clarity to two things:

  1. Hopefully clean up the mapping on the dart side within the _levelAsStatus function to correctly map Level.INFO to info
  2. Fix the mapping on the Android side of the plugin

This should bring both platforms to parity, though this may be a breaking change if anybody has done the same type of downgrading we were planning on doing in their implementations.

We'd be happy to open a PR up for this, but wanted to ensure this was indeed a bug prior to doing so.

`environment` does not seem to be respected in Android

Hi,

I was trying to add a sample integration with datadog to our flutter app today.

I realised that the environment property in the init call is respected by iOS. On Android on the other hand the environment is ignored. Instead datadog uses the serviceName as environment (both serviceName and environment are the same when using android).

After checking the Kotlin code of the initWithClientToken-method it seems to me that the environment is simply not set on Android.

Problem with the new version 1.4.1

Hi,

In the new version, my CI saying :

e: /opt/hostedtoolcache/flutter/2.8.1-stable/x64/.pub-cache/hosted/pub.dartlang.org/datadog_flutter-1.4.1/android/src/main/kotlin/com/greenbits/datadog_flutter/DatadogFlutterPlugin.kt: (200, 69): Unresolved reference: uppercase

Do you know why ?
waiting for, I set in my pub the 1.4.0 and it's good

Thank you and have a nice day 😬

datadog_flutter-1.1.0-dev.6 Compile error

datadog_flutter-1.1.0-dev.6/android/src/main/kotlin/com/greenbits/datadog_flutter/DatadogFlutterPlugin.kt: (125, 57): Type mismatch: inferred type is Map<String, Any?>? but Map<String, Any?> was expected

@tshedor i got the above compile error

User actions are being dropped for Android devices with "no side effect was registered during its scope" notice

We recently added this package to our mobile applications to track page views and user actions. The same user actions that are registering and being reported to datadog for an iOS mobile device are getting dropped on Android devices.

This same action that is coming through and viewable in datadog for an iOS device (iPhone 12 in the XCode simulator)

image

is getting dropped on an Android device (Pixel 5 API 31 in Andoid Studio emulator) with the error:

I/Datadog (26349): RUM Action fe7e6881-dfc3-46a6-a170-fa44f6f0b06a (TAP on housingServiceFavorited) was dropped (no side effect was registered during its scope)

Screen Shot 2021-09-17 at 5 30 41 PM

I double checked my configuration and my androidRumApplicationId is correct. Views and other data is reporting as expected.

This log message no side effect was registered during its scope can be found in the dd-sdk-android.

We are glad to be using this package and looking forward to a resolution here 🙏🏼

Question: How to use `DatadogTracingHttpClient` with `Dio`

Hi there, it's me again.

I am currently trying to use the DatadogTracingHttpClient together with Dio. The README.md suggested this is possible via Composition. Yet I am unable to get it to work.

This is how far i have come already:

Dio allows to overwrite the httpClientAdapter:

  final client = Dio();

  client.httpClientAdapter = ... as HttpClientAdapter;

Yet I don't understand how to convert the DatadogTracingHttpClient which extends http.BaseClient to a HttpClientAdapter.

Any help is much appreciated.

BUG: Tracing feature is disabled

Logs
Tracing feature is disabled, so no tracing data (http tracing) not sent to DataDog

E/Datadog ( 6802): You're trying to create an AndroidTracer instance, but the Tracing feature was disabled in your DatadogConfig. No tracing data will be sent.
W/Datadog ( 6802): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.

@tshedor i think we need to add setTracesEnabled(true) in DataDogConfigBuilder providing option to user through constructor

Plugin throwing exception on Android

I've installed the plugin and see it successfully working on iOS, however in Android it is crashing, I'm initializing the logger like so:

const datadogClientToken = "s3cr37";

ddLogger = DatadogFlutter(
    clientToken: datadogClientToken,
    serviceName: 'flutter-clientapp',
    environment: 'production',
  );

ddLogger.log("DDLogging Initialized", Level.INFO);

When I call the log method I see the following exception trace:

E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): Failed to handle method call
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): kotlin.KotlinNullPointerException
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at com.greenbits.datadog_flutter.DatadogFlutterPlugin.onMethodCall(DatadogFlutterPlugin.kt:83)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at android.app.ActivityThread.main(ActivityThread.java:6494)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E/MethodChannel#plugins.greenbits.com/datadog_flutter(22883): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
E/flutter (22883): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, null, null, kotlin.KotlinNullPointerException
E/flutter (22883): 	at com.greenbits.datadog_flutter.DatadogFlutterPlugin.onMethodCall(DatadogFlutterPlugin.kt:83)
E/flutter (22883): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (22883): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (22883): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/flutter (22883): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (22883): 	at android.os.MessageQueue.next(MessageQueue.java:325)
E/flutter (22883): 	at android.os.Looper.loop(Looper.java:142)
E/flutter (22883): 	at android.app.ActivityThread.main(ActivityThread.java:6494)
E/flutter (22883): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter (22883): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E/flutter (22883): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
E/flutter (22883): )
E/flutter (22883): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
E/flutter (22883): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)
E/flutter (22883): <asynchronous suspension>
E/flutter (22883): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (22883): #3      DatadogFlutter.log (package:datadog_flutter/datadog_flutter.dart:61:27)
E/flutter (22883): #4      main (package:client_app/main.dart:73:12)
E/flutter (22883): #5      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (22883): #6      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (22883): #7      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (22883): #8      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (22883): #9      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (22883): #10     Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (22883): #11     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
E/flutter (22883): #12     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
E/flutter (22883): #13     Firebase.initializeApp (package:firebase_core/src/firebase.dart)
E/flutter (22883): #14     _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (22883): #15     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (22883): #16     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (22883): #17     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (22883): #18     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (22883): #19     Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (22883): #20     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
E/flutter (22883): #21     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
E/flutter (22883): #22     MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart)
E/flutter (22883): #23     _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (22883): #24     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (22883): #25     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (22883): #26     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (22883): #27     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (22883): #28     Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (22883): #29     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
E/flutter (22883): #30     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
E/flutter (22883): #31     MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart)
E/flutter (22883): #32     _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (22883): #33     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (22883): #34     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (22883): #35     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (22883): #36     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (22883): #37     Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (22883): #38     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
E/flutter (22883): #39     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
E/flutter (22883): #40     Meth

Crash Reporting

Hello!

Thank you for the great package, its working wonderfully for us.

I have a question about crash reporting. This is supported by the native packages for Android and iOS

Any plans of supporting this functionality for Flutter?

Cheers

log attributes ignored on iOS

Hi there,

on iOS the attributes added to a log don't show up in datadog. The log itself shows up, but only the Android logs contain the attribute durationInMilliseconds.

This code works for Android but not for iOS:

        ddLogger.log(
          'time to initialize the app',
          Level.INFO,
          attributes: {
            'durationInMilliseconds': 1000,
          },
        );

Random failure when logging

Details

Hi!

I am facing a quite unexpected behaviour with the package.
Logging sometimes works, and some other times doesn't.

The message that is displayed when the log fails is this one: failed because of a processing error or invalid data.
I am only logging a simple String message, and I have also tried wrapping the log static method with a try catch without success.

Do you have any clue or suggestion on how to overcome this?

PS Thanks for the package!!!

I am able to initalized the Datadog but unable to send any events or logs (Android iOS)

W/Datadog ( 3737): The Datadog library has already been initialized.
W/Datadog ( 3737): RumMonitor has already been registered
W/Datadog ( 3737): A RUM event was detected, but no view is active. To track views automatically, try calling the DatadogConfig.Builder.useViewTrackingStrategy() method.
W/Datadog ( 3737): You can also track views manually using the RumMonitor.startView() and RumMonitor.stopView() methods.

@tshedor Please Help in bypassing or help in understanding whats the issue

And i tried to change my environment and i get one more from datadog log

Unable to send batch [510 bytes] (LogsOkHttpUploader) because your token is invalid. Make sure that the provided token still exists.+ flutter datadog**

Logging does not work on Android

Hey!

I have just tried out this plugin. Logging works fine on iOS, but the same configuration does not work on Android. This is my configuration:

await DatadogFlutter.initialize(
  clientToken: const String.fromEnvironment('DATADOG_CLIENT_TOKEN'),
  serviceName: 'mobile_service',
  flavorName: 'dev',
  environment: 'dev',
  trackingConsent: TrackingConsent.granted, // TODO: Ask for permission,
  useEUEndpoints: true,
);

I get the log message that batch is published V/Datadog (13280): Batch [2255 bytes] sent successfully (LogsOkHttpUploader)., but logs do not appear in Datadog.

Also, I am running this code on the arm64 Android Emulator "Pixel 4a API 31".

In case you need more information - let me know.

Thanks for your effort!

Web Build Error 'TypeError: Cannot read properties of undefined (reading: 'init'), null, null)

Hey everyone, I am loving this unofficially official flutter SDK for Datadog. The Android and iOS builds work very smoothly, but I am having an issue with the web build/deployment that I was wondering if someone can help me with/identity the issue.

When running the Chrome development server, I am getting this data in the Chrome console:

VM473:1 This app is linked to the debug service: ws://127.0.0.1:55452/nO3G8J4sP-4=/ws
errors.dart:251 Uncaught (in promise) Error: PlatformException(error, TypeError: Cannot read properties of undefined (reading 'init'), null, null)
    at Object.throw_ [as throw] (errors.dart:251:49)
    at StandardMethodCodec.decodeEnvelope (message_codecs.dart:607:7)
    at MethodChannel._invokeMethod (platform_channel.dart:177:18)
    at _invokeMethod.next (<anonymous>)
    at async_patch.dart:45:50
    at _RootZone.runUnary (zone.dart:1685:54)
    at _FutureListener.thenAwait.handleValue (future_impl.dart:159:18)
    at handleValueCallback (future_impl.dart:766:44)
    at Function._propagateToListeners (future_impl.dart:795:13)
    at _Future.new.[_completeWithValue] (future_impl.dart:601:5)
    at async._AsyncCallbackEntry.new.callback (future_impl.dart:639:7)
    at Object._microtaskLoop (schedule_microtask.dart:40:11)
    at _startMicrotaskLoop (schedule_microtask.dart:49:5)
    at async_patch.dart:166:15```

There are no failing network requests, meaning all files are being fetched - seems to be limited to compilation error.

Now, when trying to run a production build and generate a `main.dart.js` bundle, I get a slightly more helpful error:
```(index):91 Failed to load app from service worker. Falling back to plain <script> tag.
(anonymous) @ (index):91
main.dart.js:3296 Uncaught PlatformException(error, ReferenceError: DD_LOGS is not defined, null, null)
    at Object.c (https://cedarai.github.io/flutter-mobile/main.dart.js:3296:3)
    at ab6.DB (https://cedarai.github.io/flutter-mobile/main.dart.js:60273:14)
    at https://cedarai.github.io/flutter-mobile/main.dart.js:60346:98
    at anJ.a (https://cedarai.github.io/flutter-mobile/main.dart.js:4486:62)
    at anJ.$2 (https://cedarai.github.io/flutter-mobile/main.dart.js:33181:14)
    at amK.$1 (https://cedarai.github.io/flutter-mobile/main.dart.js:33175:21)
    at SW.kA (https://cedarai.github.io/flutter-mobile/main.dart.js:34133:32)
    at age.$0 (https://cedarai.github.io/flutter-mobile/main.dart.js:33546:11)
    at Object.uq (https://cedarai.github.io/flutter-mobile/main.dart.js:4576:40)
    at a5.ql (https://cedarai.github.io/flutter-mobile/main.dart.js:33478:3)```

Any idea what might be going on? I've tried digging into the main.dart.js, but the minified code isn't giving me much. I can post it later if you can't think of anything.

iOS and Android initialization success but logs are not sending

I'v tested the same client token/rum id on a react web app and i was able to log to datadog.. so looks like it's not the tokens.. any thoughts?

Initialization:

Future main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await dotenv.load();
  setupLocator();

  // configLoading();
  HttpOverrides.global = new MyHttpOverrides();
  await DatadogFlutter.initialize(
      clientToken: client_token,
      environment: 'develop',
      iosRumApplicationId: rum_token,
      androidRumApplicationId: rum_token,
      webRumApplicationId: rum_token,
      serviceName: app,
   
      trackingConsent: TrackingConsent.granted,
      );
  final ddLogger = DatadogLogger();
  // Capture Flutter errors automatically:
  FlutterError.onError = DatadogRum.instance.addFlutterError;
  DatadogRum.instance.addUserAction('TAP');

  await DatadogTracing.initialize();
  await ddLogger.log('a warning', Level.WARNING);
  await ddLogger.log('a severe', Level.SEVERE);
  await ddLogger.log('a shout', Level.SHOUT);
  await ddLogger.log('a fine', Level.FINE);
  await ddLogger.log('a finer', Level.FINER);
  await ddLogger.log('a finest', Level.FINEST);
  await ddLogger.log('an info', Level.INFO);

  runZonedGuarded(() {
    runApp(
      App(),
    );
  }, (error, stackTrace) {
    DatadogRum.instance.addError(error, stackTrace);
  });
}

Screen Shot 2021-10-07 at 4 44 58 PM

ios output

Screen Shot 2021-10-07 at 4 44 35 PM

android output

Unable to determine Swift version for the following pods 'datadog_flutter'

I am seeing , datadog_flutter does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod. is there a fix for this issue ?

Below is the summary of flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.3, on macOS 11.5.2 20G95 darwin-x64, locale en-NL)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[!] Xcode - develop for iOS and macOS (Xcode 12.5)
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.4)
[✓] VS Code (version 1.65.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

! Doctor found issues in 2 categories.

Deprecation of Community Plugin

The Datadog team has released an official version of their SDK. Since they are a team and very close to the APIs and features of the iOS and Android SDKs, it is with a heavy and joyful heart that version 2 of datadog_flutter will be the final release of this community package.

The migration is not exactly one to one. Below is a migration guide, however, as the new SDK has just reached beta, it is impartial (add more in the comments and I'll edit this list as we discover disparity). If you have questions about the new SDK or APIs, please open issues on the new repo. Good luck @fuzzybinary @xgouchet and thanks for your work in releasing this new SDK.

Thank you to everyone for your support and contributions to this plugin, especially @btrautmann @charafau @QuirijnGB.

Migration Guide (WIP)

  • Rename datadog_flutter to datadog_flutter_plugin. The Datadog team has decided to not use the datadog_flutter package name.
  • The initialization API is extremely similar, however, you cannot pass keys for different platforms. Instead, consider applicationId: Platform.isAndroid ? androidKey : iosKey. For apps that use web/linux/mac/windows too, you'll have to be more creative with your solution.
  • Use the global logger in DatadogSdk.instance.logs. While you can still use the individual logger architecture, the class isn't publicly exposed (DataDog/dd-sdk-flutter#121) as of writing.
  • Web is not supported by the new SDK yet. Do not migrate if you use Flutter web.
  • HTTP tracing has been mostly completely rewritten (cc #104). Please review the new datadog_trackiing_http_client package to integrate with your app. Don't forget to enable automatic capture.
  • DatadogObserver is now DatadogNavigationObserver

App crashes on iOS

Hello, after flutter update to 3.0.5 app started to crash on iOS using this plugin version 2.0.0

[DATADOG SDK] 🐶 → 13:43:55.060 [ERROR] 'dd.trace_id' is a reserved attribute name. This attribute will be ignored.
[DATADOG SDK] 🐶 → 13:43:55.060 [ERROR] 'dd.span_id' is a reserved attribute name. This attribute will be ignored.
flutter: AuthenticationStatus.authenticated
2
datadog_flutter/SwiftDatadogFlutterPlugin.swift:267: Fatal error: Unexpectedly found nil while unwrapping an Optional value
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
    frame #0: 0x00000001e4a4a458 libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`_swift_runtime_on_report:
->  0x1e4a4a458 <+0>: ret
libswiftCore.dylib`_swift_reportToDebugger:
    0x1e4a4a45c <+0>: b      0x1e4a4a458               ; _swift_runtime_on_report
libswiftCore.dylib`_swift_shouldReportFatalErrorsToDebugger:
    0x1e4a4a460 <+0>: adrp   x8, 335240
    0x1e4a4a464 <+4>: ldrb   w0, [x8, #0x45c]
Target 0: (Runner) stopped.
Lost connection to device.

Also for some reasons i see another error in here dd.trace_id' is a reserved attribute name

RUM and Logger

so I use both RUM and Logger to log my app

but I only define the RUM client token when I initialize the DatadogFlutter, does my app able to log using Logger functionality too?

Invalid kind enum

While not getting response regarding this bug: #64 I had to dig deeper into datadog java code regarding this error:

image

It appears that Enums that you are using in stopResoureceLoading are lowercased and in datadog java sdk all enums are uppercased: https://github.com/DataDog/dd-sdk-android/blob/2b9d9cce4d3e557bcf2881ae3613668923bcb7e1/dd-sdk-android/apiSurface (search for enum com.datadog.android.rum.RumResourceKind)
When added upercase FETCH problem was gone.
Please update default value and documentation

Attributes still are being ignored in iOS v1.4.0

Hi @tshedor ,

Even with the latest update that has a commit regarding fixing the attributes in iOS, attributes are not still passed.

I have a sample attribute with a value like this:

{ "key1":"value1", "key2":"value2" }

it works fine if the attributes are only simple values, but passing a dictionary will break the following cast in iOS code:

return unencodedAttributes as? [AttributeKey : AttributeValue]](

return unencodedAttributes as? [AttributeKey : AttributeValue]
)

I understand that you mentioned in the comments that dictionary attributes support are limited. Still, since Datadog supports up to 10 level inner attributes, I think it is worth adding.

Would you please let me know if I could be any of help adding this?

Thanks :)

Request: Http Network Resources Auto tracking

@tshedor Is it possible to auto track network resources instead of manual tracking.
Like Adding NetworkResourceInterceptor which user can add to the http client, instead of manually tracking http resources in lot of defined places.

datadog_flutter v1.7.0: App crashes when extraInfo property in setUserInfo method is null

datadog_flutter v1.7.0: App crashes when extraInfo property in setUserInfo method is null. Based on the changelog, this problem should have been appeared since datadog_flutter v1.5.2 with BREAKING CHANGE all attribute maps have been updated from Map<String, dynamic> to Map<String, Object>. These Maps no longer support nullable values.

This is the error from the native layer:

datadog_flutter/SwiftDatadogFlutterPlugin.swift:327: Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Swift.Dictionary<Swift.String, AnyCodable.AnyCodable>, Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data did not contain a top-level value.", underlyingError: nil))

This error occurs when calling the setUserInfo method like this:

DatadogFlutter.setUserInfo(
  id: '123',
  email: '[email protected]',
);

You can fix the problem by providing an empty object to extraInfo.

DatadogFlutter.setUserInfo(
  id: '123',
  email: '[email protected]',
  extraInfo: {},
);

I think you should either specify the default value for extraInfo (e.g. empty object) or fix the bug in the native layer to expect a nullable value.

Flutter doctor command output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.4, on macOS 12.0.1 21A559 darwin-arm, locale en-LT)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.65.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

Let me know if you need any more details.

403 Forbidden - Bintray download fails for dependency dd-sdk-android:1.4.3

Could not resolve com.datadoghq:dd-sdk-android:1.4.3.
Required by:
 project :
> Could not resolve com.datadoghq:dd-sdk-android:1.4.3.
> Could not get resource 'https://dl.bintray.com/datadog/datadog-maven/com/datadoghq/dd-sdk-android/1.4.3/dd-sdk-android-1.4.3.pom'.
> Could not GET 'https://dl.bintray.com/datadog/datadog-maven/com/datadoghq/dd-sdk-android/1.4.3/dd-sdk-android-1.4.3.pom'. Received status code 403 from server: Forbidden

Looks like Datadog moved to Maven Central, but they did not copy over the old versions of the library. They are only hosting recent versions from 1.8.1 and higher. The older versions are still hosted on Bintray, which is 403'ing.

Potential solutions:

  1. Publish cached version of 1.4.3 to MavenCentral on your own,
  2. Upgrade to 1.8.1 or newer of the dd-sdk-android library. I attempted to do this hoping for no breaking changes, but this is not the case. I can keep working on it until I can post a PR unless you beat me to this.

If possible, can this change be made off of 0.0.3 instead of with the null safety commit? My app is not ready for null safety, so publishing with that would likely prevent anyone using from upgrading if they haven't upgraded to Flutter SDK 2.12 or higher.

Web not supported

Hi,

I just tried to installed your plugin (which looks amazin BTW !) but i'm trying to vuild for web.
By looking at the code it seems like your dart code directly calls the IOS and Android functions.

As a result, the following error happens when I start the app

Error: MissingPluginException(No implementation found for method initWithClientToken on channel
plugins.greenbits.com/datadog_flutter)
    at Object.throw_ [as throw] (http://localhost:33397/dart_sdk.js:5333:11)
    at MethodChannel._invokeMethod
    (http://localhost:33397/packages/flutter/src/services/system_channels.dart.lib.js:954:21)
    at _invokeMethod.next (<anonymous>)
    at http://localhost:33397/dart_sdk.js:39031:33
    at _RootZone.runUnary (http://localhost:33397/dart_sdk.js:38888:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:33397/dart_sdk.js:33874:29)
    at handleValueCallback (http://localhost:33397/dart_sdk.js:34434:49)
    at Function._propagateToListeners (http://localhost:33397/dart_sdk.js:34472:17)
    at _Future.new.[_completeWithValue] (http://localhost:33397/dart_sdk.js:34314:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:33397/dart_sdk.js:34337:35)
    at Object._microtaskLoop (http://localhost:33397/dart_sdk.js:39175:13)
    at _startMicrotaskLoop (http://localhost:33397/dart_sdk.js:39181:13)
    at http://localhost:33397/dart_sdk.js:34688:9

Do you plan to support Web in the near future ?

No rum data uploaded - "(rum) No upload"

I've had the logging working for a while but decided to add RUM for error tracking. No matter what I try though I always get the message (rum) No upload.

  await DatadogFlutter.initialize(
    trackingConsent: TrackingConsent.granted,
    clientToken: const String.fromEnvironment("DD_TOKEN"),
    iosRumApplicationId:
        const String.fromEnvironment("DD_IOS_RUM_APPLICATION_ID"),
    serviceName: 'app-name',
    environment: "production",
    useEUEndpoints: true,
  );
  await DatadogFlutter.setUserInfo(id: "anon1");
  await DatadogRum.instance.addUserAction("hello");

Am I correct in thinking that the above should cause the user action to be sent with the next RUM data batch upload? (DD_TOKEN is my main client_token, I also tried the rum app client_token which again worked for logging but not RUM). Maybe I'm missing a step?

Bug: Logging not working for iOS

final ddLogger = DatadogLogger(loggerName: 'xyz');
await ddLogger.log("App launched", Level.INFO);

Android: Working, able to see logs in Log section of datadog log dashboard
iOS: Not able to see the logs
Won't be able to get stack trace as no runtime error in console.

@tshedor i think there is some issue with createLogger or log method call in SwiftDatadogFlutterPlugin.swift

Bug in Datadog Observer implementation

The current implementation of didPop takescurrent route that is being popped as newRoute and route that is coming into the view after didPop is considered as previousRoute.

This implementation is wrong. The correct way is that we have to switch the way we are currentRoute is fetched in didPop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.