sentry-miniapp 1.11.1 → 1.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +83 -311
- package/README.md +83 -321
- package/dist/sentry-miniapp.cjs.js +1 -1
- package/dist/sentry-miniapp.cjs.js.map +1 -1
- package/dist/sentry-miniapp.esm.js +1 -1
- package/dist/sentry-miniapp.esm.js.map +1 -1
- package/dist/sentry-miniapp.umd.js +1 -1
- package/dist/sentry-miniapp.umd.js.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -2
package/README.en.md
CHANGED
|
@@ -7,26 +7,31 @@
|
|
|
7
7
|

|
|
8
8
|
[](https://docs.sentry.io/platforms/#sdks-supported-by-our-community)
|
|
9
9
|
[](./LICENSE)
|
|
10
|
+
[](https://sentry-miniapp.pages.dev/)
|
|
10
11
|
|
|
11
12
|
[简体中文](./README.md) | English
|
|
12
13
|
|
|
13
14
|
A **mini program monitoring SDK** built on `@sentry/core`, providing **error monitoring**, **performance monitoring**, offline caching, and distributed tracing. Supports WeChat, Alipay, ByteDance, Baidu, QQ, DingTalk, Kuaishou mini programs, **WeChat / Douyin mini games**, and cross-platform frameworks (Taro / uni-app).
|
|
14
15
|
|
|
15
|
-
> **What are Mini Programs?** Mini programs (小程序) are lightweight apps that run inside super-apps like WeChat, Alipay, and ByteDance/Douyin. They form a massive ecosystem in China with **hundreds of millions of daily active users**, but have no direct equivalent in the Western
|
|
16
|
+
> **What are Mini Programs?** Mini programs (小程序) are lightweight apps that run inside super-apps like WeChat, Alipay, and ByteDance/Douyin. They form a massive ecosystem in China with **hundreds of millions of daily active users**, but have no direct equivalent in the Western stack — think of them as a hybrid of PWAs and native apps, hosted within a platform's sandbox.
|
|
17
|
+
|
|
18
|
+
> **📖 Full docs live on the documentation site**: [sentry-miniapp.pages.dev](https://sentry-miniapp.pages.dev/) — getting started, capability matrix, per-framework setup, FAQ, Source Map config, and examples, with nav and search (Chinese for now). This README is a quick overview and entry point.
|
|
16
19
|
|
|
17
20
|
> **📰 Featured Article (Chinese)**: [《我给 Sentry 提了个 PR,后来 sentry-miniapp 进了官方文档》](https://juejin.cn/post/7636106283963760681) — How sentry-miniapp got listed in Sentry's official community-supported SDKs documentation. If you find this project useful, please consider giving it a ⭐ Star.
|
|
18
21
|
|
|
19
22
|
<details>
|
|
20
|
-
<summary><b>🆕 What's New: v1.3 → v1.
|
|
23
|
+
<summary><b>🆕 What's New: v1.3 → v1.11 (click to expand)</b></summary>
|
|
21
24
|
|
|
22
25
|
| Version | Highlights |
|
|
23
26
|
|---|---|
|
|
27
|
+
| **v1.11** | Mini-game performance data reported as **independent transactions** (Sentry Performance page); API requests reported as `http.client` spans; launched the [documentation site](https://sentry-miniapp.pages.dev/), added Taro / uni-app examples and a [two-layer Source Map merge script](./scripts/merge-sourcemap.mjs) |
|
|
28
|
+
| **v1.10** | 🎮 **Mini game support**: auto-detects mini-game environments; adds cold-start first-frame timing and frame-rate / jank (FPS) monitoring |
|
|
24
29
|
| **v1.8.0** | AI-assisted integration skill — auto onboarding via Claude Code / Cursor |
|
|
25
30
|
| **v1.7.0** | New `tracesSampler` for dynamic sampling; complete Source Map configuration guide |
|
|
26
|
-
| **v1.6.0** | 13 enhancements + 16 fixes;
|
|
27
|
-
| **v1.5.0** | Performance enhancements (configurable thresholds / slow `setData` detection / memory sampling); new page lifecycle, user interaction, and Console breadcrumbs
|
|
28
|
-
| **v1.4.0** | `NetworkBreadcrumbs` captures Request / Response body; configurable offline cache limit
|
|
29
|
-
| **v1.3.0** | 🎯 Build pipeline rewrite (Vite + bundle-inline): **zero external deps**,
|
|
31
|
+
| **v1.6.0** | 13 enhancements + 16 fixes; build output minification — bundle size reduced by ~**59%** |
|
|
32
|
+
| **v1.5.0** | Performance enhancements (configurable thresholds / slow `setData` detection / memory sampling); new page lifecycle, user interaction, and Console breadcrumbs |
|
|
33
|
+
| **v1.4.0** | `NetworkBreadcrumbs` captures Request / Response body; configurable offline cache limit |
|
|
34
|
+
| **v1.3.0** | 🎯 Build pipeline rewrite (Vite + bundle-inline): **zero external deps**, resolves the `miniprogram_npm` module-resolution issue; built-in Source Map path normalization |
|
|
30
35
|
|
|
31
36
|
See [CHANGELOG.md](./CHANGELOG.md) for full details.
|
|
32
37
|
|
|
@@ -34,394 +39,161 @@ See [CHANGELOG.md](./CHANGELOG.md) for full details.
|
|
|
34
39
|
|
|
35
40
|
---
|
|
36
41
|
|
|
37
|
-
## Core Features
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
- **
|
|
49
|
-
-
|
|
50
|
-
- **Session Health Monitoring**: Automatic session lifecycle management with crash rate and session health data in the Sentry Release Health dashboard.
|
|
51
|
-
- **Network Status Monitoring**: Real-time tracking of network changes (WiFi/4G/offline) to help diagnose network-related exceptions.
|
|
52
|
-
- **Stack Trace Parsing**: Built-in multi-platform stack parser supporting V8/Safari/JavaScriptCore formats for precise error location with SourceMap.
|
|
42
|
+
## ✨ Core Features
|
|
43
|
+
|
|
44
|
+
- **🚀 Modern Architecture**: Built on the latest Sentry JavaScript V10 SDK core modules.
|
|
45
|
+
- **📱 True Multi-Platform Support**: Built-in API abstraction engine — one codebase supports **WeChat, Alipay, ByteDance, Baidu, QQ, DingTalk, and Kuaishou** mini programs.
|
|
46
|
+
- **🎮 Mini Game Support**: Auto-detects mini-game environments — error / network / device monitoring out of the box, plus mini-game-specific **cold-start first-frame timing** and **frame-rate / jank monitoring**.
|
|
47
|
+
- **🎯 Automatic Exception Capture**: No business code intrusion. Hooks into lifecycle error listeners (`onError`, `onUnhandledRejection`, `onPageNotFound`, `onMemoryWarning`).
|
|
48
|
+
- **🍞 Rich Context Breadcrumbs**: Auto-records device info, user tap/touch, network requests (XHR), and page lifecycle.
|
|
49
|
+
- **🗺️ Built-in SourceMap Path Normalization**: Unifies virtual stack paths across platforms; works with sentry-cli for seamless resolution.
|
|
50
|
+
- **📡 Offline Caching for Weak Networks**: Caches events to local storage on failure, silently retries when connectivity returns.
|
|
51
|
+
- **⚡ Deep Performance Monitoring**: Navigation timing (FCP/LCP), render performance, resource loading, and custom marks.
|
|
52
|
+
- **🔗 Distributed Tracing**: Injects `sentry-trace` / `baggage` headers and reports API timing as `http.client` spans, connecting mini program and backend call chains.
|
|
53
|
+
- **📊 Session Health** & **📶 Network Status Monitoring**: Session lifecycle management + real-time network change tracking (WiFi/4G/offline).
|
|
54
|
+
- **🛡️ Smart Deduplication & Filtering**: Built-in dedup and sample rate controls to prevent log storms.
|
|
53
55
|
|
|
54
56
|
---
|
|
55
57
|
|
|
56
|
-
## Installation
|
|
58
|
+
## 📦 Installation
|
|
57
59
|
|
|
58
60
|
```bash
|
|
59
61
|
npm install sentry-miniapp
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
---
|
|
64
|
+
> Not using npm? Copy `examples/wxapp/lib/sentry-miniapp.js` from this repo directly into your project.
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
### 🤖 AI-Assisted Setup
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
With [Claude Code](https://claude.ai/code) or [Cursor](https://cursor.com), get AI-guided setup:
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
71
|
npx skills add https://github.com/lizhiyao/sentry-miniapp --skill sentry-miniapp-sdk
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Then just ask "help me set up Sentry monitoring" in your AI editor.
|
|
75
75
|
|
|
76
76
|
---
|
|
77
77
|
|
|
78
|
-
## Quick Start
|
|
79
|
-
|
|
80
|
-
### 1. Prerequisites
|
|
81
|
-
|
|
82
|
-
1. Ensure you have a Sentry account ([Sentry SaaS](https://sentry.io/) or self-hosted).
|
|
83
|
-
2. **Important**: Add your Sentry reporting endpoint domain to the `request` trusted domain list in your mini program platform's admin console.
|
|
78
|
+
## 🚀 Quick Start
|
|
84
79
|
|
|
85
|
-
|
|
80
|
+
**Prerequisites**: ① a Sentry account ([SaaS](https://sentry.io/) or self-hosted); ② add your Sentry endpoint domain to the `request` trusted-domain list in your mini program console.
|
|
86
81
|
|
|
87
|
-
Initialize
|
|
82
|
+
Initialize at the **top** of your entry file (`app.js` / `app.ts`), **before** `App()`:
|
|
88
83
|
|
|
89
84
|
```javascript
|
|
90
85
|
import * as Sentry from 'sentry-miniapp';
|
|
91
86
|
|
|
92
87
|
Sentry.init({
|
|
93
88
|
dsn: 'https://<key>@sentry.io/<project>',
|
|
89
|
+
release: 'my-project@1.0.0', // match the release you upload Source Maps with
|
|
94
90
|
environment: 'production',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// --- Mini Program Configuration ---
|
|
98
|
-
platform: 'wechat', // Optional event platform label; runtime platform is auto-detected
|
|
99
|
-
enableUserInteractionBreadcrumbs: true, // Auto-record user tap events
|
|
100
|
-
enableConsoleBreadcrumbs: false, // Record console output as breadcrumbs (default: false)
|
|
101
|
-
traceNetworkBody: false, // Record request/response bodies in breadcrumbs (default: false)
|
|
102
|
-
|
|
103
|
-
// --- Offline Cache & Reliability ---
|
|
104
|
-
enableOfflineCache: true, // Enable offline caching with retry (default: true)
|
|
105
|
-
offlineCacheLimit: 30, // Max cached events (default: 30)
|
|
106
|
-
|
|
107
|
-
// --- SourceMap Support ---
|
|
108
|
-
enableSourceMap: true, // Normalize virtual stack paths for SourceMap resolution
|
|
109
|
-
|
|
110
|
-
// --- Sampling ---
|
|
111
|
-
sampleRate: 1.0, // Error reporting sample rate (0.0 - 1.0)
|
|
112
|
-
tracesSampleRate: 1.0, // Performance tracing sample rate; API requests are reported as http.client spans
|
|
113
|
-
|
|
114
|
-
// --- Distributed Tracing ---
|
|
115
|
-
enableTracePropagation: true, // Auto-inject sentry-trace/baggage headers (default: true)
|
|
116
|
-
tracePropagationTargets: ['api.example.com'], // Only inject tracing headers for specified domains; spans still follow tracing sampling
|
|
117
|
-
|
|
118
|
-
// --- Session & Network Monitoring ---
|
|
119
|
-
enableAutoSessionTracking: true, // Auto session lifecycle management (default: true)
|
|
120
|
-
enableNetworkStatusMonitoring: true, // Real-time network status monitoring (default: true)
|
|
91
|
+
sampleRate: 1.0, // error sample rate
|
|
92
|
+
tracesSampleRate: 1.0, // performance sample rate; API requests become http.client spans
|
|
121
93
|
});
|
|
122
94
|
|
|
123
|
-
App({
|
|
124
|
-
onLaunch() {
|
|
125
|
-
// ...
|
|
126
|
-
}
|
|
127
|
-
});
|
|
95
|
+
App({ onLaunch() {} });
|
|
128
96
|
```
|
|
129
97
|
|
|
130
|
-
Default integrations already include
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Advanced Usage
|
|
135
|
-
|
|
136
|
-
After initialization, the SDK works automatically in the background. You can also use the following APIs for manual instrumentation.
|
|
98
|
+
Default integrations already include **exception capture, performance monitoring, Source Map path normalization, network breadcrumbs, session and network status monitoring** — you usually don't pass `integrations` (doing so replaces the defaults). Full options (offline cache, trace propagation, breadcrumb toggles) are on the [docs site · Configuration](https://sentry-miniapp.pages.dev/guide/configuration).
|
|
137
99
|
|
|
138
|
-
|
|
100
|
+
**Verify it works** — capture an event and check the Sentry "Issues" list:
|
|
139
101
|
|
|
140
102
|
```javascript
|
|
141
|
-
|
|
142
|
-
try {
|
|
143
|
-
throw new Error('Payment API parsing failed');
|
|
144
|
-
} catch (error) {
|
|
145
|
-
Sentry.captureException(error);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Log a message
|
|
149
|
-
Sentry.captureMessage('User cancelled authorization', 'info');
|
|
103
|
+
Sentry.captureException(new Error('sentry test'));
|
|
150
104
|
```
|
|
151
105
|
|
|
152
|
-
|
|
106
|
+
> ⚠️ `addBreadcrumb` is not reported on its own — it only ships with the next event. Calling it without capturing an event leaves your dashboard empty.
|
|
153
107
|
|
|
154
|
-
|
|
155
|
-
// Set current user info
|
|
156
|
-
Sentry.setUser({
|
|
157
|
-
id: 'user_12345',
|
|
158
|
-
username: 'John Doe'
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Set global tags for filtering and analytics
|
|
162
|
-
Sentry.setTag('page_module', 'checkout_counter');
|
|
163
|
-
|
|
164
|
-
// Manually add a breadcrumb
|
|
165
|
-
Sentry.addBreadcrumb({
|
|
166
|
-
message: 'User tapped [Confirm Payment] button',
|
|
167
|
-
category: 'action',
|
|
168
|
-
level: 'info',
|
|
169
|
-
data: { cartId: 'c_888' }
|
|
170
|
-
});
|
|
171
|
-
```
|
|
108
|
+
---
|
|
172
109
|
|
|
173
|
-
|
|
110
|
+
## 📚 Common APIs
|
|
174
111
|
|
|
175
112
|
```javascript
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
op: 'http.client',
|
|
180
|
-
},
|
|
181
|
-
async () => {
|
|
182
|
-
await fetchUserData();
|
|
183
|
-
},
|
|
184
|
-
);
|
|
185
|
-
```
|
|
113
|
+
// Manual capture
|
|
114
|
+
Sentry.captureException(new Error('Payment API parsing failed'));
|
|
115
|
+
Sentry.captureMessage('User cancelled authorization', 'info');
|
|
186
116
|
|
|
187
|
-
|
|
117
|
+
// User & tags
|
|
118
|
+
Sentry.setUser({ id: 'user_12345', username: 'John Doe' });
|
|
119
|
+
Sentry.setTag('page_module', 'checkout');
|
|
188
120
|
|
|
189
|
-
|
|
121
|
+
// Breadcrumb
|
|
122
|
+
Sentry.addBreadcrumb({ message: 'Tapped [Confirm Payment]', category: 'action', level: 'info' });
|
|
190
123
|
|
|
191
|
-
|
|
192
|
-
Sentry.
|
|
193
|
-
dsn: '...',
|
|
194
|
-
tracesSampler: ({ name, inheritOrSampleWith }) => {
|
|
195
|
-
// 100% sampling for critical pages
|
|
196
|
-
if (name.includes('pages/index') || name.includes('pages/pay')) {
|
|
197
|
-
return 1;
|
|
198
|
-
}
|
|
199
|
-
// Lower sampling for low-priority pages
|
|
200
|
-
if (name.includes('pages/about') || name.includes('pages/settings')) {
|
|
201
|
-
return 0.1;
|
|
202
|
-
}
|
|
203
|
-
// Inherit upstream decision or fall back to 50%
|
|
204
|
-
return inheritOrSampleWith(0.5);
|
|
205
|
-
},
|
|
206
|
-
});
|
|
124
|
+
// Custom span
|
|
125
|
+
await Sentry.startSpan({ name: 'fetch-user', op: 'http.client' }, async () => { /* ... */ });
|
|
207
126
|
```
|
|
208
127
|
|
|
209
|
-
|
|
128
|
+
For per-page / per-scenario sampling use the `tracesSampler` callback (it overrides `tracesSampleRate`); see the [docs site · Configuration](https://sentry-miniapp.pages.dev/guide/configuration).
|
|
210
129
|
|
|
211
130
|
---
|
|
212
131
|
|
|
213
|
-
##
|
|
214
|
-
|
|
215
|
-
The SDK includes built-in multi-platform stack path normalization (`enableSourceMap: true`, enabled by default), automatically converting platform-specific virtual paths to the `app:///` prefix for seamless SourceMap resolution with sentry-cli.
|
|
132
|
+
## 🗺️ Source Map
|
|
216
133
|
|
|
217
|
-
|
|
134
|
+
The SDK normalizes platform virtual stack paths to the `app:///` prefix by default (`enableSourceMap: true`). Upload with sentry-cli:
|
|
218
135
|
|
|
219
136
|
```bash
|
|
220
137
|
sentry-cli releases files "my-miniapp@1.0.0" upload-sourcemaps ./dist \
|
|
221
|
-
--url-prefix "app:///"
|
|
222
|
-
--ext js --ext map
|
|
138
|
+
--url-prefix "app:///" --ext js --ext map
|
|
223
139
|
```
|
|
224
140
|
|
|
225
|
-
>
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
## User Feedback
|
|
230
|
-
|
|
231
|
-
In web environments, Sentry provides a built-in `showReportDialog()` popup. However, mini programs have no DOM, so this method is **not available**.
|
|
232
|
-
|
|
233
|
-
Instead, build a **native mini program form or modal** to collect user feedback, then submit it via `Sentry.captureFeedback()`:
|
|
234
|
-
|
|
235
|
-
```javascript
|
|
236
|
-
const userMessage = 'The page is frozen, nothing responds';
|
|
237
|
-
const userName = 'John Doe';
|
|
238
|
-
const userEmail = 'john@example.com';
|
|
239
|
-
|
|
240
|
-
Sentry.captureFeedback({
|
|
241
|
-
message: userMessage,
|
|
242
|
-
name: userName,
|
|
243
|
-
email: userEmail,
|
|
244
|
-
// Optional: associate with a specific error event
|
|
245
|
-
// associatedEventId: 'abc123xyz...'
|
|
246
|
-
});
|
|
247
|
-
```
|
|
141
|
+
> Full end-to-end setup (build tools, CI/CD, two-layer map merging for cross-platform frameworks, verification) is in the **[Source Map Configuration Guide](./docs/SOURCEMAP_GUIDE.md)**.
|
|
248
142
|
|
|
249
143
|
---
|
|
250
144
|
|
|
251
|
-
##
|
|
145
|
+
## 🎮 Mini Game Support
|
|
252
146
|
|
|
253
|
-
|
|
147
|
+
`sentry-miniapp` also works in WeChat / Douyin **mini games**: auto-detects the environment, error / network / device monitoring out of the box, plus **cold-start first-frame timing** and **frame-rate / jank monitoring**. Initialization is identical to mini programs; with `tracesSampleRate` enabled, performance data is reported as independent transactions on the Performance page.
|
|
254
148
|
|
|
255
|
-
|
|
149
|
+
> Capability matrix and performance-reporting details: [docs site · Platforms & Capabilities](https://sentry-miniapp.pages.dev/guide/platforms).
|
|
256
150
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
WeChat and Alipay natively support [subpackage async loading](https://developers.weixin.qq.com/miniprogram/dev/framework/subpackages/async.html).
|
|
260
|
-
|
|
261
|
-
```javascript
|
|
262
|
-
// app.js
|
|
263
|
-
App({
|
|
264
|
-
onLaunch() {
|
|
265
|
-
require.async('./subpackageA/sentry-miniapp.js').then((Sentry) => {
|
|
266
|
-
Sentry.init({
|
|
267
|
-
dsn: 'https://xxxxxxxx@sentry.io/12345',
|
|
268
|
-
// ...other options
|
|
269
|
-
});
|
|
270
|
-
console.log('Sentry loaded and initialized successfully');
|
|
271
|
-
}).catch(err => {
|
|
272
|
-
console.error('Failed to load Sentry', err);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
```
|
|
151
|
+
## 📦 Bundle Size Optimization
|
|
277
152
|
|
|
278
|
-
|
|
153
|
+
The SDK is ~100KB. If main-package size matters, use platform "subpackage async" / "dynamic loading" to move the SDK into a subpackage and reduce main-package overhead; platforms with cross-subpackage async loading can reach zero main-package overhead.
|
|
279
154
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
For platforms that don't support `require.async`, use **subpackage predownload + dynamic loading**:
|
|
283
|
-
|
|
284
|
-
```javascript
|
|
285
|
-
// ByteDance mini program example
|
|
286
|
-
App({
|
|
287
|
-
onLaunch() {
|
|
288
|
-
const loadTask = tt.loadSubpackage({
|
|
289
|
-
name: 'subpackageA',
|
|
290
|
-
success: () => {
|
|
291
|
-
const Sentry = require('./subpackageA/sentry-miniapp.js');
|
|
292
|
-
Sentry.init({ dsn: '...' });
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
*Note: If using Taro / uni-app, you can use `import('sentry-miniapp')` dynamic import syntax — the framework handles cross-platform differences at compile time.*
|
|
155
|
+
> WeChat subpackage async loading and cross-platform verification guidance: [docs site · Bundle Size](https://sentry-miniapp.pages.dev/guide/bundle-size).
|
|
300
156
|
|
|
301
157
|
---
|
|
302
158
|
|
|
303
|
-
##
|
|
304
|
-
|
|
305
|
-
`sentry-miniapp` also works in **mini games** (WeChat / ByteDance mini games, etc.). Mini games have no `App()`/`Page()`/page routing, but expose platform APIs like `wx.onError`, `wx.request`, `wx.getDeviceInfo`, and `wx.getPerformance`. Most SDK capabilities work out of the box, plus mini-game-specific cold-start and frame-rate monitoring.
|
|
306
|
-
|
|
307
|
-
**Initialization is identical to mini programs** — the SDK auto-detects the mini-game environment and enables the relevant features:
|
|
308
|
-
|
|
309
|
-
```js
|
|
310
|
-
import * as Sentry from 'sentry-miniapp';
|
|
311
|
-
|
|
312
|
-
Sentry.init({
|
|
313
|
-
dsn: 'YOUR_DSN',
|
|
314
|
-
// Enabled by default in mini-game environments; set to false to disable:
|
|
315
|
-
// enableMinigameLifecycle: true, // cold-start first-frame timing + launch scene + onShow/onHide breadcrumbs
|
|
316
|
-
// enableMinigameFrameRate: true, // FPS / jank monitoring
|
|
317
|
-
|
|
318
|
-
// Fine-tune frame-rate monitoring (FPS warning threshold, jank threshold, report interval, etc.):
|
|
319
|
-
// minigameFrameRateOptions: { fpsWarningThreshold: 45 },
|
|
320
|
-
});
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### Capability matrix
|
|
324
|
-
|
|
325
|
-
| Capability | Mini Game | Notes |
|
|
326
|
-
|------------|:---------:|-------|
|
|
327
|
-
| Exception / unhandled rejection capture | ✅ | `wx.onError` / `wx.onUnhandledRejection` |
|
|
328
|
-
| API request monitoring (count / duration / status) | ✅ | wraps `wx.request`; creates `http.client` spans when tracing is enabled |
|
|
329
|
-
| Network status monitoring | ✅ | `wx.onNetworkStatusChange` |
|
|
330
|
-
| Device info / context breadcrumbs | ✅ | `wx.getDeviceInfo` etc. |
|
|
331
|
-
| Resource load timing | ✅ | `wx.getPerformance()` |
|
|
332
|
-
| **Cold-start first-frame timing + launch scene** | ✅ New | `MinigameIntegration` (first `requestAnimationFrame` ≈ first frame) |
|
|
333
|
-
| **Frame rate / jank monitoring** | ✅ New | `MinigameFrameRateIntegration` (RAF FPS sampling, long frames → jank, periodic `minigame.framerate` context) |
|
|
334
|
-
| Page lifecycle / tap breadcrumbs | ➖ | No pages in mini games — auto-skipped; use `onShow/onHide` breadcrumbs or manual `addBreadcrumb` |
|
|
159
|
+
## 💬 User Feedback
|
|
335
160
|
|
|
336
|
-
|
|
161
|
+
Mini programs have no DOM, so `showReportDialog()` is deprecated. Build a native form to collect feedback, then submit via `Sentry.captureFeedback()`:
|
|
337
162
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
Cold-start and frame-rate data are **not only attached to error events** — with tracing enabled they are reported as independent transactions, so you can aggregate trends / distributions / P95 across sessions on the Sentry Performance page:
|
|
341
|
-
|
|
342
|
-
- **Cold start** → a `minigame.coldstart` transaction (with a `cold_start` measurement).
|
|
343
|
-
- **Frame rate / jank** → accumulated per session and flushed as a single `minigame.framerate.summary` transaction on **background (onHide) / session end** (with `fps_avg` / `fps_p95` / `fps_min` / `jank_count` measurements) — no per-window events, quota-friendly.
|
|
344
|
-
|
|
345
|
-
```js
|
|
346
|
-
Sentry.init({
|
|
347
|
-
dsn: 'YOUR_DSN',
|
|
348
|
-
tracesSampleRate: 1.0, // enable performance sampling (decoupled from error sampleRate)
|
|
349
|
-
});
|
|
163
|
+
```javascript
|
|
164
|
+
Sentry.captureFeedback({ message: 'The page is frozen', name: 'John Doe', email: 'john@example.com' });
|
|
350
165
|
```
|
|
351
166
|
|
|
352
|
-
> Requires `tracesSampleRate` (or `tracesSampler`) for performance transactions to be sent; this sampling is **independent of** the error `sampleRate`. Without tracing enabled, it degrades to the original behavior: performance data is only attached to error events as `minigame` / `minigame.framerate` contexts + breadcrumbs.
|
|
353
|
-
|
|
354
167
|
---
|
|
355
168
|
|
|
356
|
-
## FAQ
|
|
357
|
-
|
|
358
|
-
### 1. Do I need to manually report errors in `onError`?
|
|
359
|
-
|
|
360
|
-
**No.** `sentry-miniapp` automatically hooks into platform-level global error listeners (e.g., `wx.onError`) during initialization. As long as `Sentry.init` is called **before** `App()`, it captures all unhandled JS exceptions automatically.
|
|
361
|
-
|
|
362
|
-
If errors are not being reported, check:
|
|
363
|
-
1. Whether the Sentry domain is in the mini program's trusted domain list.
|
|
364
|
-
2. Whether `sampleRate` is set too low.
|
|
365
|
-
3. Some WeChat DevTools environments don't trigger `onError` — test on a **real device**.
|
|
366
|
-
|
|
367
|
-
### 2. Does this SDK support Session Replay?
|
|
368
|
-
|
|
369
|
-
**Not currently.** Sentry's official Replay feature relies on standard browser DOM (via rrweb recording). Mini programs use a dual-thread architecture without standard DOM access. We recommend using **Breadcrumbs** combined with **custom logging** to reconstruct user action sequences.
|
|
370
|
-
|
|
371
|
-
### 3. How do I monitor the H5 build of a uni-app / Taro project?
|
|
372
|
-
|
|
373
|
-
`sentry-miniapp` **only adapts mini program platforms** and does not implement browser-native signals (`window.onerror`, `fetch` / `XHR` interception, `PerformanceObserver`, etc.). For the H5 build, use Sentry's official [`@sentry/browser`](https://docs.sentry.io/platforms/javascript/) directly — full feature coverage, maintained upstream.
|
|
374
|
-
|
|
375
|
-
> When this SDK is initialized in a browser environment, it logs a warning suggesting you switch to `@sentry/browser`.
|
|
376
|
-
|
|
377
|
-
Recommended pattern: split SDKs by platform via **uni-app conditional compilation**:
|
|
169
|
+
## ❓ FAQ (quick reference)
|
|
378
170
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
171
|
+
- **Must I report manually in `onError`?** No — `init` hooks the global error listeners automatically.
|
|
172
|
+
- **Are network requests included with errors?** Yes, on by default — recorded as `category: xhr` breadcrumbs shipped with the error.
|
|
173
|
+
- **uni-app (Vue) component errors rarely reported?** Vue swallows component errors; wire `app.config.errorHandler`. Taro (React) uses an Error Boundary.
|
|
174
|
+
- **Session Replay?** Not supported (no DOM); reconstruct via breadcrumbs.
|
|
175
|
+
- **H5 build?** Use official `@sentry/browser`, branched via conditional compilation.
|
|
382
176
|
|
|
383
|
-
|
|
384
|
-
Sentry = require('@sentry/browser');
|
|
385
|
-
Sentry.init({
|
|
386
|
-
dsn: 'YOUR_DSN',
|
|
387
|
-
environment: 'production',
|
|
388
|
-
tracesSampleRate: 0.2,
|
|
389
|
-
});
|
|
390
|
-
// #endif
|
|
391
|
-
|
|
392
|
-
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ || MP-KUAISHOU || MP-DINGTALK
|
|
393
|
-
Sentry = require('sentry-miniapp');
|
|
394
|
-
Sentry.init({
|
|
395
|
-
dsn: 'YOUR_DSN',
|
|
396
|
-
environment: 'production',
|
|
397
|
-
tracesSampleRate: 0.2,
|
|
398
|
-
});
|
|
399
|
-
// #endif
|
|
400
|
-
|
|
401
|
-
export default Sentry;
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
Both sides report to the same Sentry DSN so all errors land in a single project. For Taro, use `process.env.TARO_ENV === 'h5'` to branch similarly.
|
|
177
|
+
> Full answers on the **[docs site · FAQ](https://sentry-miniapp.pages.dev/guide/faq)**.
|
|
405
178
|
|
|
406
179
|
---
|
|
407
180
|
|
|
408
|
-
## Documentation
|
|
181
|
+
## 📖 Documentation
|
|
409
182
|
|
|
410
183
|
| Document | Description |
|
|
411
184
|
|----------|-------------|
|
|
412
|
-
| [
|
|
413
|
-
| [
|
|
414
|
-
| [
|
|
415
|
-
| [
|
|
416
|
-
| [
|
|
185
|
+
| [Documentation site](https://sentry-miniapp.pages.dev/) | Getting started / capability matrix / FAQ / Source Map / examples (recommended, with search) |
|
|
186
|
+
| [Taro guide](https://sentry-miniapp.pages.dev/guide/taro) · [uni-app guide](https://sentry-miniapp.pages.dev/guide/uniapp) | Cross-platform framework setup & component error handling |
|
|
187
|
+
| [Source Map Configuration Guide](./docs/SOURCEMAP_GUIDE.md) | End-to-end setup, build tools, CI/CD, verification |
|
|
188
|
+
| [Multi-Platform Compatibility Report](./docs/MultiPlatformCompatibilityReport.md) | Platform API differences |
|
|
189
|
+
| [Examples](./examples/) | wxapp (native) / taro (React) / uniapp (Vue) runnable examples |
|
|
190
|
+
| [Development Guide](./DEVELOPMENT.md) · [Contributing Guide](./CONTRIBUTING.md) | Local dev, debugging & contributing |
|
|
417
191
|
|
|
418
192
|
---
|
|
419
193
|
|
|
420
|
-
## Community
|
|
421
|
-
|
|
422
|
-
Have questions or want to discuss mini program monitoring? Join our community.
|
|
194
|
+
## 💬 Community
|
|
423
195
|
|
|
424
|
-
Due to WeChat group QR code expiration (7-day limit), please add the author on WeChat (**note: sentry-miniapp**) to be invited to the group:
|
|
196
|
+
Have questions or want to discuss mini program monitoring? Due to WeChat group QR code expiration (7-day limit), please add the author on WeChat (**note: sentry-miniapp**) to be invited to the group:
|
|
425
197
|
|
|
426
198
|
<img src="docs/qrcode/zhiyao.jpeg" alt="Author WeChat QR Code" width="200" style="border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);" />
|
|
427
199
|
|