sentry-miniapp 1.5.0 → 1.7.0

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.
Files changed (49) hide show
  1. package/README.en.md +338 -0
  2. package/README.md +61 -16
  3. package/dist/sentry-miniapp.cjs.js +7 -7193
  4. package/dist/sentry-miniapp.cjs.js.map +1 -1
  5. package/dist/sentry-miniapp.esm.js +3781 -5221
  6. package/dist/sentry-miniapp.esm.js.map +1 -1
  7. package/dist/sentry-miniapp.umd.js +7 -7197
  8. package/dist/sentry-miniapp.umd.js.map +1 -1
  9. package/dist/types/client.d.ts +4 -0
  10. package/dist/types/client.d.ts.map +1 -1
  11. package/dist/types/crossPlatform.d.ts +7 -0
  12. package/dist/types/crossPlatform.d.ts.map +1 -1
  13. package/dist/types/helpers.d.ts +9 -9
  14. package/dist/types/index.d.ts +1 -0
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/types/integrations/console.d.ts +5 -0
  17. package/dist/types/integrations/console.d.ts.map +1 -1
  18. package/dist/types/integrations/dedupe.d.ts +6 -0
  19. package/dist/types/integrations/dedupe.d.ts.map +1 -1
  20. package/dist/types/integrations/globalhandlers.d.ts +8 -4
  21. package/dist/types/integrations/globalhandlers.d.ts.map +1 -1
  22. package/dist/types/integrations/index.d.ts +2 -0
  23. package/dist/types/integrations/index.d.ts.map +1 -1
  24. package/dist/types/integrations/networkbreadcrumbs.d.ts +35 -0
  25. package/dist/types/integrations/networkbreadcrumbs.d.ts.map +1 -1
  26. package/dist/types/integrations/networkstatus.d.ts +13 -0
  27. package/dist/types/integrations/networkstatus.d.ts.map +1 -0
  28. package/dist/types/integrations/pagebreadcrumbs.d.ts +8 -0
  29. package/dist/types/integrations/pagebreadcrumbs.d.ts.map +1 -1
  30. package/dist/types/integrations/performance.d.ts.map +1 -1
  31. package/dist/types/integrations/router.d.ts +5 -0
  32. package/dist/types/integrations/router.d.ts.map +1 -1
  33. package/dist/types/integrations/session.d.ts +25 -0
  34. package/dist/types/integrations/session.d.ts.map +1 -0
  35. package/dist/types/integrations/system.d.ts +8 -0
  36. package/dist/types/integrations/system.d.ts.map +1 -1
  37. package/dist/types/integrations/trycatch.d.ts +1 -12
  38. package/dist/types/integrations/trycatch.d.ts.map +1 -1
  39. package/dist/types/polyfills.d.ts.map +1 -1
  40. package/dist/types/sdk.d.ts.map +1 -1
  41. package/dist/types/stacktrace.d.ts +10 -0
  42. package/dist/types/stacktrace.d.ts.map +1 -0
  43. package/dist/types/transports/offlineStore.d.ts +4 -1
  44. package/dist/types/transports/offlineStore.d.ts.map +1 -1
  45. package/dist/types/transports/xhr.d.ts.map +1 -1
  46. package/dist/types/types.d.ts +44 -4
  47. package/dist/types/types.d.ts.map +1 -1
  48. package/dist/types/version.d.ts +1 -1
  49. package/package.json +46 -35
