Flutter SDK Integration
Add the HEAL SDK to a Flutter app for automatic HTTP API monitoring and tracing.
Key Features#
- HTTP API Monitoring — automatically tracks all HTTP API calls (excluding those in
ignore_urls) - Method Compatibility — supports all HTTP methods (GET, POST, PUT, DELETE, etc.)
- Trace Context Propagation — maintains trace context by sending the
traceparentheader
Flutter Prerequisites#
- Create a
packagesfolder inside the root of your Flutter project and add theheal_sdkfolder into it - Add the required Flutter dependencies (see Step 1 below)
- Network reachability to the HEAL OTEL Collector on TCP port 4318
- Define an allowlist containing only approved, non-sensitive operational attributes required for tracing
Minimum Platform Compatibility#
| Platform | Minimum Version |
|---|---|
| iOS | 13.0 |
| Android | SDK 34 (compile/target) |
Step 1: Add Required Dependencies#
Add the following to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
heal_sdk:
path: ./packages/heal_sdk
Then install the dependencies:
flutter pub get
Step 2: Keep Optional Permissions Disabled by Default#
Tracing outbound network requests does not require background location access. Leave location collection disabled unless an approved use case, the minimum platform permission, a clear user-facing explanation, and any required notice or consent are in place. Do not request background location solely for monitoring.
Step 3: Initialize HEAL SDK#
In your main.dart file, import the SDK and initialize it:
import 'package:heal_sdk/heal_sdk.dart';
void main() {
final Map<String, String> customVariables = {
"environment": "development",
"appRelease": "1.0.0"
};
final heal = HealSDK();
heal.initSDK(
config: {
"heal_receiver_endpoint": 'https://otel.example.com:4318/v1/traces', // Replace with actual HEAL OTEL endpoint
"service_name": 'sample_app', // Replace with your application name/identifier
"ignore_urls": ['v1/traces'], // Optional: exclude specific URLs from tracing
"custom_variables": customVariables, // Custom attributes attached to each trace
"trace_id_key": 'gt-id' // Optional: override default trace ID key
},
enableTracing: true,
enableAnalytics: false, // Keep analytics OFF
);
runApp(const MyApp());
}
Configuration Parameters#
| Parameter | Required | Description |
|---|---|---|
heal_receiver_endpoint |
Yes | HEAL OTEL Collector endpoint URL |
service_name |
Yes | Unique identifier for your Flutter application in HEAL |
ignore_urls |
No | URL patterns to skip from tracing |
custom_variables |
No | Key-value metadata attached to each trace |
trace_id_key |
No | Header name used for trace-ID propagation. The header name is a normal HTTP field name; any trace-ID value it carries must follow the format required by the configured tracing protocol. |
Validation#
After successful integration:
- Launch your Flutter app
- Perform API interactions
- Verify trace data in the HEAL dashboard under the configured
service_name