Skip to content

Commit 81e4707

Browse files
committed
set vue SDK data globally
1 parent 643823f commit 81e4707

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

packages/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"fix": "run-s fix:eslint fix:prettier",
6262
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
6363
"fix:eslint": "eslint . --format stylish --fix",
64-
"test": "jest --passWithNoTests",
64+
"test": "jest",
6565
"test:watch": "jest --watch",
6666
"pack": "npm pack"
6767
},

packages/vue/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ export {
1717
setUser,
1818
startTransaction,
1919
withScope,
20+
SDK_VERSION,
2021
} from '@sentry/browser';
2122

2223
export { init } from './sdk';
2324
export { vueRouterInstrumentation } from './vuerouter';
25+
26+
import { SDK_VERSION } from '@sentry/browser';
27+
import { setSDKInfo } from '@sentry/utils';
28+
29+
setSDKInfo('sentry.javascript.vue', 'npm:@sentry/vue', SDK_VERSION);

packages/vue/test/init.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { getGlobalObject } from '@sentry/utils';
2+
3+
import * as Sentry from '../src/index';
4+
5+
const global = getGlobalObject<Window>();
6+
7+
describe('event SDK info', () => {
8+
it('adds SDK metadata globally', () => {
9+
// the SDK data is set when we import from (and therefore run) `../src/index.ts` - it sets the vue part itself,
10+
// and the browser part gets set when it imports from @sentry/browser - so no action is necessary here before we run
11+
// the `expect`s
12+
13+
expect(global.__SENTRY__?.sdkInfo).toBeDefined();
14+
expect(global.__SENTRY__?.sdkInfo?.name).toEqual('sentry.javascript.vue');
15+
expect(global.__SENTRY__?.sdkInfo?.version).toEqual(Sentry.SDK_VERSION);
16+
expect(global.__SENTRY__?.sdkInfo?.packages).toEqual(
17+
expect.arrayContaining([
18+
{ name: 'npm:@sentry/vue', version: Sentry.SDK_VERSION },
19+
{ name: 'npm:@sentry/browser', version: Sentry.SDK_VERSION },
20+
]),
21+
);
22+
});
23+
});

0 commit comments

Comments
 (0)