measure_flutter library
Flutter SDK for measure.sh
Measure is an open source tool to monitor mobile apps, this package contains the Flutter SDK which helps instrumenting your app easily.
Integration
Install the SDK
Add the following dependency to your pubspec.yaml
file:
dependencies:
measure_flutter: ^0.1.0
Initialize the SDK
To initialize the SDK, you need to call the Measure.instance.init
method in your main
function
and wrap your application with MeasureWidget
as the parent.
Future<void> main() async {
await Measure.instance.init(
() =>
runApp(
MeasureWidget(child: MyApp()),
),
config: const MeasureConfig(
enableLogging: true,
traceSamplingRate: 1,
samplingRateForErrorFreeSessions: 1,
),
clientInfo: ClientInfo(
apiKey: "YOUR_API_KEY",
apiUrl: "YOUR_API_URL",
),
);
}
Verify Installation
Launch the app with the SDK integrated and navigate through a few screens. The data is sent to the server periodically,
so it may take a few seconds to appear. Checkout the Usage
section in the dashboard or navigate to the Sessions
tab
to see the sessions being tracked.
Track screen views
To hook up with the Flutter navigation system, use the MsrNavigatorObserver which automatically
tracks screen views when navigating between screens. You can add it to your MaterialApp
or
CupertinoApp
as follows:
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [MsrNavigatorObserver()],
home: HomeScreen(),
);
}
To manually track screen views in a Flutter application, you can use the trackScreenViewEvent
method:
Measure.instance.trackScreenViewEvent(name: "Home");
Track http events
Network requests made using the Dio package can be tracked by adding the measure_dio
package to your
project. This package provides MsrInterceptor
that can automatically track network requests done
using Dio.
final dio = Dio();
dio.interceptors.add(MsrInterceptor());
For any other HTTP client libraries, you can manually track network requests using the
trackHttpEvent
method.
Checkout detailed documentation
Checkout the documentation to learn more about Measure.
Classes
- AttributeBuilder
- A fluent builder for creating attribute maps with automatic type conversion.
- AttributeValue
- Base class for attribute values used in events and spans.
- BooleanAttr
- An AttributeValue that holds a bool value.
- BugReportColors
- Color configuration for customizing the bug report UI appearance.
- BugReportText
- Text configuration for customizing the bug report UI labels and messages.
- BugReportTheme
- Complete theme configuration for the bug report UI.
- ClientInfo
- Identifiers required to connect to the Measure backend.
- DoubleAttr
- An AttributeValue that holds a double value.
- IMeasureConfig
- IntAttr
- An AttributeValue that holds an int value.
- Measure
- This singleton class serves as the primary entry point for all SDK functionality.
- MeasureApi
- MeasureConfig
- Configuration class for Measure SDK
- MeasureWidget
- A wrapper widget that enables automatic gesture tracking and screenshot capture.
- MsrAttachment
- Represents a file attachment that can be included with bug reports or events.
- A NavigatorObserver that automatically tracks screen navigation events.
- Span
- Represents a unit of work or operation within a trace.
- SpanBuilder
- Interface for configuring and creating a new Span.
- StringAttr
- An AttributeValue that holds a String value.
Enums
- AttachmentType
- HttpMethod
- Enumeration of HTTP methods supported for tracking network requests.
- SpanStatus
- Specifies the status of the operation for which the span has been created.
Mixins
-
MsrShakeDetectorMixin<
T extends StatefulWidget> - A mixin that enables automatic shake detection for displaying bug reports.