reportMetric static method
Allows reporting numeric values associated with a metric name
. For
example, to track the number of times your users clicked the checkout
button.
name
should contain only alphanumeric characters and spaces.
Illegal characters shall be replaced by their ASCII hex value.
Method might throw Exception.
import 'package:appdynamics_agent/appdynamics_agent.dart';
import 'package:flutter/material.dart';
class App extends StatelessWidget {
_finishCheckout() {
Instrumentation.reportMetric(name: "Checkout Count", value: 1);
// rest of the checkout logic
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Checkout screen")),
body: Center(
child:
ElevatedButton(
child: Text('Checkout'),
onPressed: _finishCheckout,
)
));
}
Implementation
static Future<void> reportMetric({
required String name,
required int value,
}) async {
try {
final arguments = {"name": name, "value": value};
await channel.invokeMethod<void>('reportMetric', arguments);
} on PlatformException catch (e) {
throw Exception(e.details);
}
}