Skip to content

Commit bf67f18

Browse files
committed
feat(vue): Actually console.warn when not passing app/Vue
1 parent 2a11060 commit bf67f18

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

packages/vue/src/sdk.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { init as browserInit, SDK_VERSION } from '@sentry/browser';
2-
import { arrayify, GLOBAL_OBJ, logger } from '@sentry/utils';
2+
import { arrayify, GLOBAL_OBJ } from '@sentry/utils';
33

44
import { DEFAULT_HOOKS } from './constants';
55
import { attachErrorHandler } from './errorhandler';
@@ -43,12 +43,12 @@ export function init(
4343
browserInit(options);
4444

4545
if (!options.Vue && !options.app) {
46-
__DEBUG_BUILD__ &&
47-
logger.warn(
48-
'Misconfigured SDK. Vue specific errors will not be captured.\n' +
49-
'Update your `Sentry.init` call with an appropriate config option:\n' +
50-
'`app` (Application Instance - Vue 3) or `Vue` (Vue Constructor - Vue 2).',
51-
);
46+
// eslint-disable-next-line no-console
47+
console.warn(
48+
`[@sentry/vue]: Misconfigured SDK. Vue specific errors will not be captured.
49+
Update your \`Sentry.init\` call with an appropriate config option:
50+
\`app\` (Application Instance - Vue 3) or \`Vue\` (Vue Constructor - Vue 2).`,
51+
);
5252
return;
5353
}
5454

packages/vue/test/integration/init.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,23 @@ describe('Sentry.init', () => {
7171
'[@sentry/vue]: Misconfigured SDK. Vue app is already mounted. Make sure to call `app.mount()` after `Sentry.init()`.',
7272
]);
7373
});
74+
75+
it('warns when not passing app & Vue', () => {
76+
const el = document.createElement('div');
77+
const app = createApp({
78+
template: '<div>hello</div>',
79+
});
80+
81+
Sentry.init({
82+
defaultIntegrations: false,
83+
});
84+
85+
app.mount(el);
86+
87+
expect(warnings).toEqual([
88+
`[@sentry/vue]: Misconfigured SDK. Vue specific errors will not be captured.
89+
Update your \`Sentry.init\` call with an appropriate config option:
90+
\`app\` (Application Instance - Vue 3) or \`Vue\` (Vue Constructor - Vue 2).`,
91+
]);
92+
});
7493
});

0 commit comments

Comments
 (0)