Skip to content

Commit 1b175fd

Browse files
committed
fix(nuxt): avoid logging skip warning when debug is false
1 parent 809d578 commit 1b175fd

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

packages/nuxt/src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default defineNuxtModule<ModuleOptions>({
117117
if (serverConfigFile) {
118118
addMiddlewareImports();
119119
addStorageInstrumentation(nuxt);
120-
addDatabaseInstrumentation(nuxt.options.nitro);
120+
addDatabaseInstrumentation(nuxt.options.nitro, moduleOptions);
121121
}
122122

123123
// Add the sentry config file to the include array

packages/nuxt/src/vite/databaseConfig.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import { addServerPlugin, createResolver } from '@nuxt/kit';
22
import { consoleSandbox } from '@sentry/core';
33
import type { NitroConfig } from 'nitropack/types';
4+
import type { SentryNuxtModuleOptions } from '../common/types';
45
import { addServerTemplate } from '../vendor/server-template';
56

67
/**
78
* Sets up the database instrumentation.
89
*/
9-
export function addDatabaseInstrumentation(nitro: NitroConfig): void {
10+
export function addDatabaseInstrumentation(nitro: NitroConfig, moduleOptions?: SentryNuxtModuleOptions): void {
1011
if (!nitro.experimental?.database) {
11-
consoleSandbox(() => {
12-
// eslint-disable-next-line no-console
13-
console.log(
14-
'[Sentry] [Nitro Database Plugin]: No database configuration found. Skipping database instrumentation.',
15-
);
16-
});
12+
// We cannot use DEBUG_BUILD here because it is a runtime flag, so it is not available for build time scripts
13+
// So we have to pass in the module options to the build time script
14+
moduleOptions?.debug &&
15+
consoleSandbox(() => {
16+
// eslint-disable-next-line no-console
17+
console.log(
18+
'[Sentry] [Nitro Database Plugin]: No database configuration found. Skipping database instrumentation.',
19+
);
20+
});
1721

1822
return;
1923
}

0 commit comments

Comments
 (0)