package/README.en.md ADDED
@@ -0,0 +1,338 @@
1
+ # Sentry Miniapp SDK — Mini Program Monitoring SDK
2
+
3
+ ![npm version](https://img.shields.io/npm/v/sentry-miniapp)
4
+ ![npm downloads/month](https://img.shields.io/npm/dm/sentry-miniapp)
5
+ ![github forks](https://img.shields.io/github/forks/lizhiyao/sentry-miniapp?style=social)
6
+ ![github stars](https://img.shields.io/github/stars/lizhiyao/sentry-miniapp?style=social)
7
+ ![test coverage](https://img.shields.io/badge/test%20coverage-100%25-brightgreen.svg)
8
+ ![license](https://img.shields.io/github/license/lizhiyao/sentry-miniapp)
9
+
10
+ [简体中文](./README.md) | English
11
+
12
+ A **mini program monitoring SDK** built on `@sentry/core` (v10.45.0), providing **error monitoring**, **performance monitoring**, offline caching, and distributed tracing. Supports WeChat, Alipay, ByteDance, Baidu, QQ, DingTalk, Kuaishou mini programs and cross-platform frameworks (Taro / uni-app).
13
+
14
+ > **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 tech stack. Think of them as a hybrid between PWAs and native apps, but hosted within a platform's sandbox.
15
+
16
+ > **Version Notes**
17
+ >
18
+ > - `v1.x.x`: New architecture based on Sentry V10 core. Full support for WeChat, Alipay, ByteDance, Baidu, QQ, DingTalk, Kuaishou mini programs and cross-platform frameworks (Taro / uni-app).
19
+ > - `v0.x.x`: Legacy version, no longer maintained.
20
+
21
+ ---
22
+
23
+ ## Core Features
24
+
25
+ - **Modern Architecture**: Built on the latest Sentry JavaScript V10 SDK core modules.
26
+ - **True Multi-Platform Support**: Built-in API abstraction engine — one codebase seamlessly supports **WeChat, Alipay, ByteDance, Baidu, QQ, DingTalk, and Kuaishou** mini program platforms.
27
+ - **Automatic Exception Capture**: No business code intrusion required. Automatically hooks into lifecycle error listeners (`onError`, `onUnhandledRejection`, `onPageNotFound`, `onMemoryWarning`).
28
+ - **Rich Context Breadcrumbs**: Automatically records device info, user tap/touch interactions, network requests (XHR/Fetch), and page navigation paths.
29
+ - **Built-in SourceMap Path Normalization**: Handles virtual stack paths across WeChat, Alipay, ByteDance and other platforms. Works with sentry-cli for seamless SourceMap resolution.
30
+ - **Offline Caching for Weak Networks**: Designed for mini program network conditions. Automatically caches events to local storage on network failure, silently retries when connectivity is restored.
31
+ - **Deep Performance Monitoring**: Integrates mini program Performance API for navigation timing (FCP/LCP), render performance, resource loading, and custom performance marks.
32
+ - **Smart Deduplication & Filtering**: Built-in error deduplication and sample rate controls to prevent log storms.
33
+ - **Cross-Platform Framework Friendly**: Works seamlessly with Taro, uni-app, and other cross-platform compilation frameworks.
34
+ - **Distributed Tracing**: Automatically injects `sentry-trace` / `baggage` headers into network requests, connecting mini program and backend service call chains.
35
+ - **Session Health Monitoring**: Automatic session lifecycle management with crash rate and session health data in the Sentry Release Health dashboard.
36
+ - **Network Status Monitoring**: Real-time tracking of network changes (WiFi/4G/offline) to help diagnose network-related exceptions.
37
+ - **Stack Trace Parsing**: Built-in multi-platform stack parser supporting V8/Safari/JavaScriptCore formats for precise error location with SourceMap.
38
+
39
+ ---
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install sentry-miniapp --save
45
+ ```
46
+
47
+ > **Note:** Starting from `v1.1.0`, the build strategy has been optimized (dependencies are inlined), so there is **no need** to install `@sentry/core` separately.
48
+
49
+ *Tip: If you don't use npm, you can also copy `examples/wxapp/lib/sentry-miniapp.js` from this repository directly into your mini program project.*
50
+
51
+ ---
52
+
53
+ ## Quick Start
54
+
55
+ ### 1. Prerequisites
56
+
57
+ 1. Ensure you have a Sentry account ([Sentry SaaS](https://sentry.io/) or self-hosted).
58
+ 2. **Important**: Add your Sentry reporting endpoint domain to the `request` trusted domain list in your mini program platform's admin console.
59
+
60
+ ### 2. Initialize the SDK
61
+
62
+ Initialize Sentry at the **top** of your mini program entry file (e.g., `app.js` or `app.ts`), **before** calling `App()`.
63
+
64
+ ```javascript
65
+ import * as Sentry from 'sentry-miniapp';
66
+
67
+ Sentry.init({
68
+ dsn: 'https://<key>@sentry.io/<project>',
69
+ environment: 'production',
70
+ release: 'my-project-name@1.0.0',
71
+
72
+ // --- Mini Program Configuration ---
73
+ platform: 'wechat', // Current platform (wechat | alipay | bytedance | dd | swan, etc.)
74
+ enableSystemInfo: true, // Auto-collect system and device info
75
+ enableUserInteractionBreadcrumbs: true, // Auto-record user tap events
76
+ enableNavigationBreadcrumbs: true, // Auto-record page navigation
77
+ traceNetworkBody: true, // Record request/response bodies in breadcrumbs (default: false)
78
+
79
+ // --- Offline Cache & Reliability ---
80
+ enableOfflineCache: true, // Enable offline caching with retry (default: true)
81
+ offlineCacheLimit: 30, // Max cached events (default: 30)
82
+
83
+ // --- SourceMap Support ---
84
+ enableSourceMap: true, // Normalize virtual stack paths for SourceMap resolution
85
+
86
+ // --- Sampling ---
87
+ sampleRate: 1.0, // Error reporting sample rate (0.0 - 1.0)
88
+
89
+ // --- Distributed Tracing ---
90
+ enableTracePropagation: true, // Auto-inject sentry-trace/baggage headers (default: true)
91
+ tracePropagationTargets: ['api.example.com'], // Only inject tracing headers for specified domains
92
+
93
+ // --- Session & Network Monitoring ---
94
+ enableAutoSessionTracking: true, // Auto session lifecycle management (default: true)
95
+ enableNetworkStatusMonitoring: true, // Real-time network status monitoring (default: true)
96
+
97
+ // Optional: Performance monitoring
98
+ integrations: [
99
+ Sentry.performanceIntegration({
100
+ enableNavigation: true, // Navigation timing
101
+ enableRender: true, // Render timing
102
+ enableResource: true, // Resource loading timing
103
+ }),
104
+ ]
105
+ });
106
+
107
+ App({
108
+ onLaunch() {
109
+ // ...
110
+ }
111
+ });
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Advanced Usage
117
+
118
+ After initialization, the SDK works automatically in the background. You can also use the following APIs for manual instrumentation.
119
+
120
+ ### Manual Exception & Message Reporting
121
+
122
+ ```javascript
123
+ // Manually capture and report an Error
124
+ try {
125
+ throw new Error('Payment API parsing failed');
126
+ } catch (error) {
127
+ Sentry.captureException(error);
128
+ }
129
+
130
+ // Log a message
131
+ Sentry.captureMessage('User cancelled authorization', 'info');
132
+ ```
133
+
134
+ ### Context Enrichment (Context & Breadcrumbs)
135
+
136
+ ```javascript
137
+ // Set current user info
138
+ Sentry.setUser({
139
+ id: 'user_12345',
140
+ username: 'John Doe'
141
+ });
142
+
143
+ // Set global tags for filtering and analytics
144
+ Sentry.setTag('page_module', 'checkout_counter');
145
+
146
+ // Manually add a breadcrumb
147
+ Sentry.addBreadcrumb({
148
+ message: 'User tapped [Confirm Payment] button',
149
+ category: 'action',
150
+ level: 'info',
151
+ data: { cartId: 'c_888' }
152
+ });
153
+ ```
154
+
155
+ ### Custom Performance Measurement
156
+
157
+ ```javascript
158
+ // Mark start point
159
+ Sentry.addPerformanceMark('api-request-start');
160
+ // ... perform operation
161
+ Sentry.addPerformanceMark('api-request-end');
162
+
163
+ // Measure the interval
164
+ Sentry.measurePerformance('fetch-user-data', 'api-request-start', 'api-request-end');
165
+ ```
166
+
167
+ ### Dynamic Sampling (tracesSampler)
168
+
169
+ Beyond the global `sampleRate`, you can use the `tracesSampler` callback for fine-grained, per-page sampling control:
170
+
171
+ ```javascript
172
+ Sentry.init({
173
+ dsn: '...',
174
+ tracesSampler: ({ name, inheritOrSampleWith }) => {
175
+ // 100% sampling for critical pages
176
+ if (name.includes('pages/index') || name.includes('pages/pay')) {
177
+ return 1;
178
+ }
179
+ // Lower sampling for low-priority pages
180
+ if (name.includes('pages/about') || name.includes('pages/settings')) {
181
+ return 0.1;
182
+ }
183
+ // Inherit upstream decision or fall back to 50%
184
+ return inheritOrSampleWith(0.5);
185
+ },
186
+ });
187
+ ```
188
+
189
+ > **Note:** When `tracesSampler` is set, `tracesSampleRate` is ignored. `tracesSampler` takes priority.
190
+
191
+ ---
192
+
193
+ ## SourceMap Support
194
+
195
+ 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.
196
+
197
+ **Quick upload example:**
198
+
199
+ ```bash
200
+ sentry-cli releases files "my-miniapp@1.0.0" upload-sourcemaps ./dist \
201
+ --url-prefix "app:///" \
202
+ --ext js --ext map
203
+ ```
204
+
205
+ > For a complete end-to-end setup guide (build tool configs, CI/CD integration, verification & troubleshooting), see **[Source Map Configuration Guide](./docs/SOURCEMAP_GUIDE.md)**.
206
+
207
+ ---
208
+
209
+ ## User Feedback
210
+
211
+ In web environments, Sentry provides a built-in `showReportDialog()` popup. However, mini programs have no DOM, so this method is **not available**.
212
+
213
+ Instead, build a **native mini program form or modal** to collect user feedback, then submit it via `Sentry.captureFeedback()`:
214
+
215
+ ```javascript
216
+ const userMessage = 'The page is frozen, nothing responds';
217
+ const userName = 'John Doe';
218
+ const userEmail = 'john@example.com';
219
+
220
+ Sentry.captureFeedback({
221
+ message: userMessage,
222
+ name: userName,
223
+ email: userEmail,
224
+ // Optional: associate with a specific error event
225
+ // associatedEventId: 'abc123xyz...'
226
+ });
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Bundle Size Optimization (Zero Main Package Overhead)
232
+
233
+ Mini program "main package" size is limited (typically 2MB). `sentry-miniapp` includes the full `@sentry/core` engine and multi-platform adapters, totaling ~100KB.
234
+
235
+ If main package size is a concern, use **subpackage async loading** or **dynamic loading** to move the SDK entirely into a subpackage.
236
+
237
+ ### Option A: WeChat / Alipay (Recommended)
238
+
239
+ WeChat and Alipay natively support [subpackage async loading](https://developers.weixin.qq.com/miniprogram/dev/framework/subpackages/async.html).
240
+
241
+ ```javascript
242
+ // app.js
243
+ App({
244
+ onLaunch() {
245
+ require.async('./subpackageA/sentry-miniapp.js').then((Sentry) => {
246
+ Sentry.init({
247
+ dsn: 'https://xxxxxxxx@sentry.io/12345',
248
+ // ...other options
249
+ });
250
+ console.log('Sentry loaded and initialized successfully');
251
+ }).catch(err => {
252
+ console.error('Failed to load Sentry', err);
253
+ });
254
+ }
255
+ });
256
+ ```
257
+
258
+ *This way, Sentry's ~100KB is counted against `subpackageA`'s size — zero main package overhead!*
259
+
260
+ ### Option B: Other Platforms (ByteDance, Baidu, etc.)
261
+
262
+ For platforms that don't support `require.async`, use **subpackage predownload + dynamic loading**:
263
+
264
+ ```javascript
265
+ // ByteDance mini program example
266
+ App({
267
+ onLaunch() {
268
+ const loadTask = tt.loadSubpackage({
269
+ name: 'subpackageA',
270
+ success: () => {
271
+ const Sentry = require('./subpackageA/sentry-miniapp.js');
272
+ Sentry.init({ dsn: '...' });
273
+ }
274
+ });
275
+ }
276
+ });
277
+ ```
278
+
279
+ *Note: If using Taro / uni-app, you can use `import('sentry-miniapp')` dynamic import syntax — the framework handles cross-platform differences at compile time.*
280
+
281
+ ---
282
+
283
+ ## FAQ
284
+
285
+ ### 1. Do I need to manually report errors in `onError`?
286
+
287
+ **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.
288
+
289
+ If errors are not being reported, check:
290
+ 1. Whether the Sentry domain is in the mini program's trusted domain list.
291
+ 2. Whether `sampleRate` is set too low.
292
+ 3. Some WeChat DevTools environments don't trigger `onError` — test on a **real device**.
293
+
294
+ ### 2. Does this SDK support Session Replay?
295
+
296
+ **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.
297
+
298
+ ---
299
+
300
+ ## Documentation
301
+
302
+ | Document | Description |
303
+ |----------|-------------|
304
+ | [SourceMap Configuration Guide](./docs/SOURCEMAP_GUIDE.md) | End-to-end SourceMap setup, build tools, CI/CD, verification & troubleshooting |
305
+ | [Multi-Platform Compatibility Report](./docs/MultiPlatformCompatibilityReport.md) | Platform API compatibility matrix and differences |
306
+ | [Example Project](./examples/wxapp/) | Complete WeChat mini program integration example |
307
+ | [Development Guide](./DEVELOPMENT.md) | Local development setup and debugging |
308
+ | [Contributing Guide](./CONTRIBUTING.md) | How to contribute to the project |
309
+
310
+ ---
311
+
312
+ ## Contributing
313
+
314
+ We welcome Pull Requests and Issues!
315
+
316
+ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
317
+
318
+ Quick start:
319
+
320
+ 1. `npm install` — install dependencies
321
+ 2. `npm run dev` — start watch mode
322
+ 3. `npm run test:all` — run full test suite (unit + integration)
323
+
324
+ ---
325
+
326
+ ## Community
327
+
328
+ Have questions or want to discuss mini program monitoring? Join our community.
329
+
330
+ 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:
331
+
332
+ <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);" />
333
+
334
+ ---
335
+
336
+ ## License
337
+
338
+ [MIT](./LICENSE)
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Sentry Miniapp SDK
1
+ # Sentry Miniapp SDK — 小程序监控 SDK
2
2
 
3
3
  ![npm version](https://img.shields.io/npm/v/sentry-miniapp)
4
4
  ![npm download](https://img.shields.io/npm/dm/sentry-miniapp)
@@ -7,7 +7,9 @@
7
7
  ![test coverage](https://img.shields.io/badge/test%20coverage-100%25-brightgreen.svg)
8
8
  ![license](https://img.shields.io/github/license/lizhiyao/sentry-miniapp)
9
9
 
10
- 一个基于 `@sentry/core` (v10.45.0) 核心构建的**多端小程序异常与性能监控 SDK**。旨在为小程序开发者提供与 Web 端一致的、强大且现代的 Sentry 监控体验。
10
+ 简体中文 | [English](./README.en.md)
11
+
12
+ 一个基于 `@sentry/core` (v10.45.0) 核心构建的**小程序监控 SDK**,提供**异常监控**、**性能监控**、离线缓存、分布式追踪等能力。支持微信、支付宝、字节跳动、百度、QQ、钉钉、快手等多端小程序及 Taro / uni-app 等跨端框架。
11
13
 
12
14
  > **💡 版本说明**
13
15
  >
@@ -27,6 +29,10 @@
27
29
  - **⚡ 深度性能监控**:集成小程序 Performance API,全面采集导航性能(FCP/LCP)、渲染性能、资源加载耗时及用户自定义性能标记。
28
30
  - **�️ 智能降噪与过滤**:内置强大的错误去重和采样率控制机制,避免日志风暴。
29
31
  - **🔧 跨端框架友好**:完美支持在 Taro、uni-app 等第三方多端编译框架中集成使用。
32
+ - **🔗 分布式追踪**:自动在网络请求中注入 `sentry-trace` / `baggage` 头,串联小程序与后端服务的完整调用链。
33
+ - **📊 Session 健康监控**:自动管理会话生命周期,在 Sentry Release Health 面板展示崩溃率和会话健康数据。
34
+ - **📶 网络状态监控**:实时追踪网络变化(WiFi/4G/离线),帮助排查网络相关的异常。
35
+ - **🔍 堆栈解析**:内置多平台堆栈解析器,支持 V8/Safari/JavaScriptCore 格式,配合 SourceMap 精准定位错误。
30
36
 
31
37
  ---
32
38
 
@@ -79,7 +85,15 @@ Sentry.init({
79
85
 
80
86
  // --- 性能与采样率 ---
81
87
  sampleRate: 1.0, // 异常上报采样率 (0.0 - 1.0)
82
-
88
+
89
+ // --- 分布式追踪 ---
90
+ enableTracePropagation: true, // [新增] 自动在请求头中注入 sentry-trace/baggage(默认 true)
91
+ tracePropagationTargets: ['api.example.com'], // [新增] 仅对指定域名注入追踪头(为空则全部注入)
92
+
93
+ // --- Session 与网络监控 ---
94
+ enableAutoSessionTracking: true, // [新增] 自动管理 Session 生命周期(默认 true)
95
+ enableNetworkStatusMonitoring: true, // [新增] 实时监控网络状态变化(默认 true)
96
+
83
97
  // 可选:性能监控配置
84
98
  integrations: [
85
99
  Sentry.performanceIntegration({
@@ -151,26 +165,45 @@ Sentry.addPerformanceMark('api-request-end');
151
165
  Sentry.measurePerformance('fetch-user-data', 'api-request-start', 'api-request-end');
152
166
  ```
153
167
 
154
- ---
168
+ ### 动态采样 (tracesSampler)
155
169
 
156
- ## 🗺️ Source Map 支持与配置
170
+ 除了全局 `sampleRate`,你还可以通过 `tracesSampler` 回调实现按页面、按场景的精细化采样控制:
157
171
 
158
- 在小程序中,报错堆栈的路径通常是各种虚拟路径(如 `appservice/pages/index.js`),这导致直接上传的 Source Map 无法被 Sentry 正确解析。
172
+ ```javascript
173
+ Sentry.init({
174
+ dsn: '...',
175
+ tracesSampler: ({ name, inheritOrSampleWith }) => {
176
+ // 核心页面 100% 采样
177
+ if (name.includes('pages/index') || name.includes('pages/pay')) {
178
+ return 1;
179
+ }
180
+ // 低优先级页面降低采样率
181
+ if (name.includes('pages/about') || name.includes('pages/settings')) {
182
+ return 0.1;
183
+ }
184
+ // 继承上游采样决策,或使用默认 50% 采样率
185
+ return inheritOrSampleWith(0.5);
186
+ },
187
+ });
188
+ ```
189
+
190
+ > **注意:** 设置 `tracesSampler` 后,`tracesSampleRate` 将被忽略。`tracesSampler` 的优先级更高。
159
191
 
160
- SDK 内部已经为您解决了这个痛点:
161
- 只要在 `Sentry.init` 时开启了 `enableSourceMap: true`(默认开启),SDK 会在报错时自动拦截并抹平各平台的虚拟路径,统一替换为标准前缀 `app:///`。
192
+ ---
193
+
194
+ ## 🗺️ Source Map 支持与配置
162
195
 
163
- 您**只需要在打包上传 Source Map 时,确保配置的 `url-prefix` `app:///` 即可**。
196
+ SDK 内置了多端堆栈路径归一化能力(`enableSourceMap: true`,默认开启),自动将各平台虚拟路径转换为统一的 `app:///` 前缀,配合 sentry-cli 即可实现 Source Map 解析。
164
197
 
165
- **使用 sentry-cli 上传示例:**
198
+ **快速上传示例:**
166
199
 
167
200
  ```bash
168
- sentry-cli releases files "your-project-release-id" upload-sourcemaps ./dist \
169
- --url-prefix "app:///" \
170
- --ext .js --ext .map
201
+ sentry-cli releases files “my-miniapp@1.0.0” upload-sourcemaps ./dist \
202
+ --url-prefix app:///” \
203
+ --ext js --ext map
171
204
  ```
172
205
 
173
- *(注:在微信开发者工具上传代码时,请**务必关闭**工具自带的“ES6转ES5”和“代码压缩”功能,将这些工作交给 Webpack/Vite 等构建工具,以防行列号错位。)*
206
+ > 详细的端到端配置指南(包括各构建工具配置、CI/CD 集成、验证与排查),请参阅 **[Source Map 完整配置指南](./docs/SOURCEMAP_GUIDE.md)**。
174
207
 
175
208
  ---
176
209
 
@@ -200,7 +233,7 @@ Sentry.captureFeedback({
200
233
 
201
234
  ## 📦 主包体积优化 (0KB 主包占用方案)
202
235
 
203
- 小程序的“主包体积”非常宝贵(通常限制在 2MB 以内)。`sentry-miniapp` 由于集成了完整的 `@sentry/core` 核心引擎和多端适配,原始体积约在 200KB 左右。
236
+ 小程序的“主包体积”非常宝贵(通常限制在 2MB 以内)。`sentry-miniapp` 由于集成了完整的 `@sentry/core` 核心引擎和多端适配,原始体积约在 100KB 左右。
204
237
 
205
238
  如果您非常在意主包体积,**强烈建议使用平台提供的「分包异步化」或「动态加载」特性**,将 SDK 的体积完全转移到分包中。
206
239
 
@@ -231,7 +264,7 @@ App({
231
264
  });
232
265
  ```
233
266
 
234
- *通过这种方式,Sentry 的 200KB 体积将**全部算入 `subpackageA` 的分包体积**,主包占用为 0!*
267
+ *通过这种方式,Sentry 的 100KB 体积将**全部算入 `subpackageA` 的分包体积**,主包占用为 0!*
235
268
 
236
269
  ### 方案 B:其他小程序平台(字节、百度等)
237
270
 
@@ -279,6 +312,18 @@ Sentry 官方的 Replay 功能强依赖于浏览器标准 DOM 环境(通过 rr
279
312
 
280
313
  ---
281
314
 
315
+ ## 📖 文档导航
316
+
317
+ | 文档 | 说明 |
318
+ |------|------|
319
+ | [Source Map 完整配置指南](./docs/SOURCEMAP_GUIDE.md) | 端到端 Source Map 配置,覆盖各构建工具、CI/CD 集成、验证与排查 |
320
+ | [多端兼容性报告](./docs/MultiPlatformCompatibilityReport.md) | 各小程序平台 API 兼容性矩阵与差异说明 |
321
+ | [示例项目](./examples/wxapp/) | 微信小程序完整接入示例 |
322
+ | [开发指南](./DEVELOPMENT.md) | 本地开发环境搭建与调试 |
323
+ | [贡献指南](./CONTRIBUTING.md) | 如何参与项目贡献 |
324
+
325
+ ---
326
+
282
327
  ## 🤝 参与贡献
283
328
 
284
329
  我们非常欢迎开发者提交 `Pull Request` 或通过 `Issues` 提出宝贵意见!