Skip to content

Commit 91a0c73

Browse files
authored
Merge pull request #140 from flashcatcloud/docs/miniprogram-sdk-review-fixes
docs: fix WeChat miniprogram SDK docs (package name, tracing sampleRate, domain allowlist, error sources)
2 parents 8705eca + 31b53fa commit 91a0c73

10 files changed

Lines changed: 44 additions & 36 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The console provides detailed integration guides for each platform:
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
7777
- **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
78-
- **WeChat Mini Program**: Fill in `env`, `service`, `version`, and `sessionSampleRate` in the form, and the `flashcatRum.init()` snippet built on `@flashcatcloud/fc-sdk-miniprogram` is generated and previewed in real time (see "WeChat Mini Program SDK Configuration Assistant" below)
78+
- **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)
7979

8080
Each platform's SDK configuration page automatically fills in the current application's `applicationId` and `clientToken`, so you can copy the code directly into your project.
8181

@@ -141,15 +141,15 @@ No save action is needed — the preview snippet updates as you type. `applicati
141141
Install the SDK in your Mini Program project and run the npm build through WeChat DevTools:
142142

143143
```bash
144-
npm install @flashcatcloud/fc-sdk-miniprogram
144+
npm install @flashcatcloud/miniprogram-rum
145145
```
146146
</Step>
147147

148148
<Step title="Copy the Initialization Snippet">
149149
Use the copy button at the top-right of the right-hand code block, then paste the generated snippet into your Mini Program's `app.js`:
150150

151151
```typescript
152-
import { flashcatRum } from '@flashcatcloud/fc-sdk-miniprogram';
152+
import { flashcatRum } from '@flashcatcloud/miniprogram-rum';
153153

