flutter_dynatrace 0.0.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 56

flutter_dynatrace #

This plugin allows you to use the Dynatrace Mobile SDKs (iOS and Android) to help monitor your Flutter apps. Please give the example app attached to the plugin repo a go if you want to test out the similar SDK calls in this doc.

This plugin is NOT officially supported by Dynatrace.

How to use the plugin: #

Android: #

Grade snippet in WebUI

Add the code snippet from the WebUI to your Root build.gradle file: Grade snippet in Android Studio Link to the official Dynatrace doc on implementing the above

iOS: #

Go to your project in terminal and run: pod install pod install command in terminal

Add the code snippet from the WebUI to your Runner info.plist: info.plist in WebUI info.plist in Xcode

Starting the Agent manually: #

import 'package:flutter_dynatrace/flutter_dynatrace.dart';
import 'dart:io' show Platform;

String appId = "updateThisValue";
String beaconUrl = "updateThisValue";

// This can be set in the initState function so that the agents can start when the app starts
@override
  void initState() {
	if (Platform.isIOS == true) {
		Dynatrace.startupWithInfoPlistSettings();
	} else if (Platform.isAndroid == true) {
		// startup(String appId, String beaconUrl, bool withDebugLogging, bool certValidation, bool crashReporting, bool optIn)
		Dynatrace.startup(appId, beaconUrl, true, false, false, false);

	super.initState();
  }


Single/Parent Action: #

Dynatrace.enterAction(); Required parameters:

  • parentAction
  • parentActionName

Dynatrace.leaveAction(); Required parameters:

  • parentAction
Dynatrace.enterAction(parentAction: actions[0], parentActionName: "Touch on " + options[1]);
// do something
Dynatrace.leaveAction(parentAction: actions[0]);

Result: Single Action


Sub Actions: #

Dynatrace.enterAction(); Required parameters:

  • parentAction
  • subAction
  • subActionName

Dynatrace.leaveAction(); Required parameters:

  • subAction
Dynatrace.enterAction(parentAction: actions[1], parentActionName: "Touch on " + options[2]);
// do something
Dynatrace.enterAction(subAction: actions[2], subActionName: "First Sub Action", parentAction: actions[1]);
// do something
Dynatrace.enterAction(subAction: actions[3], subActionName: "Second Sub Action", parentAction: actions[1]);
// do something
Dynatrace.enterAction(subAction: actions[4], subActionName: "Third Sub Action", parentAction: actions[1]);
// do something
Dynatrace.leaveAction(subAction: actions[4]);
Dynatrace.leaveAction(subAction: actions[3]);
Dynatrace.leaveAction(subAction: actions[2]);
Dynatrace.leaveAction(parentAction: actions[1]);

Result: Sub Actions


Web Action (Needs to be inside of a Parent or Sub Action): #

Note: Currently have this set for JSON requests and request types of POST or GET. I will work on making this more dynamic in the future.

Dynatrace.dynaWebRequest(); Required parameters:

  • parentAction OR subAction
  • url
  • requestType
    • "GET"
    • "POST"
List<String> urls = ["https://dog.ceo/api/breed/husky/image/random", "https://dog.ceo/api/breed/labrador/image/random", "https://dog.ceo/api/breed/retriever/images/random", "https://dog.ceo/api/breed/sheepdog/images/random", "https://dog.ceo/api/breed/chow/images/random"];
Dynatrace.enterAction(parentAction: actions[5], parentActionName: "Touch on " + options[3]);
// This is used for web requests of application/json and will automatically tag and time the request and return of response body if you want to use it.
// I will add more functionality to this in upcoming releases/updates
// requestType can be "POST" or "GET" - if others are used, the web request will not occur
Dynatrace.dynaWebRequest(parentAction: actions[5], url: urls[0], requestType: "GET");
Dynatrace.dynaWebRequest(parentAction: actions[5], url: urls[1], requestType: "GET");
Dynatrace.dynaWebRequest(parentAction: actions[5], url: urls[2], requestType: "GET");
Dynatrace.dynaWebRequest(parentAction: actions[5], url: urls[3], requestType: "GET");
Dynatrace.dynaWebRequest(parentAction: actions[5], url: urls[4], requestType: "GET");
Dynatrace.leaveAction(parentAction: actions[5]);

Result: Web Action


Web Action with reportValue - String: #

Dynatrace.reportValue(); (String) Required parameters:

  • parentAction OR subAction
  • key
  • stringValue
Dynatrace.enterAction(parentAction: actions[6], parentActionName: "Touch on Web Action + reportString");
// This is used for web requests of application/json and will automatically tag and time the request and return of response body if you want to use it.
// I will add more functionality to this in upcoming releases/updates
// requestType can be "POST" or "GET" - if others are used, the web request will not occur
// set response to String of JSON
String reportValueMessage = await Dynatrace.dynaWebRequest(parentAction: actions[6], url: "https://dog.ceo/api/breeds/image/random", requestType: "GET");
// decode response
var jsonResp = json.decode(reportValueMessage);
// set new String to grab the key title's value
var message = jsonResp["message"];
// use the reportValue(string) SDK to put it in the waterfall
Dynatrace.reportValue(parentAction: actions[6], key: "Message", stringValue: message);
// leave action
Dynatrace.leaveAction(parentAction: actions[6]);

Result: Web Action with reportString

With just a parentAction and reportString: reportValue - String


reportValue - Int: #

Dynatrace.reportValue(); (Int) Required parameters:

  • parentAction OR subAction
  • key
  • intValue
Dynatrace.enterAction(parentAction: actions[8], parentActionName: "Touch on + " + options[6]);
Dynatrace.reportValue(parentAction: actions[8], key: "Jenny", intValue: 8675309);
Dynatrace.leaveAction(parentAction: actions[8]);

Result: reportValue - Int


reportValue - Double: #

Dynatrace.reportValue(); (Double) Required parameters:

  • parentAction OR subAction
  • key
  • doubleValue
Dynatrace.enterAction(parentAction: actions[9], parentActionName: "Touch on + " + options[7]);
Dynatrace.reportValue(parentAction: actions[9], key: "Mobile", doubleValue: 1.337);
Dynatrace.leaveAction(parentAction: actions[9]);

Result: reportValue - Double


reportEvent: #

Dynatrace.reportEvent(); Required parameters:

  • parentAction OR subAction
  • event
Dynatrace.enterAction(parentAction: actions[10], parentActionName: "Touch on + " + options[8]);
Dynatrace.reportEvent(parentAction: actions[10], event: "Data has been received!");
Dynatrace.leaveAction(parentAction: actions[10]);

Result: reportEvent


reportError: #

This is essentially the same implementation as reportEvent currently. I will update this in a future release.

Dynatrace.reportError(); Required parameters:

  • parentAction OR subAction
  • error
int a = 100; 
int b = 0; 
int result;

Dynatrace.enterAction(parentAction: actions[12], parentActionName: "Touch on + " + options[10]);

	try {  
    	result = a ~/ b; 
    } catch(e) { 
        Dynatrace.reportError(parentAction: actions[12], error: e.toString()); 
    } 

Dynatrace.leaveAction(parentAction: actions[12]);

Result: reportError2 reportError


All options for reportValue + reportEvent + reportError: #

int a = 100; 
int b = 0; 
int result;

Dynatrace.enterAction(parentAction: actions[12], parentActionName: "Touch on + " + options[10]);
Dynatrace.reportValue(parentAction: actions[12], key: "Dynatrace", stringValue: "All-in-one, all you need");
Dynatrace.reportValue(parentAction: actions[12], key: "Jenny", intValue: 8675309);
Dynatrace.reportValue(parentAction: actions[12], key: "Mobile", doubleValue: 1.337);
Dynatrace.reportEvent(parentAction: actions[12], event: "Data has been received!");

	try {  
    	result = a ~/ b; 
    } catch(e) { 
        Dynatrace.reportError(parentAction: actions[12], error: e.toString()); 
    } 

Dynatrace.leaveAction(parentAction: actions[12]);

Result: reportValues


Using identifyUser: #

String userName = "flutter@dynatrace.com"; 
Dynatrace.identifyUser(userName);

Setting Data Collection Level: #

// Set level to off - You can use "OFF" or "off"
Dynatrace.setDataCollectionLevel("OFF");

// Set level to performance - You can use "PERFORMANCE" or "performance"
Dynatrace.setDataCollectionLevel("PERFORMANCE");

// Set level to user behavior - You can use "USER_BEHAVIOR" or "user_behavior"
Dynatrace.setDataCollectionLevel("USER_BEHAVIOR");

Setting Crash Reporting Capture: #

// On
Dynatrace.setCrashReportingOptedIn(true);

// Off
Dynatrace.setCrashReportingOptedIn(false);

No parameter SDK calls: #

Dynatrace.flushEvents();
Dynatrace.endVisit();
Dynatrace.shutdown();

SDK calls with return values: #

These will return a Future

dataCollectionLevel() async {	
    String collLevel = await Dynatrace.getDataCollectionLevel();
	debugPrint(collLevel);
}

crashReportCapture() async {
	bool crashReport = await Dynatrace.isCrashReportingOptedIn();
	debugPrint(crashReport.toString());
}

isCaptureStatus() async {
	bool capture = await Dynatrace.getCaptureStatus();
	debugPrint(capture.toString());
}

Results from the Example app in Dynatrace (Left is Android - Right is iOS): #

Overall Session view from the above examples: Sessions


I will provide more examples and features in upcoming releases. Any feedback on what you like and or don't like and what would be useful to have changed/updated, would be fantastic!

Thanks!

0.0.1 #

  • TODO: Describe initial release.

0.0.2 #

  • Updated doc with examples and how to implement the plugin/mobile agents.

0.0.3 #

  • Updated/moved around doc.

0.0.4 #

  • Doc :( Forgot to add Data collection level/crash report capture.

0.0.5 #

  • Updated Web Request timing/tagging logic and doc.

0.0.6 #

  • Updated logic for Parent and sub actions. Updated logic for Web requests. Added license.

0.0.7 #

  • Updated logic for web requests for both iOS and Android.

0.0.8 #

  • Removed extra code from previous web request logic.

example/README.md

flutter_dynatrace_example #

Demonstrates how to use the flutter_dynatrace plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_dynatrace: ^0.0.8

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_dynatrace/flutter_dynatrace.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
18
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
88
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

22 out of 22 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/flutter_dynatrace.dart.

Run flutter format to format lib/flutter_dynatrace.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The description is too long. (-2 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test