Skip to content

Commit a237c84

Browse files
committed
Merge remote-tracking branch 'origin/main' into docs/web-on-error-capture
# Conflicts: # en/rum/quickstart/app-management.mdx # zh/rum/quickstart/app-management.mdx
2 parents b881693 + b1518a5 commit a237c84

4 files changed

Lines changed: 117 additions & 8 deletions

File tree

‎en/rum/quickstart/app-management.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ After disabling geo-location or IP address collection, the related filter and an
297297
The **Remote Configuration** tab lets you adjust collection and privacy parameters online, without code changes or a new release. When enabled, the configuration on this page overrides SDK initialization settings. When disabled, clients fall back to their SDK initialization settings and data collection continues uninterrupted.
298298

299299
<Note>
300-
- Remote Configuration is currently available for **Browser**, **iOS**, **Android** and **WeChat Mini Program** applications. Other platform types will be enabled as their SDKs ship support.
300+
- Remote Configuration is currently available for **Browser**, **iOS**, **Android**, **Flutter** and **WeChat Mini Program** applications. Other platform types will be enabled as their SDKs ship support.
301301
- On SaaS the feature is rolled out account by account. If the **Remote Configuration** tab is not visible on the application detail page, contact support to enable it. On private deployments it is available by default.
302302
</Note>
303303

@@ -315,7 +315,7 @@ The **Remote Configuration** tab lets you adjust collection and privacy paramete
315315

