@error-reporting/vue 0.0.0-stage → 0.1.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.
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { App } from 'vue'
2
+ import type { CaptureContext, Options } from '@error-reporting/core'
3
+
4
+ export type { CaptureContext, Options, ReportEvent } from '@error-reporting/core'
5
+ export function init(options: Options & { app: App }): void
6
+ export function captureException(error: unknown, context?: CaptureContext): string
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "@error-reporting/vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Error Reporting Platform SDK for Vue 3",
5
+ "type": "module",
6
+ "exports": { ".": { "types": "./index.d.ts", "default": "./src/index.js" } },
7
+ "files": ["src", "index.d.ts"],
8
+ "dependencies": { "@error-reporting/core": "0.1.0", "@sentry/vue": "^11.17.0" },
9
+ "peerDependencies": { "vue": "^3.0.0" },
10
+ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
11
+ "repository": { "type": "git", "url": "git+https://gitee.com/qglove/error-reporting-platform.git", "directory": "packages/javascript/vue" }
12
+ }
package/src/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import * as Sentry from '@sentry/vue'
2
+ import { createReportOptions } from '@error-reporting/core'
3
+
4
+ let initialized = false
5
+
6
+ /** 在 Vue 3 应用挂载前安装组件和浏览器全局异常监听。
7
+ * @param {import('@error-reporting/core').Options & { app: import('vue').App }} options Vue 应用及错误上报配置。
8
+ */
9
+ export function init({ app, ...options }) {
10
+ if (!app?.config) {
11
+ throw new Error('A Vue 3 app is required')
12
+ }
13
+
14
+ if (initialized) {
15
+ throw new Error('Vue error reporting is already initialized')
16
+ }
17
+
18
+ Sentry.init({ app, attachProps: false, ...createReportOptions(options, 'vue') })
19
+
20
+ initialized = true
21
+ }
22
+
23
+ /** 上报已被业务接住的错误。
24
+ * @param {unknown} error 原始异常或拒绝原因。
25
+ * @param {import('@error-reporting/core').CaptureContext} context 诊断用请求编号。
26
+ */
27
+ export function captureException(error, context = {}) {
28
+ return Sentry.captureException(error, context.requestId ? { tags: { request_id: context.requestId } } : undefined)
29
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.