Commit fbc434b8 by liimin

fix(sentry-initor): 修复Sentry DSN默认值设置问题

在Sentry初始化时,如果未从DOM中获取到Sentry DSN,则使用默认的sentryDsn值,确保Sentry在开发和生产环境中都能正确初始化。
1 parent a5d360ca
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: liimin 17653212@qq.com * @Author: liimin 17653212@qq.com
* @Date: 2025-04-16 18:17:34 * @Date: 2025-04-16 18:17:34
* @LastEditors: liimin 17653212@qq.com * @LastEditors: liimin 17653212@qq.com
* @LastEditTime: 2025-05-15 19:04:27 * @LastEditTime: 2025-05-15 19:42:09
* @FilePath: \ai-assistant\app\components\sentry-initor.tsx * @FilePath: \ai-assistant\app\components\sentry-initor.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -12,10 +12,10 @@ import { useEffect } from 'react' ...@@ -12,10 +12,10 @@ import { useEffect } from 'react'
import * as Sentry from '@sentry/react' import * as Sentry from '@sentry/react'
const isDevelopment = process.env.NODE_ENV === 'development' const isDevelopment = process.env.NODE_ENV === 'development'
const sentryDsn = 'https://90ddfaad2eac44f3b25cd4298ae7af14@sentry.glsx.com.cn/45'
const SentryInit = ({ children }: { children: React.ReactNode }) => { const SentryInit = ({ children }: { children: React.ReactNode }) => {
useEffect(() => { useEffect(() => {
const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn') const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn') || sentryDsn
if (SENTRY_DSN) { if (SENTRY_DSN) {
Sentry.init({ Sentry.init({
dsn: SENTRY_DSN, dsn: SENTRY_DSN,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!