Skip to content

Commit 6af2016

Browse files
authored
Merge pull request #366 from flashcatcloud/docs/rum-ios-remote-config-0.6.0
docs(rum): document remote configuration for iOS and bump the SDK version to 0.6.0
2 parents 5aed0a9 + 3ec31da commit 6af2016

6 files changed

Lines changed: 120 additions & 18 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The console provides detailed integration guides for each platform:
7474

7575
- **JavaScript (Web)**: After configuring parameters like service name, preview the `flashcatRum.init()` initialization code in real-time
7676
- **Android**: Shows complete integration steps including adding Gradle dependencies (`cloud.flashcat:dd-sdk-android-core` and `cloud.flashcat:dd-sdk-android-rum`), initializing the SDK in `Application.onCreate()` with RUM enabled, and optional WebView tracking integration
77-
- **iOS**: Shows complete integration steps including adding Swift Package Manager dependency (`fc-sdk-ios`, from version 0.3.0), initializing the SDK in `AppDelegate.didFinishLaunchingWithOptions` with RUM enabled, and optional WebView tracking integration
77+
- **iOS**: Shows complete integration steps including adding Swift Package Manager dependency (`fc-sdk-ios`, from version 0.6.0), initializing the SDK in `AppDelegate.didFinishLaunchingWithOptions` with RUM enabled, and optional WebView tracking integration
7878
- **Flutter**: The Flutter SDK wraps the Android/iOS native SDKs, so one integration monitors both platforms. See [Flutter SDK Integration](/en/rum/sdk/flutter/sdk-integration)
7979
- **WeChat Mini Program**: Fill in `env`, `service`, `version`, and `sessionSampleRate` in the form, and the `flashcatRum.init()` snippet built on `@flashcatcloud/miniprogram-rum` is generated and previewed in real time (see "WeChat Mini Program SDK Configuration Assistant" below)
8080
- **Electron**: Provides a step-by-step integration guide — install `@flashcatcloud/electron-sdk` in the main process and complete initialization inside `app.whenReady()` (this must finish before any window is created; with the wrong ordering the SDK reports no error but collects no data). To capture page views, user actions, network requests, and JS errors inside your windows, optionally integrate `@flashcatcloud/browser-rum` in the renderer process, whose data is handed to the main process over an IPC bridge for unified reporting. When bundling the main process with Vite / webpack / esbuild, you can also add the corresponding plugin to keep the SDK's runtime dependencies. See [Electron SDK Integration](/en/rum/sdk/electron/sdk-integration)
@@ -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** 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** 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

@@ -311,7 +311,7 @@ The **Remote Configuration** tab lets you adjust collection and privacy paramete
311311
| **Replay privacy level** | `mask` / `mask-user-input` / `allow` | Default masking of page content in Session Replay: `mask` obscures text and hides input values; `mask-user-input` keeps page text and hides only what users typed; `allow` records the page as it is. Loosening the level starts collecting content that was not collected before, and replays already uploaded cannot be retroactively masked. The console asks you to confirm again before publishing |
312312
| **Custom configuration keys** | Key–value pairs typed as string / number / boolean / JSON | Delivered to clients together with the remote configuration and read by your application code; the platform does not interpret them. Up to 5 keys; each key name is at most 64 bytes (counted in UTF-8, not characters), each value at most 4 KB and nesting at most 3 levels (objects and arrays each count one level), and all custom entries together at most 16 KB |
313313

314-
WeChat Mini Program applications also show the **Remote Configuration** tab, but the mini program SDK reads only the **session sample rate** and **custom configuration keys** (mini programs have no Session Replay; the other values are neither delivered nor effective).
314+
iOS and WeChat Mini Program applications also show the **Remote Configuration** tab, but their SDKs read only the **session sample rate** and **custom configuration keys** (neither platform 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).
315315

