Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
fff39a30
Unverified
Commit
fff39a30
authored
Jun 13, 2023
by
Joel
Committed by
GitHub
Jun 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: use react sentry to support pass config via runtime (#350)
parent
a11f36ca
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
27 additions
and
83 deletions
+27
-83
.env.example
web/.env.example
+0
-2
_layout-client.tsx
web/app/(commonLayout)/_layout-client.tsx
+19
-0
index.tsx
web/app/components/header/index.tsx
+2
-1
layout.tsx
web/app/layout.tsx
+1
-0
entrypoint.sh
web/docker/entrypoint.sh
+1
-0
next.config.js
web/next.config.js
+1
-28
package.json
web/package.json
+3
-3
sentry.client.config.js
web/sentry.client.config.js
+0
-23
sentry.edge.config.js
web/sentry.edge.config.js
+0
-16
sentry.server.config.js
web/sentry.server.config.js
+0
-10
No files found.
web/.env.example
View file @
fff39a30
...
...
@@ -13,5 +13,3 @@ NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api
# SENTRY
NEXT_PUBLIC_SENTRY_DSN=
NEXT_PUBLIC_SENTRY_ORG=
NEXT_PUBLIC_SENTRY_PROJECT=
\ No newline at end of file
web/app/(commonLayout)/_layout-client.tsx
View file @
fff39a30
...
...
@@ -3,6 +3,7 @@ import type { FC } from 'react'
import
React
,
{
useEffect
,
useRef
,
useState
}
from
'react'
import
{
usePathname
,
useRouter
,
useSelectedLayoutSegments
}
from
'next/navigation'
import
useSWR
,
{
SWRConfig
}
from
'swr'
import
*
as
Sentry
from
'@sentry/react'
import
Header
from
'../components/header'
import
{
fetchAppList
}
from
'@/service/apps'
import
{
fetchDatasets
}
from
'@/service/datasets'
...
...
@@ -12,11 +13,29 @@ import { AppContextProvider } from '@/context/app-context'
import
DatasetsContext
from
'@/context/datasets-context'
import
type
{
LangGeniusVersionResponse
,
UserProfileResponse
}
from
'@/models/common'
const
isDevelopment
=
process
.
env
.
NODE_ENV
===
'development'
export
type
ICommonLayoutProps
=
{
children
:
React
.
ReactNode
}
const
CommonLayout
:
FC
<
ICommonLayoutProps
>
=
({
children
})
=>
{
useEffect
(()
=>
{
const
SENTRY_DSN
=
document
?.
body
?.
getAttribute
(
'data-public-sentry-dsn'
)
if
(
!
isDevelopment
&&
SENTRY_DSN
)
{
Sentry
.
init
({
dsn
:
SENTRY_DSN
,
integrations
:
[
new
Sentry
.
BrowserTracing
({
}),
new
Sentry
.
Replay
(),
],
tracesSampleRate
:
0.1
,
replaysSessionSampleRate
:
0.1
,
replaysOnErrorSampleRate
:
1.0
,
})
}
},
[])
const
router
=
useRouter
()
const
pathname
=
usePathname
()
const
segments
=
useSelectedLayoutSegments
()
...
...
web/app/components/header/index.tsx
View file @
fff39a30
...
...
@@ -83,7 +83,8 @@ const Header: FC<IHeaderProps> = ({
'sticky top-0 left-0 right-0 z-20 flex bg-gray-100 grow-0 shrink-0 basis-auto h-14'
,
s
.
header
,
isBordered
?
'border-b border-gray-200'
:
''
,
)
}
>
)
}
>
<
div
className=
{
classNames
(
s
[
`header-${langeniusVersionInfo.current_env}`
],
'flex flex-1 items-center justify-between px-4'
,
...
...
web/app/layout.tsx
View file @
fff39a30
...
...
@@ -21,6 +21,7 @@ const LocaleLayout = ({
data
-
api
-
prefix=
{
process
.
env
.
NEXT_PUBLIC_API_PREFIX
}
data
-
pubic
-
api
-
prefix=
{
process
.
env
.
NEXT_PUBLIC_PUBLIC_API_PREFIX
}
data
-
public
-
edition=
{
process
.
env
.
NEXT_PUBLIC_EDITION
}
data
-
public
-
sentry
-
dsn=
{
process
.
env
.
NEXT_PUBLIC_SENTRY_DSN
}
>
{
/* @ts-expect-error Async Server Component */
}
<
I18nServer
locale=
{
locale
}
>
{
children
}
</
I18nServer
>
...
...
web/docker/entrypoint.sh
View file @
fff39a30
...
...
@@ -6,6 +6,7 @@ export NEXT_PUBLIC_DEPLOY_ENV=${DEPLOY_ENV}
export
NEXT_PUBLIC_EDITION
=
${
EDITION
}
export
NEXT_PUBLIC_API_PREFIX
=
${
CONSOLE_URL
}
/console/api
export
NEXT_PUBLIC_PUBLIC_API_PREFIX
=
${
APP_URL
}
/api
export
NEXT_PUBLIC_SENTRY_DSN
=
${
SENTRY_DSN
}
/usr/local/bin/pm2
-v
/usr/local/bin/pm2-runtime start /app/web/pm2.json
web/next.config.js
View file @
fff39a30
const
{
withSentryConfig
}
=
require
(
'@sentry/nextjs'
)
const
isDevelopment
=
process
.
env
.
NODE_ENV
===
'development'
const
SENTRY_DSN
=
process
.
env
.
NEXT_PUBLIC_SENTRY_DSN
const
SENTRY_ORG
=
process
.
env
.
NEXT_PUBLIC_SENTRY_ORG
const
SENTRY_PROJECT
=
process
.
env
.
NEXT_PUBLIC_SENTRY_PROJECT
const
isHideSentry
=
isDevelopment
||
!
SENTRY_DSN
||
!
SENTRY_ORG
||
!
SENTRY_PROJECT
const
withMDX
=
require
(
'@next/mdx'
)({
extension
:
/
\.
mdx
?
$/
,
options
:
{
...
...
@@ -46,25 +38,6 @@ const nextConfig = {
},
]
},
...(
isHideSentry
?
{}
:
{
sentry
:
{
hideSourceMaps
:
true
,
},
}),
}
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup
const
sentryWebpackPluginOptions
=
{
org
:
SENTRY_ORG
,
project
:
SENTRY_PROJECT
,
silent
:
true
,
// Suppresses all logs
sourcemaps
:
{
assets
:
'./**'
,
ignore
:
[
'./node_modules/**'
],
},
// https://github.com/getsentry/sentry-webpack-plugin#options.
}
module
.
exports
=
isHideSentry
?
withMDX
(
nextConfig
)
:
withMDX
(
withSentryConfig
(
nextConfig
,
sentryWebpackPluginOptions
)
)
module
.
exports
=
withMDX
(
nextConfig
)
web/package.json
View file @
fff39a30
...
...
@@ -20,10 +20,10 @@
"@mdx-js/loader"
:
"^2.3.0"
,
"@mdx-js/react"
:
"^2.3.0"
,
"@next/mdx"
:
"^13.2.4"
,
"@sentry/
nextjs"
:
"^7.53.1
"
,
"@sentry/
react"
:
"^7.54.0
"
,
"@sentry/utils"
:
"^7.54.0"
,
"@tailwindcss/typography"
:
"^0.5.9"
,
"@tailwindcss/line-clamp"
:
"^0.4.2"
,
"@tailwindcss/typography"
:
"^0.5.9"
,
"@types/crypto-js"
:
"^4.1.1"
,
"@types/lodash-es"
:
"^4.17.7"
,
"@types/node"
:
"18.15.0"
,
...
...
@@ -33,8 +33,8 @@
"@types/react-syntax-highlighter"
:
"^15.5.6"
,
"@types/react-window"
:
"^1.8.5"
,
"@types/react-window-infinite-loader"
:
"^1.0.6"
,
"autoprefixer"
:
"^10.4.14"
,
"ahooks"
:
"^3.7.5"
,
"autoprefixer"
:
"^10.4.14"
,
"classnames"
:
"^2.3.2"
,
"copy-to-clipboard"
:
"^3.3.3"
,
"crypto-js"
:
"^4.1.1"
,
...
...
web/sentry.client.config.js
deleted
100644 → 0
View file @
a11f36ca
import
*
as
Sentry
from
'@sentry/nextjs'
Sentry
.
init
({
dsn
:
process
.
env
.
NEXT_PUBLIC_SENTRY_DSN
,
// Replay may only be enabled for the client-side
integrations
:
[
new
Sentry
.
Replay
()],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate
:
0.1
,
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate
:
0.1
,
replaysOnErrorSampleRate
:
1.0
,
// ...
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
})
web/sentry.edge.config.js
deleted
100644 → 0
View file @
a11f36ca
import
*
as
Sentry
from
'@sentry/nextjs'
Sentry
.
init
({
dsn
:
process
.
env
.
NEXT_PUBLIC_SENTRY_DSN
,
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate
:
0.1
,
// ...
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
})
web/sentry.server.config.js
deleted
100644 → 0
View file @
a11f36ca
import
*
as
Sentry
from
'@sentry/nextjs'
Sentry
.
init
({
dsn
:
process
.
env
.
NEXT_PUBLIC_SENTRY_DSN
,
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate
:
0.1
,
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment