File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,25 @@ declare global {
2020 var EdgeRuntime : string ;
2121}
2222
23+ function warnAboutMissingEnvironmentVariables ( ) {
24+ let checkEnabled = process . env . NODE_ENV !== 'development' ;
25+ if ( process . env . LOGTAIL_CHECK_ENV_VARS ?. toLowerCase ( ) === 'true' || process . env . LOGTAIL_CHECK_ENV_VARS === '1' ) {
26+ checkEnabled = true ;
27+ }
28+ if ( process . env . LOGTAIL_CHECK_ENV_VARS ?. toLowerCase ( ) === 'false' || process . env . LOGTAIL_CHECK_ENV_VARS === '0' ) {
29+ checkEnabled = false ;
30+ }
31+
32+ if ( checkEnabled ) {
33+ const log = new Logger ( ) ;
34+ log . warn (
35+ 'logtail: Envvars not detected. If this is production please see https://github.com/logtail/logtail-nextjs for help'
36+ ) ;
37+ log . warn ( 'logtail: Sending Web Vitals to /dev/null' ) ;
38+ log . warn ( 'logtail: Sending logs to console' ) ;
39+ }
40+ }
41+
2342export function withLogtailNextConfig ( nextConfig : NextConfig ) : NextConfig {
2443 return {
2544 ...nextConfig ,
@@ -28,12 +47,8 @@ export function withLogtailNextConfig(nextConfig: NextConfig): NextConfig {
2847
2948 const proxyEndpoint = config . getProxyEndpoint ( ) ;
3049 if ( ! proxyEndpoint ) {
31- const log = new Logger ( ) ;
32- log . warn (
33- 'logtail: Envvars not detected. If this is production please see https://github.com/logtail/logtail-nextjs for help'
34- ) ;
35- log . warn ( 'logtail: Sending Web Vitals to /dev/null' ) ;
36- log . warn ( 'logtail: Sending logs to console' ) ;
50+ warnAboutMissingEnvironmentVariables ( ) ;
51+
3752 return rewrites || [ ] ; // nothing to do
3853 }
3954
You can’t perform that action at this time.
0 commit comments