Skip to content

Commit

Permalink
feat(vue): Actually console.warn when not passing app/Vue
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Nov 18, 2022
1 parent 2a11060 commit bf67f18
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/vue/src/sdk.ts
@@ -1,5 +1,5 @@
import { init as browserInit, SDK_VERSION } from '@sentry/browser';
import { arrayify, GLOBAL_OBJ, logger } from '@sentry/utils';
import { arrayify, GLOBAL_OBJ } from '@sentry/utils';

import { DEFAULT_HOOKS } from './constants';
import { attachErrorHandler } from './errorhandler';
Expand Down Expand Up @@ -43,12 +43,12 @@ export function init(
browserInit(options);

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

Expand Down
19 changes: 19 additions & 0 deletions packages/vue/test/integration/init.test.ts
Expand Up @@ -71,4 +71,23 @@ describe('Sentry.init', () => {
'[@sentry/vue]: Misconfigured SDK. Vue app is already mounted. Make sure to call `app.mount()` after `Sentry.init()`.',
]);
});

it('warns when not passing app & Vue', () => {
const el = document.createElement('div');
const app = createApp({
template: '<div>hello</div>',
});

Sentry.init({
defaultIntegrations: false,
});

app.mount(el);

expect(warnings).toEqual([
`[@sentry/vue]: Misconfigured SDK. Vue specific errors will not be captured.
Update your \`Sentry.init\` call with an appropriate config option:
\`app\` (Application Instance - Vue 3) or \`Vue\` (Vue Constructor - Vue 2).`,
]);
});
});

0 comments on commit bf67f18

Please sign in to comment.