316316
The two on-error options are independent: **On** delivers `true`, **Off** delivers `false`, and **Use SDK setting** omits the field so the corresponding `init()` option applies (off if unset). Browser applications require Web SDK 0.3.0 or later with `remoteConfigurationEnabled: true` at initialization. Turning off on-error capture does not affect sessions selected by ordinary sampling. See [Web SDK on-error session capture](/en/rum/sdk/web/advanced-config#on-error-session-capture) for scope, billing, and limitations.
317317

318-
iOS, Android, and WeChat Mini Program applications also show the **Remote Configuration** tab, but their SDKs read only the **session sample rate** and **custom configuration keys** (none of the three has Session Replay; the other values are neither delivered nor effective). Every SDK has to opt in with `remoteConfigurationEnabled: true` at initialization (off by default; an application that has not opted in never requests the configuration). On iOS this requires SDK 0.6.0 or later, see [iOS SDK Advanced Configuration](/en/rum/sdk/ios/advanced-config#remote-configuration); on Android it requires SDK 0.7.0 or later, see [Android SDK Advanced Configuration](/en/rum/sdk/android/advanced-config#remote-configuration-adjust-the-sample-rate-from-the-console).
318+
iOS, Android, Flutter, and WeChat Mini Program applications also show the **Remote Configuration** tab, but their SDKs read only the **session sample rate** and **custom configuration keys** (none of them has Session Replay; the other values are neither delivered nor effective). Every SDK has to opt in with `remoteConfigurationEnabled: true` at initialization (off by default; an application that has not opted in never requests the configuration). On iOS this requires SDK 0.6.0 or later, see [iOS SDK Advanced Configuration](/en/rum/sdk/ios/advanced-config#remote-configuration); on Android it requires SDK 0.7.0 or later, see [Android SDK Advanced Configuration](/en/rum/sdk/android/advanced-config#remote-configuration-adjust-the-sample-rate-from-the-console); on Flutter it requires `flashcat_flutter_plugin` 0.2.0 or later, see [Flutter SDK Advanced Configuration](/en/rum/sdk/flutter/advanced-config#remote-configuration).
319319

320320
<Warning>
321321
Custom entries are delivered to clients and may be readable by end users. Never put secrets, access tokens, or personally sensitive information in them.

‎en/rum/sdk/flutter/advanced-config.mdx‎

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Flutter SDK advanced configuration"
3-
description: "Configure sampling, tracking consent, event filtering, distributed tracing, and symbol file upload for the Flutter RUM SDK"
4-
keywords: ["RUM", "Flutter SDK", "advanced configuration", "sampling", "tracking consent", "symbol upload"]
3+
description: "Configure sampling, remote configuration, tracking consent, event filtering, distributed tracing, and symbol file upload for the Flutter RUM SDK"
4+
keywords: ["RUM", "Flutter SDK", "advanced configuration", "sampling", "remote configuration", "tracking consent", "symbol upload"]
55
---
66

77
This page describes the advanced configuration options of the Flutter SDK. All configuration is passed through `DatadogConfiguration` and `DatadogRumConfiguration`.
@@ -16,6 +16,61 @@ DatadogRumConfiguration(
1616
);
1717
```
1818

19+
## Remote configuration
20+
21+
Starting with `flashcat_flutter_plugin` 0.2.0, the session sample rate can be adjusted online from the console under **Application Management > Remote Configuration**, with no code change or new release. The feature is off by default and has to be enabled at initialization:
22+
23+
```dart
24+
DatadogRumConfiguration(
25+
applicationId: '<APPLICATION_ID>',
26+
sessionSamplingRate: 100.0, // Used when the console delivers no rate
27+
remoteConfigurationEnabled: true,
28+
);
29+
```
30+
31+
Once enabled, the configuration is fetched by the native Android / iOS SDK underneath the plugin, and behaves exactly as it does there:
32+
33+
- A rate published in the console applies to the **next new session**; a session already under way is not affected.
34+
- The delivered values are persisted locally, so the first session after a cold start is already drawn under the last delivered rate.
35+
- A failed, timed-out or unreadable response leaves the values in force untouched; they are never cleared. When remote configuration is disabled in the console, the SDK falls back to the `sessionSamplingRate` passed at initialization.
36+
- The Flutter SDK reads only the **session sample rate** and **custom configuration keys**; the other settings have no effect. Read the custom keys with `getRemoteConfig()`, which returns `null` when remote configuration is off or no configuration has arrived yet:
37+
38+
```dart
39+
final custom = await DatadogSdk.instance.rum?.getRemoteConfig();
40+
// Numbers can arrive as int or double depending on the platform, so read them as num
41+
final threshold = (custom?['threshold'] as num?)?.toDouble();
42+
```
43+
44+
To decide sampling by your own business rules, use the `beforeSampling` callback. Each time a new session is about to be drawn it receives the rate that would apply (`sessionSampleRate`) and the console's custom keys (`custom`); return a rate to override it, or `null` to leave it alone. It runs synchronously, so keep it fast; returning a value outside 0–100, throwing, or timing out all keep the native SDK's decision. The callback also runs when remote configuration is off — `sessionSampleRate` is then the local value and `custom` is `null`.
45+
46+
```dart
47+
DatadogRumConfiguration(
48+
applicationId: '<APPLICATION_ID>',
49+
remoteConfigurationEnabled: true,
50+
beforeSampling: (context) {
51+
// For example: collect every session of users listed in the custom key debugUsers,
52+
// and keep the delivered rate for everyone else
53+
final debugUsers = context.custom?['debugUsers'];
54+
if (debugUsers is List && debugUsers.contains(currentUserId)) {
55+
return 100;
56+
}
57+
return null;
58+
},
59+
);
60+
```
61+
62+
To collect the current user regardless of the sample rate (for example while investigating one user's issue), call `DatadogSdk.instance.rum?.setForcedSession()`. If the current session was sampled out it ends immediately and a collected one starts; every session afterwards is collected for the lifetime of the process. The setting cannot be reverted until the app restarts.
63+
64+
<Note>
65+
When Flutter attaches to a native SDK that is already initialized (add-to-app), `remoteConfigurationEnabled` and `beforeSampling` must be set by the native side when it initializes RUM — see [iOS SDK Advanced Configuration](/en/rum/sdk/ios/advanced-config#remote-configuration) and [Android SDK Advanced Configuration](/en/rum/sdk/android/advanced-config#remote-configuration-adjust-the-sample-rate-from-the-console). `getRemoteConfig()` and `setForcedSession()` still work from Dart.
66+
</Note>
67+
68+
<Warning>
69+
Custom configuration keys are delivered to clients and readable by anyone who holds the Client Token. Never put secrets, access tokens, or personally sensitive information in them.
70+
</Warning>
71+
72+
For the console side (settings, publishing and when a version takes effect), see [Application Management · Remote Configuration](/en/rum/quickstart/app-management#remote-configuration).
73+
1974
## Tracking consent
2075

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

‎zh/rum/quickstart/app-management.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ Link 集成会从当前事件上下文中提取变量并替换到 URL 模板中
298298
「远程配置」页签允许你在线调整采集与隐私参数,而无需改代码、重新发版。启用后,本页配置覆盖 SDK 初始化设置;停用后,各端恢复使用 SDK 初始化设置,数据采集不会停止。
299299

300300
<Note>
301-
- 远程配置目前支持 **Browser**、**iOS**、**Android** 与**微信小程序**类型应用,其他平台类型将随各端 SDK 发布逐步开放。
301+
- 远程配置目前支持 **Browser**、**iOS**、**Android**、**Flutter** 与**微信小程序**类型应用,其他平台类型将随各端 SDK 发布逐步开放。
302302
- SaaS 环境下该功能按账号逐步放量。如果应用详情页未显示「远程配置」页签,请联系支持团队开通;私有化部署默认可用。
303303
</Note>
304304

@@ -316,7 +316,7 @@ Link 集成会从当前事件上下文中提取变量并替换到 URL 模板中
316316

317317
两个异常补采开关独立设置:**开**下发 `true`,**关**下发 `false`,**沿用 SDK 设置**不下发该项,由 `init()` 中对应参数决定(未设置时默认关闭)。Browser 应用需使用 Web SDK 0.3.0 及以上,并在初始化时开启 `remoteConfigurationEnabled: true`。关闭补采不影响普通采样已抽中的会话。补采范围、计费与限制见 [Web SDK 异常会话补采](/zh/rum/sdk/web/advanced-config#异常会话补采)。
318318

319-
iOS、Android 与微信小程序应用同样展示「远程配置」页签,但这三端的 SDK 仅读取**会话采样率**与**自定义配置项**两项(三端均无 Session Replay,其余配置不下发也不生效)。各端 SDK 都需要在初始化时开启 `remoteConfigurationEnabled: true`(默认关闭,未开启的应用不会请求配置);iOS 端需要 SDK 0.6.0 及以上,接入方式见 [iOS SDK 高级配置](/zh/rum/sdk/ios/advanced-config);Android 端需要 SDK 0.7.0 及以上,接入方式见 [Android SDK 高级配置](/zh/rum/sdk/android/advanced-config)。
319+
iOS、Android、Flutter 与微信小程序应用同样展示「远程配置」页签,但这几端的 SDK 仅读取**会话采样率**与**自定义配置项**两项(均无 Session Replay,其余配置不下发也不生效)。各端 SDK 都需要在初始化时开启 `remoteConfigurationEnabled: true`(默认关闭,未开启的应用不会请求配置);iOS 端需要 SDK 0.6.0 及以上,接入方式见 [iOS SDK 高级配置](/zh/rum/sdk/ios/advanced-config);Android 端需要 SDK 0.7.0 及以上,接入方式见 [Android SDK 高级配置](/zh/rum/sdk/android/advanced-config);Flutter 端需要 `flashcat_flutter_plugin` 0.2.0 及以上,接入方式见 [Flutter SDK 高级配置](/zh/rum/sdk/flutter/advanced-config)。
320320

321321
<Warning>
322322
自定义配置项会下发到客户端,可能被终端用户读取。请勿填写密钥、访问令牌或个人敏感信息。

‎zh/rum/sdk/flutter/advanced-config.mdx‎

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Flutter SDK 高级配置"
3-
description: "配置 Flutter RUM SDK 的采样率、隐私同意、事件过滤、分布式追踪和符号文件上传"
4-
keywords: ["RUM", "Flutter SDK", "高级配置", "采样", "隐私同意", "符号上传"]
3+
description: "配置 Flutter RUM SDK 的采样率、远程配置、隐私同意、事件过滤、分布式追踪和符号文件上传"
4+
keywords: ["RUM", "Flutter SDK", "高级配置", "采样", "远程配置", "隐私同意", "符号上传"]
55
---
66

77
本文介绍 Flutter SDK 的进阶配置项。所有配置都通过 `DatadogConfiguration` 与 `DatadogRumConfiguration` 传入。
@@ -16,6 +16,60 @@ DatadogRumConfiguration(
1616
);
1717
```
1818

19+
## 远程配置
20+
21+
`flashcat_flutter_plugin` 0.2.0 起,会话采样率可以在控制台 **应用管理 > 远程配置** 页签在线调整,无需改代码、重新发版。该功能默认关闭,需要在初始化时开启:
22+
23+
```dart
24+
DatadogRumConfiguration(
25+
applicationId: '<APPLICATION_ID>',
26+
sessionSamplingRate: 100.0, // 控制台未下发时使用的采样率
27+
remoteConfigurationEnabled: true,
28+
);
29+
```
30+
31+
开启后,配置由插件底层的原生 Android / iOS SDK 拉取,行为与原生端一致:
32+
33+
- 控制台发布的采样率对**下一个新会话**生效,进行中的会话不受影响。
34+
- 下发的值会持久化到本地,冷启动后的第一个会话即按上次下发的采样率抽样。
35+
- 请求失败、超时或响应无法识别时,沿用已生效的值,不会清空;控制台停用远程配置后,恢复使用初始化时的 `sessionSamplingRate`。
36+
- Flutter SDK 只读取**会话采样率**与**自定义配置项**两项,其余配置项不生效。自定义配置项可通过 `getRemoteConfig()` 读取,未开启远程配置或尚未拿到配置时返回 `null`:
37+
38+
```dart
39+
final custom = await DatadogSdk.instance.rum?.getRemoteConfig();
40+
// 数字经平台通道传回时,可能是 int 也可能是 double(取决于平台),统一按 num 读取
41+
final threshold = (custom?['threshold'] as num?)?.toDouble();
42+
```
43+
44+
需要按业务规则决定采样时,可通过 `beforeSampling` 回调干预:每次新建会话时,它收到即将生效的采样率(`sessionSampleRate`)与控制台的自定义配置项(`custom`),返回新的采样率即可覆盖,返回 `null` 表示不干预。回调同步执行,需保持轻量;返回 0–100 以外的值、抛出异常或执行超时,都会沿用原生 SDK 的判定。未开启远程配置时回调同样会执行,此时 `sessionSampleRate` 是本地设置的值,`custom` 为 `null`。
45+
46+
```dart
47+
DatadogRumConfiguration(
48+
applicationId: '<APPLICATION_ID>',
49+
remoteConfigurationEnabled: true,
50+
beforeSampling: (context) {
51+
// 例如:控制台自定义配置项 debugUsers 里的用户全量采集,其余沿用下发的采样率
52+
final debugUsers = context.custom?['debugUsers'];
53+
if (debugUsers is List && debugUsers.contains(currentUserId)) {
54+
return 100;
55+
}
56+
return null;
57+
},
58+
);
59+
```
60+
61+
若要不受采样率限制地采集当前用户(例如排查特定用户的问题),可调用 `DatadogSdk.instance.rum?.setForcedSession()`:若当前会话未被采中,会立即结束并开启一个采集的新会话,此后直到进程结束的会话一律采集;该设置无法撤销,重启 App 后恢复。
62+
63+
<Note>
64+
如果 Flutter 是挂接到一个已经初始化过的原生 SDK 上(add-to-app 场景),`remoteConfigurationEnabled` 与 `beforeSampling` 必须由原生侧在初始化 RUM 时配置,见 [iOS SDK 高级配置](/zh/rum/sdk/ios/advanced-config) 与 [Android SDK 高级配置](/zh/rum/sdk/android/advanced-config);`getRemoteConfig()` 与 `setForcedSession()` 仍可在 Dart 侧调用。
65+
</Note>
66+
67+
<Warning>
68+
自定义配置项会下发到客户端,任何持有 Client Token 的人都能读到。请勿在其中存放密钥、访问令牌或个人敏感信息。
69+
</Warning>
70+
71+
控制台侧的配置项、发布与生效方式见 [应用管理 · 远程配置](/zh/rum/quickstart/app-management#远程配置)。
72+
1973
## 隐私同意
2074

2175
`TrackingConsent` 控制是否采集与上报数据,适配 GDPR 等合规要求:

0 commit comments

Comments
 (0)