316316
<Warning>
317317
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/ios/advanced-config.mdx‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,57 @@ RUM.enable(
247247
Sampled-out sessions will not collect any page views or related telemetry data.
248248
</Warning>
249249

250+
## Remote Configuration
251+
252+
Starting with SDK 0.6.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:
253+
254+
```swift
255+
import DatadogRUM
256+
257+
RUM.enable(
258+
with: RUM.Configuration(
259+
applicationID: "<RUM_APPLICATION_ID>",
260+
sessionSampleRate: 100, // used until the console publishes a rate
261+
remoteConfigurationEnabled: true
262+
)
263+
)
264+
```
265+
266+
```objective-c
267+
@import DatadogObjc;
268+
269+
DDRUMConfiguration *configuration = [[DDRUMConfiguration alloc] initWithApplicationID:@"<RUM_APPLICATION_ID>"];
270+
configuration.remoteConfigurationEnabled = YES;
271+
272+
[RUM enableWith:configuration];
273+
```
274+
275+
Once enabled:
276+
277+
- The SDK requests the configuration from the RUM intake when `RUM.enable()` is called, and again each time a new session is created. A rate published in the console applies to the **next new session**; a session already under way is not affected.
278+
- The delivered values are persisted locally, so the first session after a cold start is already drawn under the last delivered rate.
279+
- 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 `sessionSampleRate` passed at initialization.
280+
- The iOS SDK reads only the **session sample rate** and **custom configuration keys**; the other settings have no effect. Read the custom keys with `RUMMonitor.shared().getRemoteConfig()`, which returns `nil` when remote configuration is off or the console set none.
281+
282+
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 `nil` to leave it alone. It runs synchronously inside session creation, so keep it fast and non-blocking; a value outside 0–100 is ignored.
283+
284+
```swift
285+
RUM.enable(
286+
with: RUM.Configuration(
287+
applicationID: "<RUM_APPLICATION_ID>",
288+
remoteConfigurationEnabled: true,
289+
beforeSampling: { context in
290+
// e.g. collect every session of internal accounts, keep the console's rate for the rest
291+
isInternalUser ? 100 : nil
292+
}
293+
)
294+
)
295+
```
296+
297+
To collect the current user regardless of the sample rate (for example while investigating one user's issue), call `RUMMonitor.shared().setForcedSession()`: every session drawn afterwards is collected for the lifetime of the process, while a session already under way is not re-decided.
298+
299+
For the console side (settings, publishing and when a version takes effect), see [Application Management · Remote Configuration](/en/rum/quickstart/app-management#remote-configuration).
300+
250301
## App Hang Detection
251302

252303
An App Hang is a period during which the main thread is blocked and the UI cannot respond to user input. On iOS it is the only data source behind the **Unresponsive Time Rate** metric in the analytics dashboard.

‎en/rum/sdk/ios/sdk-integration.mdx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Flashduty iOS SDK supports Swift Package Manager and CocoaPods:
3333
```
3434

3535
3. Select version rule:
36-
- **Recommended**: Select **Up to Next Major Version** and enter the latest version number (e.g., `0.3.0`)
36+
- **Recommended**: Select **Up to Next Major Version** and enter the latest version number (e.g., `0.6.0`)
3737
- This allows bug fixes and minor updates while maintaining compatibility
3838

3939
4. Click **Add Package** and wait for Xcode to download dependencies
@@ -54,13 +54,13 @@ Flashduty iOS SDK supports Swift Package Manager and CocoaPods:
5454
Add the following dependencies to your `Podfile`:
5555

5656
```ruby Podfile
57-
pod 'FlashcatCore', '~> 0.3.0' # Core SDK (required)
58-
pod 'FlashcatRUM', '~> 0.3.0' # RUM feature (required)
59-
pod 'FlashcatTrace', '~> 0.3.0' # Trace feature (required for Trace feature or manual spans)
57+
pod 'FlashcatCore', '~> 0.6.0' # Core SDK (required)
58+
pod 'FlashcatRUM', '~> 0.6.0' # RUM feature (required)
59+
pod 'FlashcatTrace', '~> 0.6.0' # Trace feature (required for Trace feature or manual spans)
6060

6161
# Optional modules
62-
pod 'FlashcatWebViewTracking', '~> 0.3.0' # WebView tracking
63-
pod 'FlashcatCrashReporting', '~> 0.3.0' # Crash reporting
62+
pod 'FlashcatWebViewTracking', '~> 0.6.0' # WebView tracking
63+
pod 'FlashcatCrashReporting', '~> 0.6.0' # Crash reporting
6464
```
6565

6666
Then run `pod install` and open your project using the `.xcworkspace` file.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ RUM 应用是承载前端性能监控数据的容器,用于采集、存储和
7575

7676
- **JavaScript(Web)**:配置服务名等参数后,实时预览 `flashcatRum.init()` 初始化代码
7777
- **Android**:展示完整的集成步骤,包括添加 Gradle 依赖(`cloud.flashcat:dd-sdk-android-core` 和 `cloud.flashcat:dd-sdk-android-rum`)、在 `Application.onCreate()` 中初始化 SDK 并启用 RUM,以及可选的 WebView 追踪集成
78-
- **iOS**:展示完整的集成步骤,包括添加 Swift Package Manager 依赖(`fc-sdk-ios`,版本 0.3.0 起)、在 `AppDelegate.didFinishLaunchingWithOptions` 中初始化 SDK 并启用 RUM,以及可选的 WebView 追踪集成
78+
- **iOS**:展示完整的集成步骤,包括添加 Swift Package Manager 依赖(`fc-sdk-ios`,版本 0.6.0 起)、在 `AppDelegate.didFinishLaunchingWithOptions` 中初始化 SDK 并启用 RUM,以及可选的 WebView 追踪集成
7979
- **Flutter**:Flutter SDK 封装了 Android/iOS 原生 SDK,一次集成即可同时监控两端,详见 [Flutter SDK 接入](/zh/rum/sdk/flutter/sdk-integration)
8080
- **微信小程序**:通过表单填写 `env`、`service`、`version`、`sessionSampleRate` 后,实时预览基于 `@flashcatcloud/miniprogram-rum` 的 `flashcatRum.init()` 初始化代码(参见下方「微信小程序 SDK 配置助手」)
8181
- **Electron**:提供分步接入向导——主进程安装 `@flashcatcloud/electron-sdk` 并在 `app.whenReady()` 中完成初始化(必须在创建任何窗口之前,顺序不对时 SDK 不报错但采集不到数据);如需采集窗口内的页面浏览、用户操作、网络请求与 JS 错误,渲染进程可选接入 `@flashcatcloud/browser-rum`,数据经 IPC 桥交由主进程统一上报;使用 Vite / webpack / esbuild 打包主进程时,还可加入对应插件以保留 SDK 的运行时依赖。详见 [Electron SDK 接入](/zh/rum/sdk/electron/sdk-integration)
@@ -298,7 +298,7 @@ Link 集成会从当前事件上下文中提取变量并替换到 URL 模板中
298298
「远程配置」页签允许你在线调整采集与隐私参数,而无需改代码、重新发版。启用后,本页配置覆盖 SDK 初始化设置;停用后,各端恢复使用 SDK 初始化设置,数据采集不会停止。
299299

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

@@ -312,7 +312,7 @@ Link 集成会从当前事件上下文中提取变量并替换到 URL 模板中
312312
| **回放脱敏级别** | `mask` / `mask-user-input` / `allow` | 会话回放对页面内容的默认遮蔽程度:`mask` 遮蔽文本并隐藏输入值;`mask-user-input` 保留页面文本、仅隐藏用户输入;`allow` 按原样录制。放宽级别会开始录制此前未采集的内容,且已上传的回放无法事后补充脱敏,发布前系统会再次确认 |
313313
| **自定义配置项** | 键值对,类型支持字符串 / 数字 / 布尔值 / JSON | 随远程配置下发到客户端、由应用代码读取,平台不解析其内容。最多 5 个;键名最长 64 字节(按 UTF-8 计,非字符数),单个值最大 4 KB,JSON 值最多嵌套 3 层(对象、数组各计一层),全部自定义项合计最大 16 KB |
314314

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

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

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,57 @@ configuration.sessionSampleRate = 90;
727727
728728
被采样的会话将不收集任何视图及其相关遥测数据。
729729
730+
## 远程配置
731+
732+
SDK 0.6.0 起,会话采样率可以在控制台 **应用管理 > 远程配置** 页签在线调整,无需改代码、重新发版。该功能默认关闭,需要在初始化时开启:
733+
734+
```swift
735+
import DatadogRUM
736+
737+
RUM.enable(
738+
with: RUM.Configuration(
739+
applicationID: "<RUM_APPLICATION_ID>",
740+
sessionSampleRate: 100, // 控制台未下发时使用的采样率
741+
remoteConfigurationEnabled: true
742+
)
743+
)
744+
```
745+
746+
```objective-c
747+
@import DatadogObjc;
748+
749+
DDRUMConfiguration *configuration = [[DDRUMConfiguration alloc] initWithApplicationID:@"<RUM_APPLICATION_ID>"];
750+
configuration.remoteConfigurationEnabled = YES;
751+
752+
[RUM enableWith:configuration];
753+
```
754+
755+
开启后的行为:
756+
757+
- SDK 在 `RUM.enable()` 时向 RUM 接入端点请求一次配置,之后每次新建会话时再请求。控制台发布的采样率对**下一个新会话**生效,进行中的会话不受影响。
758+
- 下发的值会持久化到本地,冷启动后的第一个会话即按上次下发的采样率抽样。
759+
- 请求失败、超时或响应无法识别时,沿用已生效的值,不会清空;控制台停用远程配置后,恢复使用初始化时的 `sessionSampleRate`。
760+
- iOS SDK 只读取**会话采样率**与**自定义配置项**两项,其余配置项不生效。自定义配置项可通过 `RUMMonitor.shared().getRemoteConfig()` 读取,未开启远程配置或控制台未设置时返回 `nil`。
761+
762+
需要按业务规则决定采样时,可通过 `beforeSampling` 回调干预:每次新建会话时,它收到即将生效的采样率(`sessionSampleRate`)与控制台的自定义配置项(`custom`),返回新的采样率即可覆盖,返回 `nil` 表示不干预。回调在会话创建过程中同步执行,需保持轻量、不可阻塞;返回 0–100 以外的值会被忽略。
763+
764+
```swift
765+
RUM.enable(
766+
with: RUM.Configuration(
767+
applicationID: "<RUM_APPLICATION_ID>",
768+
remoteConfigurationEnabled: true,
769+
beforeSampling: { context in
770+
// 例如:内部账号全量采集,其余沿用控制台下发的采样率
771+
isInternalUser ? 100 : nil
772+
}
773+
)
774+
)
775+
```
776+
777+
若要不受采样率限制地采集当前用户(例如排查特定用户的问题),可调用 `RUMMonitor.shared().setForcedSession()`:此后新建的会话一律采集,直到进程结束;已在进行中的会话不会被重新判定。
778+
779+
控制台侧的配置项、发布与生效方式见 [应用管理 · 远程配置](/zh/rum/quickstart/app-management)。
780+
730781
## 集成 RUM 与分布式追踪
731782

732783
集成 RUM 与分布式追踪,可让您将 iOS 应用程序的请求与其对应的后端跟踪关联起来。这种组合让您能够一目了然地查看完整的前端和后端数据。

‎zh/rum/sdk/ios/sdk-integration.mdx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Flashduty iOS SDK 支持 Swift Package Manager 和 CocoaPods 两种安装方式
3333
```
3434

3535
3. 选择版本规则:
36-
- **推荐**:选择 **Up to Next Major Version**,并输入当前最新版本号(如 `0.3.0`)
36+
- **推荐**:选择 **Up to Next Major Version**,并输入当前最新版本号(如 `0.6.0`)
3737
- 这样可以在保持兼容性的同时获取 bug 修复和小版本更新
3838

3939
4. 点击 **Add Package**,等待 Xcode 下载依赖
@@ -54,13 +54,13 @@ Flashduty iOS SDK 支持 Swift Package Manager 和 CocoaPods 两种安装方式
5454
在项目的 `Podfile` 中添加以下依赖:
5555

5656
```ruby Podfile
57-
pod 'FlashcatCore', '~> 0.3.0' # 核心 SDK(必选)
58-
pod 'FlashcatRUM', '~> 0.3.0' # RUM 功能(必选)
59-
pod 'FlashcatTrace', '~> 0.3.0' # Trace 功能(启用 Trace feature 或手动 span 时需要)
57+
pod 'FlashcatCore', '~> 0.6.0' # 核心 SDK(必选)
58+
pod 'FlashcatRUM', '~> 0.6.0' # RUM 功能(必选)
59+
pod 'FlashcatTrace', '~> 0.6.0' # Trace 功能(启用 Trace feature 或手动 span 时需要)
6060

6161
# 可选模块
62-
pod 'FlashcatWebViewTracking', '~> 0.3.0' # WebView 追踪
63-
pod 'FlashcatCrashReporting', '~> 0.3.0' # 崩溃报告
62+
pod 'FlashcatWebViewTracking', '~> 0.6.0' # WebView 追踪
63+
pod 'FlashcatCrashReporting', '~> 0.6.0' # 崩溃报告
6464
```
6565

6666
然后执行 `pod install`,并使用 `.xcworkspace` 文件打开项目。

0 commit comments

Comments
 (0)