Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@
"zh/rum/sdk/harmony/data-collection"
]
},
{
"group": "Flutter",
"pages": [
"zh/rum/sdk/flutter/sdk-integration",
"zh/rum/sdk/flutter/advanced-config",
"zh/rum/sdk/flutter/compatible",
"zh/rum/sdk/flutter/data-collection"
]
},
{
"group": "微信小程序",
"pages": [
Expand Down Expand Up @@ -1616,6 +1625,15 @@
"en/rum/sdk/harmony/data-collection"
]
},
{
"group": "Flutter",
"pages": [
"en/rum/sdk/flutter/sdk-integration",
"en/rum/sdk/flutter/advanced-config",
"en/rum/sdk/flutter/compatible",
"en/rum/sdk/flutter/data-collection"
]
},
{
"group": "WeChat Mini Program",
"pages": [
Expand Down
114 changes: 114 additions & 0 deletions en/rum/sdk/flutter/advanced-config.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: "Flutter SDK advanced configuration"
description: "Configure sampling, tracking consent, event filtering, distributed tracing, and symbol file upload for the Flutter RUM SDK"
keywords: ["RUM", "Flutter SDK", "advanced configuration", "sampling", "tracking consent", "symbol upload"]
---

This page describes the advanced configuration options of the Flutter SDK. All configuration is passed through `DatadogConfiguration` and `DatadogRumConfiguration`.

## Sampling rate

```dart
DatadogRumConfiguration(
applicationId: '<APPLICATION_ID>',
sessionSamplingRate: 100.0, // Session sampling rate
traceSampleRate: 20.0, // Trace sampling rate on resources
);
```

## Tracking consent

`TrackingConsent` controls whether data is collected and reported, to meet compliance requirements such as GDPR:

| Value | Behavior |
|------|------|
| `TrackingConsent.granted` | Collect and report |
| `TrackingConsent.notGranted` | Do not collect |
| `TrackingConsent.pending` | Cache first, then decide whether to report or drop after the user grants consent |

```dart
// Pass in during initialization
await DatadogSdk.runApp(configuration, TrackingConsent.pending, () async {
runApp(const MyApp());
});

// Update after the user grants consent
DatadogSdk.instance.setTrackingConsent(TrackingConsent.granted);
```

## Event filtering and masking

Event mappers run before events are reported; return `null` to drop the event, or return it after modification. You can use them to mask sensitive fields, remove noise, or rename views.

```dart
DatadogRumConfiguration(
applicationId: '<APPLICATION_ID>',
viewEventMapper: (event) => event,
actionEventMapper: (event) => event,
resourceEventMapper: (event) {
// For example, remove the query token from the URL
return event;
},
errorEventMapper: (event) => event,
longTaskEventMapper: (event) => event,
);
```

## Distributed tracing

For hosts that match `firstPartyHosts`, the SDK injects the W3C `traceparent` to correlate frontend RUM with backend APM. Tracing requires network collection (`enableHttpTracking()`).

```dart
DatadogConfiguration(
clientToken: '<CLIENT_TOKEN>',
env: 'production',
site: FlashcatSite.cn,
firstPartyHosts: ['api.example.com', 'gateway.example.com'],
rumConfiguration: DatadogRumConfiguration(
applicationId: '<APPLICATION_ID>',
traceSampleRate: 100.0,
),
)..enableHttpTracking();
```

## Custom reporting endpoint

For on-premises deployments, override the default reporting endpoint through `customEndpoint`:

```dart
DatadogRumConfiguration(
applicationId: '<APPLICATION_ID>',
customEndpoint: 'https://your-ingest.example.com',
);
```

## Symbol file upload

To resolve crash and error stacks back to source locations, you need to upload symbol files. A Flutter application may contain both Dart and native frames:

| Frame type | Required files | How to generate |
|----------|----------|----------|
| Dart | Flutter symbols | `flutter build --split-debug-info=<dir> --obfuscate` |
| iOS Native | dSYM | Xcode build output |
| Android Native | mapping files | R8 / ProGuard output |

Use the FlashCat CLI to upload symbol files:

```bash
# Example: upload the symbol files for the corresponding version
flashcat-cli flutter-symbols upload --service <SERVICE_NAME> --version <VERSION> <symbols-dir>
```

<Warning>
The `version` and `service` used at upload time must exactly match the values in the SDK initialization. Otherwise the console can receive crash events but cannot resolve stack frames back to source locations. Make symbol upload part of your release build process.
</Warning>

## Other configuration

| Configuration | Default | Description |
|------|--------|------|
| `nativeCrashReportEnabled` | false | Whether to collect native crashes |
| `detectLongTasks` | true | Whether to collect long tasks |
| `longTaskThreshold` | 0.1s | Long task threshold |
| `trackBackgroundEvents` | false | Whether to collect events while the application is in the background |
| `batchSize` / `uploadFrequency` | — | Upload batch size and frequency, balancing real-time delivery against battery usage |
69 changes: 69 additions & 0 deletions en/rum/sdk/flutter/compatible.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: "Flutter SDK compatibility"
description: "Review the platforms, Flutter versions, companion packages, and current limits supported by the Flutter RUM SDK"
keywords: ["RUM", "Flutter SDK", "compatibility", "Dart", "iOS", "Android"]
---

This page describes the Flutter SDK support scope and current limits so you can determine whether your project meets the requirements before integration.

## Support scope

| Item | Support |
|------|----------|
| SDK version | `flashcat_flutter_plugin` 0.1.0 |
| Target platforms | **iOS and Android** (Flutter Web / Desktop not supported) |
| Flutter / Dart | Flutter ≥ 3.0, Dart ≥ 3.0 |
| iOS | Deployment target ≥ 12.0 |
| Android | `minSdkVersion` ≥ 21 |
| RUM data source | Events always write `source: "flutter"` |
| Implementation | A Flutter plugin wrapping the native iOS / Android SDKs |
| Data upload | `POST /api/v2/rum` |

## Packages and capabilities

| Package | pub name | Description |
|------|------|------|
| RUM / Core / Crash | `flashcat_flutter_plugin` | Initialization, configuration, RUM (view / action / resource / error / session), and native crash collection |
| HTTP tracking | `datadog_tracking_http_client` | Automatically records `dart:io` / `http` requests as resources and injects trace headers (requires `dependency_overrides`, not v1 core) |
| WebView tracking | `flashcat_webview_tracking` | Correlates RUM data inside WebViews |

<Note>
The Dart class names still follow the upstream `Datadog*` naming; only the site enum `FlashcatSite` (`.cn` default / `.staging`) and the package name are rebranded. The `DatadogSdk`, `DatadogConfiguration`, `DatadogRumConfiguration`, `DatadogNavigationObserver`, and other classes in the documentation examples are the actual exported class names.
</Note>

## Supported automatic collection

| Capability | Support | Description |
|------|----------|------|
| Automatic views | Supported | Requires a `DatadogNavigationObserver` on `MaterialApp` |
| Automatic actions | Supported | Requires wrapping the subtree with `RumUserActionDetector`; `trackFrustrations` is enabled by default |
| Automatic resources | Supported (requires companion package) | Through `enableHttpTracking()` from `datadog_tracking_http_client` |
| Unhandled exceptions | Supported | When using `DatadogSdk.runApp`, automatically takes over `FlutterError.onError` / `PlatformDispatcher.onError` |
| Native crashes | Supported | Requires `nativeCrashReportEnabled: true` |
| Distributed tracing | Supported | Injects W3C `traceparent` for hosts that match `firstPartyHosts` |

## Current limits

| Limit | Description |
|------|------|
| Platform scope | iOS / Android only; Flutter Web and Desktop are not supported |
| Logs | v1 does not support log reporting (`DatadogLoggingConfiguration` is a no-op) |
| Session Replay | Not supported in v1 (`datadog_session_replay` is a preview, not in the core scope) |
| Companion package naming | `datadog_tracking_http_client` / `datadog_session_replay` still declare their dependency on `datadog_flutter_plugin: ^3.0.0`, so integrating this fork requires `dependency_overrides` |
| dio / gql / grpc | The corresponding interceptor packages are not yet adapted to this fork in v1 |
| Page performance metrics | `reportFlutterPerformance` is disabled by default; the console performance page is currently hidden for Flutter to avoid showing zero-value empty data |
| pub.dev publication | Official publication is being confirmed; git dependencies are currently recommended |

## Symbolication compatibility

Flutter crash stacks can contain both Dart frames and native (iOS / Android) frames. To resolve stack frames back to source locations, you need to upload the corresponding symbol files:

| Frame type | Required uploaded files |
|----------|--------------|
| Dart | Flutter symbols (`flutter build --split-debug-info` output) |
| iOS Native | dSYM |
| Android Native | mapping files |

<Tip>
Symbol files are uploaded through the FlashCat CLI, and the `version` used at upload time must match the `version` in the SDK initialization. Otherwise the console can receive crash events but cannot resolve the stacks.
</Tip>
79 changes: 79 additions & 0 deletions en/rum/sdk/flutter/data-collection.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: "Flutter SDK data collection"
description: "Learn about the event types, fields, and upload behavior collected by the Flutter RUM SDK"
keywords: ["RUM", "Flutter SDK", "data collection", "view", "action", "resource", "error"]
---

This page describes which data the Flutter SDK collects, how it is uploaded, and how to control the collection scope. All events write `source: "flutter"`.

## Event types

| Event | Trigger | Description |
|------|----------|------|
| view | Route change (`DatadogNavigationObserver`) or manual API | One page visit, recording load time and the number of internal actions / resources / errors |
| action | Automatic recognition by `RumUserActionDetector` or `rum.addAction` | User interaction (tap / scroll / swipe / custom), can correlate frustration signals |
| resource | `enableHttpTracking()` or `DatadogClient` | One network request, recording URL, method, status code, duration, and size |
| error | Automatic (unhandled exceptions / native crashes) or `rum.addError` | Errors and crashes, including type, message, and stack |
| long task | `detectLongTasks` enabled by default | Main-thread blocking that exceeds `longTaskThreshold` (default 0.1s) |

## Automatically collected context

Each event automatically carries the following context (collected by the native layer):

- **Application information**: `service`, `version`, `env`, and `application_id`
- **Device information**: device model, operating system and version, screen size
- **Session information**: `session.id`, sampled by `sessionSamplingRate`
- **Connection information**: network type (when available)
- **User information**: `usr.id` / `usr.name` / `usr.email` set through `setUserInfo`

## Manual instrumentation

In addition to automatic collection, you can manually record events and attributes.

```dart
final rum = DatadogSdk.instance.rum;

// Manually manage views
rum?.startView('checkout', 'Checkout');
rum?.stopView('checkout');

// Manually record an action
rum?.addAction(RumActionType.tap, 'pay_button');

// Manually report an error
rum?.addErrorInfo('payment failed', RumErrorSource.source);

// Attach a global attribute (written to all subsequent events)
rum?.addAttribute('tenant', 'acme');
```

## Sampling and control

| Configuration | Default | Description |
|------|--------|------|
| `sessionSamplingRate` | 100.0 | Session sampling rate (percentage); unsampled sessions produce no RUM data |
| `traceSampleRate` | 100.0 | Sampling rate for distributed tracing on resources |
| `telemetrySampleRate` | 20.0 | Sampling rate for the SDK's own telemetry |
| `detectLongTasks` | true | Whether to collect long tasks |
| `trackFrustrations` | true | Whether to generate frustration signals from user actions |
| `trackAnonymousUser` | true | Whether to generate an anonymous ID for signed-out users |

## Data masking

Event mappers let you modify or drop data before events are reported, for masking or filtering out noise. See <a href="/en/rum/sdk/flutter/advanced-config">Advanced configuration</a>.

```dart
DatadogRumConfiguration(
applicationId: '<APPLICATION_ID>',
resourceEventMapper: (event) {
// Return null to drop the event, or return it after modification
return event;
},
);
```

## Upload behavior

- The SDK batches and caches at the native layer, uploading in batches by `batchSize` and `uploadFrequency`
- When the network is unavailable, events are persisted locally and retried after recovery
- The upload endpoint defaults to the site's endpoint (`FlashcatSite.cn` → `browser.flashcat.cloud`); on-premises deployments can override it through `customEndpoint`
Loading