File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11import { addGlobalEventProcessor , SDK_VERSION } from '@sentry/browser' ;
2+ import { setSDKInfo } from '@sentry/utils' ;
3+
4+ setSDKInfo ( 'sentry.javascript.react' , 'npm:@sentry/react' , SDK_VERSION ) ;
25
36/**
47 * A global side effect that makes sure Sentry events that user
Original file line number Diff line number Diff line change 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 react 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.react' ) ;
15+ expect ( global . __SENTRY__ ?. sdkInfo ?. version ) . toEqual ( Sentry . SDK_VERSION ) ;
16+ expect ( global . __SENTRY__ ?. sdkInfo ?. packages ) . toEqual (
17+ expect . arrayContaining ( [
18+ { name : 'npm:@sentry/react' , version : Sentry . SDK_VERSION } ,
19+ { name : 'npm:@sentry/browser' , version : Sentry . SDK_VERSION } ,
20+ ] ) ,
21+ ) ;
22+ } ) ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments