@@ -77,43 +77,62 @@ See [examples/sentry](https://github.com/vikejs/vike-react/tree/main/examples/se
7777
7878Sentry SDK configuration options.
7979
80+ ** Example 1: Using ` getGlobalContext() ` for dynamic configuration**
81+
8082``` js
81- // pages/+sentry.js
82- // Environment: client, server
83+ // pages/+sentry.server. js
84+ // Environment: server
8385
84- // Shared configuration (client & server)
86+ import { getGlobalContext } from ' vike/ server'
8587
86- export default (globalContext ) => ({
87- tracesSampleRate: 1.0 , // Capture 100% of transactions for tracing
88- debug: true , // Enable debug mode during development
89- environment: globalContext .isProduction ? ' production' : ' development' ,
90- })
88+ export default async () => {
89+ const globalContext = await getGlobalContext ()
90+ return {
91+ tracesSampleRate: 1.0 , // Capture 100% of transactions for tracing
92+ debug: true , // Enable debug mode during development
93+ environment: globalContext .isProduction ? ' production' : ' development' ,
94+ }
95+ }
9196```
9297
9398``` js
9499// pages/+sentry.client.js
95100// Environment: client
96101
97- // Client-only configuration
102+ import { getGlobalContext } from ' vike/client'
103+
104+ export default async () => {
105+ const globalContext = await getGlobalContext ()
106+ return {
107+ tracesSampleRate: 1.0 ,
108+ debug: true ,
109+ environment: globalContext .isProduction ? ' production' : ' development' ,
110+ }
111+ }
112+ ```
113+
114+ ** Example 2: Static configuration**
98115
99- export default (globalContext ) => ({
116+ ``` js
117+ // pages/+sentry.client.js
118+ // Environment: client
119+
120+ export default {
100121 integrations: [
101122 // Add custom browser integrations here
102123 ],
103- })
124+ }
104125```
105126
106127``` js
107128// pages/+sentry.server.js
108129// Environment: server
109130
110- // Server-only configuration
111-
112- export default (globalContext ) => ({
131+ export default {
113132 integrations: [
114133 // Add custom Node.js integrations here
115134 ],
116- })
135+ }
117136```
118137
119138> [ !NOTE]
0 commit comments