154154
flashcatRum.init({
155155
applicationId: "<APPLICATION_ID>",

‎en/rum/sdk/wechat-miniprogram/advanced-config.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ flashcatRum.init({
5050
clientToken: "<YOUR_CLIENT_TOKEN>",
5151
tracing: {
5252
enabled: true,
53-
sampleRate: 1,
53+
sampleRate: 100,
5454
headerName: "traceparent"
5555
}
5656
});
@@ -59,7 +59,7 @@ flashcatRum.init({
5959
| Field | Type | Default | Description |
6060
|-------|------|---------|-------------|
6161
| `tracing.enabled` | boolean | `false` | Controls whether request trace headers are injected |
62-
| `tracing.sampleRate` | number | `1` | Request tracing sample rate. `1` means 100%, and `0.5` means approximately 50% |
62+
| `tracing.sampleRate` | number | `100` | Request tracing sample rate, from 0 to 100. `100` means all requests are sampled, and `50` means approximately 50% |
6363
| `tracing.headerName` | string | `traceparent` | Header name injected into requests |
6464
| `tracing.rootTraceContext` | object | - | Optional root Trace Context. When configured, the SDK creates child spans from this context |
6565

‎en/rum/sdk/wechat-miniprogram/compatible.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The WeChat Mini Program RUM SDK runs in the WeChat Mini Program environment and
1313
| Mini Program base library | `2.10.0+` | SDK initialization registers `wx.onUnhandledRejection`; runtimes below this version are not recommended |
1414
| Recommended base library | `2.12.0+` | Enables complete page rendering, startup, script execution, and setData update timing collection |
1515
| WeChat DevTools | Recent stable version | Must support npm dependency installation and **Tools > Build npm** |
16-
| npm package | `@flashcatcloud/fc-sdk-miniprogram` | Includes core functionality, platform adapter, and the RUM entry point |
16+
| npm package | `@flashcatcloud/miniprogram-rum` | Includes core functionality, platform adapter, and the RUM entry point |
1717

1818
<Warning>
1919
If your Mini Program allows users to run on base library versions below `2.10.0`, SDK initialization may fail to register unhandled Promise rejection listeners. We recommend setting a minimum base library version in the Mini Program admin console, or evaluating low-version user coverage before integration.
@@ -49,7 +49,7 @@ If your Mini Program allows users to run on base library versions below `2.10.0`
4949

5050
When integrating through npm, build npm dependencies in WeChat DevTools:
5151

52-
1. Run `npm install @flashcatcloud/fc-sdk-miniprogram` in the Mini Program project root
52+
1. Run `npm install @flashcatcloud/miniprogram-rum` in the Mini Program project root
5353
2. Open the project in WeChat DevTools
5454
3. Run **Tools > Build npm**
5555
4. Confirm that the generated `miniprogram_npm` can be referenced by Mini Program code

‎en/rum/sdk/wechat-miniprogram/data-collection.mdx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ After initialization, the WeChat Mini Program RUM SDK automatically collects use
1313
| Page views | Enabled | `Page` lifecycle hooks: `onLoad`, `onShow`, `onReady`, `onHide`, `onUnload` | `view` |
1414
| User actions | Enabled | Page methods that receive an event object with a `type` field | `action` |
1515
| Network requests | Enabled | `wx.request`, `wx.uploadFile`, `wx.downloadFile` | `resource` |
16-
| App errors | Enabled | `wx.onError`, `wx.onUnhandledRejection` | `error` |
16+
| App errors | Enabled | `wx.onError`, `wx.onUnhandledRejection`, `wx.onPageNotFound`, `wx.onLazyLoadError`, and failed network requests | `error` |
1717
| Performance metrics | Enabled | `wx.getPerformance` and page `setUpdatePerformanceListener` | `view` |
1818
| Custom events | Manual | `addCustomEvent()` | `custom` |
1919

@@ -98,12 +98,15 @@ Network requests create resource events:
9898

9999
## Error Collection
100100

101-
When `trackErrors` is enabled, the SDK subscribes to Mini Program app errors and unhandled Promise rejections.
101+
When `trackErrors` is enabled, the SDK subscribes to Mini Program app errors, unhandled Promise rejections, page-not-found events, and subpackage lazy-load failures. Failed network requests are also recorded as errors.
102102

103103
| Source | SDK source | Description |
104104
|--------|------------|-------------|
105105
| `wx.onError` | `app` | Mini Program runtime errors |
106106
| `wx.onUnhandledRejection` | `promise` | Unhandled Promise rejections |
107+
| `wx.onPageNotFound` | `page-not-found` | The target page does not exist |
108+
| `wx.onLazyLoadError` | `lazy-load` | Subpackage lazy-load failures |
109+
| Failed network requests | `network` | For a failed request, the SDK creates an error event in addition to the resource event |
107110
| `addError()` | `custom` | Business errors that you report manually |
108111

109112
Error events include the error message, optional stack, and source. When manually reporting an error, pass `error.stack` as the third argument to `addError()`.
@@ -135,7 +138,7 @@ Calling `addCustomEvent(name, context?)` creates a custom event. Use it to recor
135138
| `event.context` | Custom event context object |
136139

137140
```javascript pages/order/detail.js
138-
import { flashcatRum } from "@flashcatcloud/fc-sdk-miniprogram";
141+
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";
139142

140143
flashcatRum.addCustomEvent("order_status_changed", {
141144
orderId: "order-123",
@@ -157,7 +160,7 @@ The SDK associates non-view events with the page and session active at the event
157160
Disable collection types you do not need during initialization:
158161

159162
```javascript app.js
160-
import { flashcatRum } from "@flashcatcloud/fc-sdk-miniprogram";
163+
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";
161164

162165
flashcatRum.init({
163166
applicationId: "<YOUR_APPLICATION_ID>",

‎en/rum/sdk/wechat-miniprogram/sdk-integration.mdx‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
---
22
title: "SDK Integration Guide"
33
description: "Integrate the RUM SDK into a WeChat Mini Program to collect page, action, request, error, and performance data"
4-
keywords: ["RUM", "WeChat Mini Program SDK", "Mini Program monitoring", "user monitoring", "@flashcatcloud/fc-sdk-miniprogram"]
4+
keywords: ["RUM", "WeChat Mini Program SDK", "Mini Program monitoring", "user monitoring", "@flashcatcloud/miniprogram-rum"]
55
---
66

7-
The WeChat Mini Program RUM SDK provides the `flashcatRum` instance through `@flashcatcloud/fc-sdk-miniprogram`. After initialization, the SDK automatically collects page lifecycle events, user actions, network requests, app errors, and performance metrics, then reports them to Flashduty RUM.
7+
The WeChat Mini Program RUM SDK provides the `flashcatRum` instance through `@flashcatcloud/miniprogram-rum`. After initialization, the SDK automatically collects page lifecycle events, user actions, network requests, app errors, and performance metrics, then reports them to Flashduty RUM.
88

99
## Prerequisites
1010

1111
Before integrating the SDK, complete these steps:
1212

1313
- Create or select a RUM application in the Flashduty console, then obtain the **Application ID** and **Client Token**
1414
- Confirm that your Mini Program can access the RUM intake URL. The default URL is `https://browser.flashcat.cloud/api/v2/rum`; configure `proxy` if your network policy requires forwarding
15+
- Configure the request domain allowlist in the WeChat Official Platform: go to **Development > Development Management > Development Settings > Server Domain** and add `https://browser.flashcat.cloud` (or your proxy domain) to the **request legal domains**. Without this, WeChat blocks all reporting requests on real devices; during development, you can temporarily check the "Do not verify legal domains" option in WeChat DevTools
1516
- If you use WeChat DevTools, build npm so `miniprogram_npm` can reference the SDK package
1617

1718
## Install the SDK
1819

1920
Install the RUM SDK in the Mini Program project root:
2021

2122
```bash
22-
npm install @flashcatcloud/fc-sdk-miniprogram
23+
npm install @flashcatcloud/miniprogram-rum
2324
```
2425

2526
After installation, run **Tools > Build npm** in WeChat DevTools.
@@ -29,7 +30,7 @@ After installation, run **Tools > Build npm** in WeChat DevTools.
2930
Initialize the SDK as early as possible in the Mini Program entry file. The SDK wraps page lifecycle hooks, request methods, and app error listeners during initialization, so initializing it in `app.js` is recommended.
3031

3132
```javascript app.js
32-
import { flashcatRum } from "@flashcatcloud/fc-sdk-miniprogram";
33+
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";
3334

3435
flashcatRum.init({
3536
applicationId: "<YOUR_APPLICATION_ID>",
@@ -112,7 +113,7 @@ The following toggles control automatic collection. They are all enabled by defa
112113
| `trackPages` | boolean | `true` | Collects page lifecycle data and creates view events |
113114
| `trackActions` | boolean | `true` | Collects user actions from page event handlers and creates action events |
114115
| `trackRequests` | boolean | `true` | Collects `wx.request`, `wx.uploadFile`, and `wx.downloadFile` calls and creates resource events |
115-
| `trackErrors` | boolean | `true` | Collects errors from `wx.onError` and `wx.onUnhandledRejection` |
116+
| `trackErrors` | boolean | `true` | Collects errors from `wx.onError`, `wx.onUnhandledRejection`, page-not-found events, subpackage lazy-load failures, and failed network requests |
116117
| `trackPerformance` | boolean | `true` | Collects page rendering, startup, and script execution metrics through `wx.getPerformance` |
117118

118119
## Use User Information and Global Context
@@ -141,7 +142,7 @@ flashcatRum.setGlobalContext({
141142
In addition to automatic collection, you can add business events, errors, actions, and custom timings manually.
142143

143144
```javascript pages/order/detail.js
144-
import { flashcatRum } from "@flashcatcloud/fc-sdk-miniprogram";
145+
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";
145146

146147
Page({
147148
onPayTap() {
@@ -167,7 +168,7 @@ Page({
167168
| `addError(message, source?, stack?)` | Manually reports an error event. The public API uses `custom` as the source |
168169
| `addTiming(name, time?)` | Records a custom timing on the current page view. Invalid characters in the name are replaced with `_` |
169170
| `addCustomEvent(name, context?)` | Reports a custom event with optional context |
170-
| `startPage(name)` | Manually starts a page view, useful for overriding the automatic page name or recording a virtual page |
171+
| `startPage(name?)` | Manually starts a page view, useful for overriding the automatic page name or recording a virtual page |
171172
| `stopSession()` | Clears the current session. The next event creates a new session |
172173
| `getInitConfiguration()` | Returns the latest initialization configuration |
173174

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ RUM 应用是承载前端性能监控数据的容器,用于采集、存储和
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 追踪集成
7878
- **iOS**:展示完整的集成步骤,包括添加 Swift Package Manager 依赖(`fc-sdk-ios`,版本 0.3.0 起)、在 `AppDelegate.didFinishLaunchingWithOptions` 中初始化 SDK 并启用 RUM,以及可选的 WebView 追踪集成
79-
- **微信小程序**:通过表单填写 `env`、`service`、`version`、`sessionSampleRate` 后,实时预览基于 `@flashcatcloud/fc-sdk-miniprogram` 的 `flashcatRum.init()` 初始化代码(参见下方「微信小程序 SDK 配置助手」)
79+
- **微信小程序**:通过表单填写 `env`、`service`、`version`、`sessionSampleRate` 后,实时预览基于 `@flashcatcloud/miniprogram-rum` 的 `flashcatRum.init()` 初始化代码(参见下方「微信小程序 SDK 配置助手」)
8080

8181
每个平台的 SDK 配置页面都会自动填入当前应用的 `applicationId` 和 `clientToken`,您可以直接复制代码到项目中使用。
8282

@@ -142,15 +142,15 @@ flashcatRum.init({
142142
在小程序项目中执行以下命令安装 SDK,并通过微信开发者工具完成 npm 构建:
143143

144144
```bash
145-
npm install @flashcatcloud/fc-sdk-miniprogram
145+
npm install @flashcatcloud/miniprogram-rum
146146
```
147147
</Step>
148148

149149
<Step title="复制初始化代码">
150150
点击右侧代码块右上角的复制按钮,将生成的初始化代码粘贴到小程序的 `app.js`:
151151

152152
```typescript
153-
import { flashcatRum } from '@flashcatcloud/fc-sdk-miniprogram';
153+
import { flashcatRum } from '@flashcatcloud/miniprogram-rum';
154154

155155
flashcatRum.init({
156156
applicationId: "<APPLICATION_ID>",

‎zh/rum/sdk/wechat-miniprogram/advanced-config.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ flashcatRum.init({
5050
clientToken: "<YOUR_CLIENT_TOKEN>",
5151
tracing: {
5252
enabled: true,
53-
sampleRate: 1,
53+
sampleRate: 100,
5454
headerName: "traceparent"
5555
}
5656
});
@@ -59,7 +59,7 @@ flashcatRum.init({
5959
| 字段 | 类型 | 默认值 | 说明 |
6060
|------|------|--------|------|
6161
| `tracing.enabled` | boolean | `false` | 是否启用请求追踪头注入 |
62-
| `tracing.sampleRate` | number | `1` | 请求追踪采样率。`1` 表示 100% 采样,`0.5` 表示约 50% 采样 |
62+
| `tracing.sampleRate` | number | `100` | 请求追踪采样率,取值范围 0-100。`100` 表示全量采样,`50` 表示约 50% 采样 |
6363
| `tracing.headerName` | string | `traceparent` | 注入到请求 header 中的字段名 |
6464
| `tracing.rootTraceContext` | object | - | 可选根 Trace Context。配置后,SDK 会基于该上下文创建子 span |
6565

‎zh/rum/sdk/wechat-miniprogram/compatible.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ keywords: ["RUM", "微信小程序", "兼容性", "基础库"]
1313
| 小程序基础库 | `2.10.0+` | SDK 初始化会注册 `wx.onUnhandledRejection`,低于该版本的运行时不建议接入 |
1414
| 推荐基础库 | `2.12.0+` | 可完整采集页面渲染、启动、脚本执行和 setData 更新耗时 |
1515
| 微信开发者工具 | 使用近期稳定版 | 需要支持 npm 安装依赖并执行 **工具 > 构建 npm** |
16-
| npm 包 | `@flashcatcloud/fc-sdk-miniprogram` | 包含核心能力、平台适配层和 RUM 入口 |
16+
| npm 包 | `@flashcatcloud/miniprogram-rum` | 包含核心能力、平台适配层和 RUM 入口 |
1717

1818
<Warning>
1919
如果小程序允许用户在低于 `2.10.0` 的基础库中运行,SDK 初始化阶段可能无法注册未处理 Promise 拒绝监听。建议在小程序管理后台设置最低基础库版本,或在接入前根据业务覆盖范围评估低版本用户占比。
@@ -49,7 +49,7 @@ keywords: ["RUM", "微信小程序", "兼容性", "基础库"]
4949

5050
接入 npm 包时,需要在微信开发者工具中完成 npm 构建:
5151

52-
1. 在小程序项目根目录执行 `npm install @flashcatcloud/fc-sdk-miniprogram`
52+
1. 在小程序项目根目录执行 `npm install @flashcatcloud/miniprogram-rum`
5353
2. 在微信开发者工具中打开项目
5454
3. 执行 **工具 > 构建 npm**
5555
4. 确认生成的 `miniprogram_npm` 可以被小程序代码引用

‎zh/rum/sdk/wechat-miniprogram/data-collection.mdx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ keywords: ["RUM", "微信小程序", "数据收集", "小程序监控"]
1313
| 页面访问 | 开启 | `Page` 生命周期:`onLoad`、`onShow`、`onReady`、`onHide`、`onUnload` | `view` |
1414
| 用户操作 | 开启 | 页面方法收到带有 `type` 的事件对象时自动记录 | `action` |
1515
| 网络请求 | 开启 | `wx.request`、`wx.uploadFile`、`wx.downloadFile` | `resource` |
16-
| 应用错误 | 开启 | `wx.onError`、`wx.onUnhandledRejection` | `error` |
16+
| 应用错误 | 开启 | `wx.onError`、`wx.onUnhandledRejection`、`wx.onPageNotFound`、`wx.onLazyLoadError` 和失败的网络请求 | `error` |
1717
| 性能指标 | 开启 | `wx.getPerformance` 和页面 `setUpdatePerformanceListener` | `view` |
1818
| 自定义事件 | 手动上报 | `addCustomEvent()` | `custom` |
1919

@@ -98,12 +98,15 @@ SDK 每 3 秒更新一次活跃页面的停留时长。页面进入后台、隐
9898

9999
## 错误采集
100100

101-
启用 `trackErrors` 后,SDK 会订阅小程序应用错误和未处理 Promise 拒绝。
101+
启用 `trackErrors` 后,SDK 会订阅小程序应用错误、未处理 Promise 拒绝、页面不存在和分包懒加载失败事件,并把失败的网络请求同时记录为错误。
102102

103103
| 来源 | SDK 标记 | 说明 |
104104
|------|----------|------|
105105
| `wx.onError` | `app` | 小程序运行时错误 |
106106
| `wx.onUnhandledRejection` | `promise` | 未处理的 Promise 拒绝 |
107+
| `wx.onPageNotFound` | `page-not-found` | 打开的页面不存在 |
108+
| `wx.onLazyLoadError` | `lazy-load` | 分包懒加载失败 |
109+
| 网络请求失败 | `network` | 请求失败时,SDK 在 resource 事件之外额外生成一条错误事件 |
107110
| `addError()` | `custom` | 你手动上报的业务错误 |
108111

109112
错误事件会包含错误消息、可选堆栈和来源。手动上报错误时,可以把 `error.stack` 作为第三个参数传入 `addError()`。
@@ -135,7 +138,7 @@ SDK 每 3 秒更新一次活跃页面的停留时长。页面进入后台、隐
135138
| `event.context` | 自定义事件上下文对象 |
136139

137140
```javascript pages/order/detail.js
138-
import { flashcatRum } from "@flashcatcloud/fc-sdk-miniprogram";
141+
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";
139142

140143
flashcatRum.addCustomEvent("order_status_changed", {
141144
orderId: "order-123",
@@ -157,7 +160,7 @@ SDK 会把非 view 事件关联到事件发生时间对应的页面和会话:
157160
你可以在初始化时关闭不需要的采集类型:
158161

159162
```javascript app.js
160-
import { flashcatRum } from "@flashcatcloud/fc-sdk-miniprogram";
163+
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";
161164

162165
flashcatRum.init({
163166
applicationId: "<YOUR_APPLICATION_ID>",

0 commit comments

Comments
 (0)