diff --git a/client/web/plugins/com.msgbyte.sentry/manifest.json b/client/web/plugins/com.msgbyte.sentry/manifest.json new file mode 100644 index 00000000..5843fc43 --- /dev/null +++ b/client/web/plugins/com.msgbyte.sentry/manifest.json @@ -0,0 +1,9 @@ +{ + "label": "Sentry", + "name": "com.msgbyte.sentry", + "url": "/plugins/com.msgbyte.sentry/index.js", + "version": "0.0.0", + "author": "moonrailgun", + "description": "Sentry 错误处理", + "requireRestart": true +} diff --git a/client/web/plugins/com.msgbyte.sentry/package.json b/client/web/plugins/com.msgbyte.sentry/package.json new file mode 100644 index 00000000..1c1cf274 --- /dev/null +++ b/client/web/plugins/com.msgbyte.sentry/package.json @@ -0,0 +1,19 @@ +{ + "name": "@plugins/com.msgbyte.sentry", + "main": "src/index.tsx", + "version": "0.0.0", + "description": "Sentry 错误处理", + "private": true, + "scripts": { + "sync:declaration": "tailchat declaration github" + }, + "dependencies": { + "@sentry/react": "^7.20.0", + "@sentry/tracing": "^7.20.0" + }, + "devDependencies": { + "@types/styled-components": "^5.1.26", + "react": "18.2.0", + "styled-components": "^5.3.6" + } +} diff --git a/client/web/plugins/com.msgbyte.sentry/src/index.tsx b/client/web/plugins/com.msgbyte.sentry/src/index.tsx new file mode 100644 index 00000000..ab09c757 --- /dev/null +++ b/client/web/plugins/com.msgbyte.sentry/src/index.tsx @@ -0,0 +1,12 @@ +import * as Sentry from '@sentry/react'; +import { BrowserTracing } from '@sentry/tracing'; + +Sentry.init({ + dsn: 'https://177fd98a1e9e4deba84146a769633c32@o4504196236836864.ingest.sentry.io/4504196241293312', + integrations: [new BrowserTracing()], + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, +}); diff --git a/client/web/plugins/com.msgbyte.sentry/tsconfig.json b/client/web/plugins/com.msgbyte.sentry/tsconfig.json new file mode 100644 index 00000000..79e593c1 --- /dev/null +++ b/client/web/plugins/com.msgbyte.sentry/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "jsx": "react", + "importsNotUsedAsValues": "error" + } +} diff --git a/client/web/plugins/com.msgbyte.sentry/types/tailchat.d.ts b/client/web/plugins/com.msgbyte.sentry/types/tailchat.d.ts new file mode 100644 index 00000000..49f524ae --- /dev/null +++ b/client/web/plugins/com.msgbyte.sentry/types/tailchat.d.ts @@ -0,0 +1,2 @@ +declare module '@capital/common'; +declare module '@capital/component'; diff --git a/client/web/src/plugin/builtin.ts b/client/web/src/plugin/builtin.ts index 2edb3d5f..4bf71e91 100644 --- a/client/web/src/plugin/builtin.ts +++ b/client/web/src/plugin/builtin.ts @@ -1,7 +1,10 @@ import type { PluginManifest } from 'tailchat-shared'; import _compact from 'lodash/compact'; -const isOffical = ['nightly.paw.msgbyte.com'].includes(location.host); +const isOffical = [ + 'nightly.paw.msgbyte.com', + // 'localhost:11011', +].includes(location.host); /** * 内置插件列表 @@ -47,7 +50,7 @@ export const builtinPlugins: PluginManifest[] = _compact([ requireRestart: true, }, isOffical && { - label: 'posthog', + label: 'Posthog', name: 'com.msgbyte.posthog', url: '/plugins/com.msgbyte.posthog/index.js', version: '0.0.0', @@ -55,4 +58,13 @@ export const builtinPlugins: PluginManifest[] = _compact([ description: 'Posthog 数据统计', requireRestart: true, }, + isOffical && { + label: 'Sentry', + name: 'com.msgbyte.sentry', + url: '/plugins/com.msgbyte.sentry/index.js', + version: '0.0.0', + author: 'moonrailgun', + description: 'Sentry 错误处理', + requireRestart: true, + }, ]); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 57f64d77..fd30ee17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -640,6 +640,21 @@ importers: react: 18.2.0 styled-components: 5.3.6_react@18.2.0 + client/web/plugins/com.msgbyte.sentry: + specifiers: + '@sentry/react': ^7.20.0 + '@sentry/tracing': ^7.20.0 + '@types/styled-components': ^5.1.26 + react: 18.2.0 + styled-components: ^5.3.6 + dependencies: + '@sentry/react': 7.20.0_react@18.2.0 + '@sentry/tracing': 7.20.0 + devDependencies: + '@types/styled-components': 5.1.26 + react: 18.2.0 + styled-components: 5.3.6_react@18.2.0 + client/web/plugins/com.msgbyte.snapdrop: specifiers: {} @@ -7028,6 +7043,16 @@ packages: util: 0.12.4 dev: false + /@sentry/browser/7.20.0: + resolution: {integrity: sha512-L84CdB7DPQ2ohVcWh/KivemndWSZyXRvBZBr+tHFlQchzcaZZ/8lIPvjwvb8OJhzhecDq6JCAyUxaZwyItdyAg==} + engines: {node: '>=8'} + dependencies: + '@sentry/core': 7.20.0 + '@sentry/types': 7.20.0 + '@sentry/utils': 7.20.0 + tslib: 1.14.1 + dev: false + /@sentry/core/6.19.7: resolution: {integrity: sha512-tOfZ/umqB2AcHPGbIrsFLcvApdTm9ggpi/kQZFkej7kMphjT+SGBiQfYtjyg9jcRW+ilAR4JXC9BGKsdEQ+8Vw==} engines: {node: '>=6'} @@ -7039,6 +7064,15 @@ packages: tslib: 1.14.1 dev: false + /@sentry/core/7.20.0: + resolution: {integrity: sha512-8dIHk8niyEyVayUQpgECHnV2p444nPBjIyuQrtkdTxL7sBLC5+Y0DhRjxg9cJyZe/bZnXVerGkgcA7niKW4W8A==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.20.0 + '@sentry/utils': 7.20.0 + tslib: 1.14.1 + dev: false + /@sentry/hub/6.19.7: resolution: {integrity: sha512-y3OtbYFAqKHCWezF0EGGr5lcyI2KbaXW2Ik7Xp8Mu9TxbSTuwTe4rTntwg8ngPjUQU3SUHzgjqVB8qjiGqFXCA==} engines: {node: '>=6'} @@ -7073,6 +7107,30 @@ packages: - supports-color dev: false + /@sentry/react/7.20.0_react@18.2.0: + resolution: {integrity: sha512-hXPObzl4I7TgeCGEb3b03yLI7zF/oYQ5NoGz65fmhUainOGuW+S8KSyCWmAvaHXZ1cZao+sLfQSxl29sVVQyww==} + engines: {node: '>=8'} + peerDependencies: + react: 15.x || 16.x || 17.x || 18.x + dependencies: + '@sentry/browser': 7.20.0 + '@sentry/types': 7.20.0 + '@sentry/utils': 7.20.0 + hoist-non-react-statics: 3.3.2 + react: 18.2.0 + tslib: 1.14.1 + dev: false + + /@sentry/tracing/7.20.0: + resolution: {integrity: sha512-qg3sMvjuMQl/NEaF8I2IpvUcJ4HGGVIwEqqqZ6hkeHXIKt02p6f+nls45pVhluMiNHAaQJ+vefMTUc3E1yZwDA==} + engines: {node: '>=8'} + dependencies: + '@sentry/core': 7.20.0 + '@sentry/types': 7.20.0 + '@sentry/utils': 7.20.0 + tslib: 1.14.1 + dev: false + /@sentry/types/6.19.7: resolution: {integrity: sha512-jH84pDYE+hHIbVnab3Hr+ZXr1v8QABfhx39KknxqKWr2l0oEItzepV0URvbEhB446lk/S/59230dlUUIBGsXbg==} engines: {node: '>=6'} @@ -7091,6 +7149,14 @@ packages: tslib: 1.14.1 dev: false + /@sentry/utils/7.20.0: + resolution: {integrity: sha512-4lc122TFgkaCAvoPRy+uc5vgOCumTa/2nPkzCSxVsezQs+ebHxyMJQK7GWBLI6P+EzKfEjlgyMzRWaPJ3iJatA==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.20.0 + tslib: 1.14.1 + dev: false + /@seznam/compose-react-refs/1.0.6: resolution: {integrity: sha512-izzOXQfeQLonzrIQb8u6LQ8dk+ymz3WXTIXjvOlTXHq6sbzROg3NWU+9TTAOpEoK9Bth24/6F/XrfHJ5yR5n6Q==} dev: false