miaoda-react-devkit 0.1.1-beta.6 → 0.1.1-beta.8

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/dist/index.cjs CHANGED
@@ -461,54 +461,8 @@ var PostMessageSubscriber = class {
461
461
  };
462
462
  this.send(msg, "*");
463
463
  }
464
- onNetworkRequest({ method, url, statusCode, requestBody, responseBody, isError, cause }) {
465
- const isClientError = statusCode != null && statusCode >= 400 && statusCode < 500;
466
- if (!isError && !isClientError) return;
467
- const urlPath = extractUrlPath(url);
468
- if (isError) {
469
- const causeDesc = cause != null ? String(cause) : "NetworkError";
470
- const errorMessage = `${method} ${urlPath} failed: ${causeDesc}`;
471
- const msg = {
472
- type: "GLOBAL_ERROR",
473
- message: errorMessage,
474
- error: cause != null ? { name: cause.name, message: cause.message, stack: cause.stack } : null,
475
- errorData: {
476
- name: cause?.name ?? "NetworkError",
477
- message: cause?.message ?? causeDesc,
478
- stack: cause?.stack ?? null,
479
- fileName: url,
480
- lineNumber: 0,
481
- columnNumber: 0,
482
- httpPath: urlPath,
483
- httpStatus: 0,
484
- httpMethod: method,
485
- requestBody: requestBody ?? "",
486
- responseBody: ""
487
- }
488
- };
489
- this.send(msg, "*");
490
- } else {
491
- const errorMessage = `${method} ${urlPath} -> ${statusCode}`;
492
- const msg = {
493
- type: "GLOBAL_ERROR",
494
- message: errorMessage,
495
- error: null,
496
- errorData: {
497
- name: "HTTPClientError",
498
- message: errorMessage,
499
- stack: null,
500
- fileName: url,
501
- lineNumber: 0,
502
- columnNumber: 0,
503
- httpPath: urlPath,
504
- httpStatus: statusCode,
505
- httpMethod: method,
506
- requestBody: requestBody ?? "",
507
- responseBody: responseBody ?? ""
508
- }
509
- };
510
- this.send(msg, "*");
511
- }
464
+ // postMessage 场景不需要上报 network 日志
465
+ onNetworkRequest(_info) {
512
466
  }
513
467
  onPgRestWhitelistError({ type, method, url, statusCode, pgRestError, requestBody, responseBody }) {
514
468
  const urlPath = extractUrlPath(url);
package/dist/index.js CHANGED
@@ -429,54 +429,8 @@ var PostMessageSubscriber = class {
429
429
  };
430
430
  this.send(msg, "*");
431
431
  }
432
- onNetworkRequest({ method, url, statusCode, requestBody, responseBody, isError, cause }) {
433
- const isClientError = statusCode != null && statusCode >= 400 && statusCode < 500;
434
- if (!isError && !isClientError) return;
435
- const urlPath = extractUrlPath(url);
436
- if (isError) {
437
- const causeDesc = cause != null ? String(cause) : "NetworkError";
438
- const errorMessage = `${method} ${urlPath} failed: ${causeDesc}`;
439
- const msg = {
440
- type: "GLOBAL_ERROR",
441
- message: errorMessage,
442
- error: cause != null ? { name: cause.name, message: cause.message, stack: cause.stack } : null,
443
- errorData: {
444
- name: cause?.name ?? "NetworkError",
445
- message: cause?.message ?? causeDesc,
446
- stack: cause?.stack ?? null,
447
- fileName: url,
448
- lineNumber: 0,
449
- columnNumber: 0,
450
- httpPath: urlPath,
451
- httpStatus: 0,
452
- httpMethod: method,
453
- requestBody: requestBody ?? "",
454
- responseBody: ""
455
- }
456
- };
457
- this.send(msg, "*");
458
- } else {
459
- const errorMessage = `${method} ${urlPath} -> ${statusCode}`;
460
- const msg = {
461
- type: "GLOBAL_ERROR",
462
- message: errorMessage,
463
- error: null,
464
- errorData: {
465
- name: "HTTPClientError",
466
- message: errorMessage,
467
- stack: null,
468
- fileName: url,
469
- lineNumber: 0,
470
- columnNumber: 0,
471
- httpPath: urlPath,
472
- httpStatus: statusCode,
473
- httpMethod: method,
474
- requestBody: requestBody ?? "",
475
- responseBody: responseBody ?? ""
476
- }
477
- };
478
- this.send(msg, "*");
479
- }
432
+ // postMessage 场景不需要上报 network 日志
433
+ onNetworkRequest(_info) {
480
434
  }
481
435
  onPgRestWhitelistError({ type, method, url, statusCode, pgRestError, requestBody, responseBody }) {
482
436
  const urlPath = extractUrlPath(url);
@@ -0,0 +1,78 @@
1
+ // src/stubs/sentry-react-noop-stub.ts
2
+ var init = (_options) => {
3
+ };
4
+ var browserTracingIntegration = () => ({});
5
+ var captureException = (_err) => "";
6
+ var captureMessage = (_msg) => "";
7
+ var captureEvent = (_event) => "";
8
+ var addBreadcrumb = (_breadcrumb) => {
9
+ };
10
+ var setUser = (_user) => {
11
+ };
12
+ var setTag = (_key, _value) => {
13
+ };
14
+ var setTags = (_tags) => {
15
+ };
16
+ var setContext = (_key, _ctx) => {
17
+ };
18
+ var setExtra = (_key, _value) => {
19
+ };
20
+ var setExtras = (_extras) => {
21
+ };
22
+ var withScope = (cb) => {
23
+ cb({});
24
+ };
25
+ var withIsolationScope = (cb) => {
26
+ cb({});
27
+ };
28
+ var startSpan = (_opts, cb) => cb();
29
+ var getClient = () => void 0;
30
+ var flush = () => Promise.resolve(true);
31
+ var close = () => Promise.resolve(true);
32
+ var lastEventId = () => void 0;
33
+ var SDK_VERSION = "0.0.0-stub";
34
+ var ErrorBoundary = ({ children }) => children ?? null;
35
+ var withErrorBoundary = (Component) => Component;
36
+ var withProfiler = (Component) => Component;
37
+ var useProfiler = (_name) => {
38
+ };
39
+ var Profiler = ({ children }) => children ?? null;
40
+ var withSentryRouting = (Component) => Component;
41
+ var withSentryReactRouterV6Routing = (Component) => Component;
42
+ var wrapCreateBrowserRouterV6 = (fn) => fn;
43
+ var wrapCreateBrowserRouterV7 = (fn) => fn;
44
+ var reactRouterV6BrowserTracingIntegration = () => ({});
45
+ var reactRouterV7BrowserTracingIntegration = () => ({});
46
+ export {
47
+ ErrorBoundary,
48
+ Profiler,
49
+ SDK_VERSION,
50
+ addBreadcrumb,
51
+ browserTracingIntegration,
52
+ captureEvent,
53
+ captureException,
54
+ captureMessage,
55
+ close,
56
+ flush,
57
+ getClient,
58
+ init,
59
+ lastEventId,
60
+ reactRouterV6BrowserTracingIntegration,
61
+ reactRouterV7BrowserTracingIntegration,
62
+ setContext,
63
+ setExtra,
64
+ setExtras,
65
+ setTag,
66
+ setTags,
67
+ setUser,
68
+ startSpan,
69
+ useProfiler,
70
+ withErrorBoundary,
71
+ withIsolationScope,
72
+ withProfiler,
73
+ withScope,
74
+ withSentryReactRouterV6Routing,
75
+ withSentryRouting,
76
+ wrapCreateBrowserRouterV6,
77
+ wrapCreateBrowserRouterV7
78
+ };
@@ -432,54 +432,8 @@ var PostMessageSubscriber = class {
432
432
  };
433
433
  this.send(msg, "*");
434
434
  }
435
- onNetworkRequest({ method, url, statusCode, requestBody, responseBody, isError, cause }) {
436
- const isClientError = statusCode != null && statusCode >= 400 && statusCode < 500;
437
- if (!isError && !isClientError) return;
438
- const urlPath = extractUrlPath(url);
439
- if (isError) {
440
- const causeDesc = cause != null ? String(cause) : "NetworkError";
441
- const errorMessage = `${method} ${urlPath} failed: ${causeDesc}`;
442
- const msg = {
443
- type: "GLOBAL_ERROR",
444
- message: errorMessage,
445
- error: cause != null ? { name: cause.name, message: cause.message, stack: cause.stack } : null,
446
- errorData: {
447
- name: cause?.name ?? "NetworkError",
448
- message: cause?.message ?? causeDesc,
449
- stack: cause?.stack ?? null,
450
- fileName: url,
451
- lineNumber: 0,
452
- columnNumber: 0,
453
- httpPath: urlPath,
454
- httpStatus: 0,
455
- httpMethod: method,
456
- requestBody: requestBody ?? "",
457
- responseBody: ""
458
- }
459
- };
460
- this.send(msg, "*");
461
- } else {
462
- const errorMessage = `${method} ${urlPath} -> ${statusCode}`;
463
- const msg = {
464
- type: "GLOBAL_ERROR",
465
- message: errorMessage,
466
- error: null,
467
- errorData: {
468
- name: "HTTPClientError",
469
- message: errorMessage,
470
- stack: null,
471
- fileName: url,
472
- lineNumber: 0,
473
- columnNumber: 0,
474
- httpPath: urlPath,
475
- httpStatus: statusCode,
476
- httpMethod: method,
477
- requestBody: requestBody ?? "",
478
- responseBody: responseBody ?? ""
479
- }
480
- };
481
- this.send(msg, "*");
482
- }
435
+ // postMessage 场景不需要上报 network 日志
436
+ onNetworkRequest(_info) {
483
437
  }
484
438
  onPgRestWhitelistError({ type, method, url, statusCode, pgRestError, requestBody, responseBody }) {
485
439
  const urlPath = extractUrlPath(url);
@@ -544,7 +498,8 @@ function createPostMessageSubscriber(send) {
544
498
  // src/stubs/sentry-react-stub.ts
545
499
  export * from "@sentry/react";
546
500
  var STUB_DSN = "https://stubPublicKey@o0.ingest.sentry.io/0";
547
- var OVERRIDE_DSN = typeof process !== "undefined" && process.env["SENTRY_OVERRIDE_DSN"] ? process.env["SENTRY_OVERRIDE_DSN"] : STUB_DSN;
501
+ var OVERRIDE_DSN = import.meta.env.VITE_SENTRY_DSN || STUB_DSN;
502
+ var OVERRIDE_ENVIRONMENT = import.meta.env.VITE_SENTRY_ENV;
548
503
  var _subscribers = [createPostMessageSubscriber()];
549
504
  function configureStubSubscribers(subscribers) {
550
505
  _subscribers = subscribers;
@@ -562,6 +517,7 @@ var init2 = (options) => {
562
517
  const result = RealSentry.init({
563
518
  ...options,
564
519
  dsn: OVERRIDE_DSN,
520
+ environment: OVERRIDE_ENVIRONMENT,
565
521
  beforeSend(event, hint) {
566
522
  const processed = capture.beforeSend(event, hint);
567
523
  return upstreamBeforeSend ? upstreamBeforeSend(processed, hint) : processed;
@@ -572,6 +528,15 @@ var init2 = (options) => {
572
528
  return upstreamBeforeBreadcrumb ? upstreamBeforeBreadcrumb(processed, hint) : processed;
573
529
  }
574
530
  });
531
+ const stubTags = {
532
+ app_id: import.meta.env.VITE_APP_ID,
533
+ environment: OVERRIDE_ENVIRONMENT
534
+ };
535
+ for (const [key, value] of Object.entries(stubTags)) {
536
+ if (value) {
537
+ RealSentry.setTag(key, value);
538
+ }
539
+ }
575
540
  capture.installNetworkObserver();
576
541
  capture.installConsoleObserver();
577
542
  return result;
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var vite_exports = {};
32
32
  __export(vite_exports, {
33
33
  hmrTogglePlugin: () => hmrTogglePlugin,
34
+ withSentryBuild: () => withSentryBuild,
34
35
  withSentryStub: () => withSentryStub
35
36
  });
36
37
  module.exports = __toCommonJS(vite_exports);
@@ -60,6 +61,24 @@ function withSentryStub() {
60
61
  };
61
62
  }
62
63
 
64
+ // src/vite/withSentryBuild.ts
65
+ var import_node_path2 = __toESM(require("path"), 1);
66
+ var import_node_url2 = require("url");
67
+ var SENTRY_MODULE2 = "@sentry/react";
68
+ var _dirname2 = import_node_path2.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
69
+ var STUB_PATH2 = import_node_path2.default.resolve(_dirname2, "../stubs/sentry-react-noop-stub.js");
70
+ function withSentryBuild() {
71
+ return {
72
+ name: "miaoda-devkit:sentry-build",
73
+ enforce: "pre",
74
+ apply: "build",
75
+ resolveId(id) {
76
+ if (id === SENTRY_MODULE2) return STUB_PATH2;
77
+ return null;
78
+ }
79
+ };
80
+ }
81
+
63
82
  // src/vite/hmrTogglePlugin.ts
64
83
  function hmrTogglePlugin() {
65
84
  return {
@@ -120,5 +139,6 @@ function hmrTogglePlugin() {
120
139
  // Annotate the CommonJS export names for ESM import in node:
121
140
  0 && (module.exports = {
122
141
  hmrTogglePlugin,
142
+ withSentryBuild,
123
143
  withSentryStub
124
144
  });
@@ -9,6 +9,8 @@ import { Plugin } from 'vite';
9
9
 
10
10
  declare function withSentryStub(): Plugin;
11
11
 
12
+ declare function withSentryBuild(): Plugin;
13
+
12
14
  /**
13
15
  * 云端 dev server 专用:HMR 开关 + 手动 reload 控制接口。
14
16
  *
@@ -21,4 +23,4 @@ declare function withSentryStub(): Plugin;
21
23
  */
22
24
  declare function hmrTogglePlugin(): Plugin;
23
25
 
24
- export { hmrTogglePlugin, withSentryStub };
26
+ export { hmrTogglePlugin, withSentryBuild, withSentryStub };
@@ -9,6 +9,8 @@ import { Plugin } from 'vite';
9
9
 
10
10
  declare function withSentryStub(): Plugin;
11
11
 
12
+ declare function withSentryBuild(): Plugin;
13
+
12
14
  /**
13
15
  * 云端 dev server 专用:HMR 开关 + 手动 reload 控制接口。
14
16
  *
@@ -21,4 +23,4 @@ declare function withSentryStub(): Plugin;
21
23
  */
22
24
  declare function hmrTogglePlugin(): Plugin;
23
25
 
24
- export { hmrTogglePlugin, withSentryStub };
26
+ export { hmrTogglePlugin, withSentryBuild, withSentryStub };
@@ -19,6 +19,24 @@ function withSentryStub() {
19
19
  };
20
20
  }
21
21
 
22
+ // src/vite/withSentryBuild.ts
23
+ import path2 from "path";
24
+ import { fileURLToPath as fileURLToPath2 } from "url";
25
+ var SENTRY_MODULE2 = "@sentry/react";
26
+ var _dirname2 = path2.dirname(fileURLToPath2(import.meta.url));
27
+ var STUB_PATH2 = path2.resolve(_dirname2, "../stubs/sentry-react-noop-stub.js");
28
+ function withSentryBuild() {
29
+ return {
30
+ name: "miaoda-devkit:sentry-build",
31
+ enforce: "pre",
32
+ apply: "build",
33
+ resolveId(id) {
34
+ if (id === SENTRY_MODULE2) return STUB_PATH2;
35
+ return null;
36
+ }
37
+ };
38
+ }
39
+
22
40
  // src/vite/hmrTogglePlugin.ts
23
41
  function hmrTogglePlugin() {
24
42
  return {
@@ -78,5 +96,6 @@ function hmrTogglePlugin() {
78
96
  }
79
97
  export {
80
98
  hmrTogglePlugin,
99
+ withSentryBuild,
81
100
  withSentryStub
82
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-react-devkit",
3
- "version": "0.1.1-beta.6",
3
+ "version": "0.1.1-beta.8",
4
4
  "description": "React admin 应用开发工具集",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/README.md DELETED
@@ -1,181 +0,0 @@
1
- # miaoda-react-devkit
2
-
3
- React 管理后台开发工具集。提供 Sentry 开发环境 stub、错误桥接上报,以及云端 dev server 的 vite 配置。
4
-
5
- ## 功能
6
-
7
- 开发模式下,`@sentry/react` 会被自动替换为 stub:
8
-
9
- - DSN 替换为无害的 stub 端点(project id = 0),错误不会上报到真实 Sentry
10
- - 捕获到错误时在控制台打印 `[SentryStub]` 前缀的 warn,含错误消息、错误类型和调用栈
11
- - 每个 fetch / XHR 请求完成后触发 `onNetworkRequest` 回调,可拿到请求体和响应体文本
12
- - 4xx 请求和网络层失败(fetch 抛出异常)通过 `window.parent.postMessage` 向父窗口发送 `GLOBAL_ERROR` 消息
13
- - 每次 `console.xxx` 调用触发 `onConsole` 回调,原始输出不受影响,无递归风险
14
- - 用户传入的 `beforeSend` / `beforeBreadcrumb` 回调仍会被链式调用
15
- - SSE / 流式响应自动跳过,不消费原始 stream,不影响业务代码
16
- - 生产构建时插件不生效,恢复正常上报
17
-
18
- ## 目录结构
19
-
20
- ```
21
- packages/devkit/
22
- ├── src/
23
- │ ├── index.ts 主入口,导出所有公共 API
24
- │ ├── sentry/ Sentry 事件捕获核心
25
- │ │ ├── SentryCapture.ts SentryCapture 类,协调三类观测器
26
- │ │ ├── consoleObserver.ts 控制台日志捕获与过滤
27
- │ │ ├── networkObserver.ts 网络请求捕获(fetch / XHR)
28
- │ │ └── types.ts 共享类型定义(IErrorCaptureInfo 等)
29
- │ ├── bridge/ 错误桥接:向父窗口发送 postMessage
30
- │ │ └── errorBridge.ts createErrorBridge,格式对齐 vite-plugin-monitor
31
- │ ├── vite/ Vite 插件
32
- │ │ ├── index.ts vite 插件导出
33
- │ │ ├── withSentryStub.ts dev 模式下将 @sentry/react 重定向到 stub
34
- │ │ └── hmrTogglePlugin.ts HMR 开关及手动 reload 控制接口
35
- │ └── stubs/
36
- │ └── sentry-react-stub.ts dev 模式 stub,透传真实 Sentry API
37
- └── cloud/
38
- └── vite.config.ts 云端 dev server 专用 vite 配置
39
- ```
40
-
41
- ## 使用
42
-
43
- ### 本地开发
44
-
45
- 在项目 `vite.config.ts` 中注册插件(需放在第一位):
46
-
47
- ```ts
48
- import { withSentryStub } from 'miaoda-react-devkit/vite';
49
-
50
- export default defineConfig({
51
- plugins: [withSentryStub(), react()],
52
- });
53
- ```
54
-
55
- 应用代码中正常使用 `@sentry/react`,无需任何改动。
56
-
57
- ### 云端 dev server
58
-
59
- 云端 dev server 指定 `cloud/vite.config.ts` 启动,项目自身的 `vite.config.ts` 无需改动:
60
-
61
- ```bash
62
- vite --config node_modules/miaoda-react-devkit/cloud/vite.config.ts
63
- ```
64
-
65
- `cloud/vite.config.ts` 通过 `loadConfigFromFile` 加载项目的 `vite.config.ts`,再用 `mergeConfig` 追加云端专用插件:
66
-
67
- | 插件 | 说明 |
68
- |------|------|
69
- | `withSentryStub` **或** `monitorPlugin` | 二选一,见下方说明 |
70
- | `makeTagger` | DOM 节点打标(仅 web 类型) |
71
- | `injectedGuiListenerPlugin` | 注入云端 GUI 监听脚本 |
72
- | `injectOnErrorPlugin` | 全局错误捕获 |
73
- | `hmrTogglePlugin` | HMR 开关及手动 reload 控制接口 |
74
-
75
- **Sentry 插件自动选择**:启动时扫描项目入口文件(`src/main.tsx` 等),若检测到 `import ... from '@sentry/react'`,则使用 `withSentryStub`(新架构:项目自行调用 `Sentry.init()`,stub 拦截 dev 上报);否则使用 `monitorPlugin`(旧架构:通过 CDN 脚本注入 Sentry)。两者互斥,不会同时生效。
76
-
77
- 启动前由 `ViteDevServerStrategy` 通过环境变量传入参数:
78
-
79
- | 环境变量 | 说明 |
80
- |----------|------|
81
- | `DEVKIT_APP_TYPE` | `'web'` 或 `'freestyle'`,决定是否注入 `makeTagger()` |
82
- | `DEVKIT_CDN_HOST` | CDN 域名 |
83
- | `DEVKIT_ENV` | 部署环境(`'online'` \| `'dev'` \| `'qa'` 等) |
84
- | `DEVKIT_SENTRY_DSN` | 云端 Sentry DSN |
85
- | `DEVKIT_MIAODA_ENV` | miaoda 环境标识 |
86
- | `DEVKIT_APP_ID` | 应用 ID |
87
-
88
- ### 自定义观测回调(可选)
89
-
90
- ```ts
91
- import * as Sentry from '@sentry/react';
92
- import { SentryCapture, DEFAULT_CONSOLE_FILTER_KEYWORDS, DEFAULT_IGNORE_URLS } from 'miaoda-react-devkit';
93
-
94
- const capture = new SentryCapture({
95
- consoleFilterKeywords: DEFAULT_CONSOLE_FILTER_KEYWORDS,
96
- ignoreUrls: DEFAULT_IGNORE_URLS,
97
- onError(info) {
98
- console.warn('错误:', info.errorName, info.message);
99
- console.warn('位置:', info.fileName, info.lineNumber, info.columnNumber);
100
- },
101
- onNetworkRequest(info) {
102
- console.log(`[${info.type}] ${info.method} ${info.url} → ${info.statusCode}`);
103
- if (info.requestBody) console.log('请求体:', info.requestBody);
104
- if (info.responseBody) console.log('响应体:', info.responseBody);
105
- if (info.cause) console.error('网络失败:', info.cause);
106
- },
107
- onConsole({ level, args }) {
108
- console.debug(`[console.${level}]`, ...args);
109
- },
110
- });
111
-
112
- Sentry.init({
113
- dsn: '...',
114
- beforeSend: capture.beforeSend,
115
- beforeBreadcrumb: capture.beforeBreadcrumb,
116
- });
117
-
118
- capture.installNetworkObserver();
119
- capture.installConsoleObserver();
120
- ```
121
-
122
- ### 单独使用 ErrorBridge
123
-
124
- `createErrorBridge` 可独立于 `SentryCapture` 使用,也可注入自定义 `send` 函数便于测试:
125
-
126
- ```ts
127
- import { createErrorBridge } from 'miaoda-react-devkit';
128
-
129
- // 默认:window.parent.postMessage
130
- const bridge = createErrorBridge();
131
-
132
- // 自定义(测试或特殊宿主环境)
133
- const bridge = createErrorBridge((msg, origin) => {
134
- customChannel.send(msg);
135
- });
136
- ```
137
-
138
- `IGlobalErrorMessage` 格式与 `vite-plugin-monitor` 保持一致,接收端可统一处理两种来源的错误消息。
139
-
140
- ## 类型参考
141
-
142
- ### IErrorCaptureInfo
143
-
144
- | 字段 | 类型 | 说明 |
145
- |------|------|------|
146
- | `message` | `string` | 错误消息 |
147
- | `stack` | `string \| undefined` | 完整调用栈文本 |
148
- | `errorName` | `string \| undefined` | 错误类型名,如 `'TypeError'`、`'RangeError'` |
149
- | `fileName` | `string \| undefined` | 抛出错误的文件路径(来自 Sentry stack frame) |
150
- | `lineNumber` | `number \| undefined` | 行号 |
151
- | `columnNumber` | `number \| undefined` | 列号 |
152
- | `componentStack` | `string \| undefined` | React 组件调用栈(ErrorBoundary 提供) |
153
- | `mechanismType` | `string \| null \| undefined` | 捕获方式,如 `'instrument'`、`'onerror'` |
154
-
155
- ### INetworkRequestInfo
156
-
157
- | 字段 | 类型 | 说明 |
158
- |------|------|------|
159
- | `type` | `'fetch' \| 'xhr'` | 请求类型 |
160
- | `method` | `string` | HTTP 方法 |
161
- | `url` | `string` | 请求 URL |
162
- | `statusCode` | `number \| null` | HTTP 状态码,网络层失败时为 null |
163
- | `requestBody` | `string \| undefined` | 请求体文本,Blob/ArrayBuffer 等二进制类型为 undefined |
164
- | `responseBody` | `string \| undefined` | 响应体文本,SSE 流式响应为 `'[streaming response - not captured]'` |
165
- | `isError` | `boolean` | 网络层失败(未收到 HTTP 响应)时为 true |
166
- | `cause` | `Error \| undefined` | 网络层失败时的原始 Error(仅 fetch 可用;XHR 无法获取) |
167
-
168
- ## 其他环境变量
169
-
170
- | 变量 | 说明 |
171
- |------|------|
172
- | `SENTRY_OVERRIDE_DSN` | 覆盖 stub DSN,可指向本地 Sentry Relay |
173
- | `VITE_SENTRY_STUB_LOG` | 设为 `'true'` 时开启 stub 日志输出(仅 E2E 测试使用) |
174
-
175
- ## 构建
176
-
177
- ```bash
178
- pnpm build
179
- ```
180
-
181
- E2E 测试见 `../devkit-e2e`。