File tree 4 files changed +19
-0
lines changed
4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,10 @@ export function init(options: BrowserOptions = {}): void {
83
83
if ( window . SENTRY_RELEASE && window . SENTRY_RELEASE . id ) {
84
84
options . release = window . SENTRY_RELEASE . id ;
85
85
}
86
+ } else if ( typeof options . release !== 'string' ) {
87
+ options . release = JSON . stringify ( options . release ) ;
86
88
}
89
+
87
90
if ( options . autoSessionTracking === undefined ) {
88
91
options . autoSessionTracking = true ;
89
92
}
Original file line number Diff line number Diff line change @@ -185,6 +185,13 @@ describe('SentryBrowser initialization', () => {
185
185
expect ( global . __SENTRY__ . hub . _stack [ 0 ] . client . getOptions ( ) . release ) . to . be . undefined ;
186
186
} ) ;
187
187
188
+ it ( 'should use window.SENTRY_RELEASE to set release on initialization if available' , ( ) => {
189
+ const releaseObj = { name : 'release hello world' } ;
190
+ // @ts -ignore
191
+ init ( { dsn, release : releaseObj } ) ;
192
+ expect ( global . __SENTRY__ . hub . _stack [ 0 ] . client . getOptions ( ) . release ) . equal ( JSON . stringify ( releaseObj ) ) ;
193
+ } ) ;
194
+
188
195
describe ( 'SDK metadata' , ( ) => {
189
196
it ( 'should set SDK data when Sentry.init() is called' , ( ) => {
190
197
init ( { dsn } ) ;
Original file line number Diff line number Diff line change @@ -97,6 +97,8 @@ export function init(options: NodeOptions = {}): void {
97
97
if ( detectedRelease !== undefined ) {
98
98
options . release = detectedRelease ;
99
99
}
100
+ } else if ( typeof options . release !== 'string' ) {
101
+ options . release = JSON . stringify ( options . release ) ;
100
102
}
101
103
102
104
if ( options . environment === undefined && process . env . SENTRY_ENVIRONMENT ) {
Original file line number Diff line number Diff line change @@ -279,6 +279,13 @@ describe('SentryNode initialization', () => {
279
279
global . SENTRY_RELEASE = undefined ;
280
280
} ) ;
281
281
282
+ test ( 'release is stringified, if options.release is passed as an object' , ( ) => {
283
+ const releaseObj = { name : 'release hello world' } ;
284
+ // @ts -ignore
285
+ init ( { dsn, release : releaseObj } ) ;
286
+ expect ( global . __SENTRY__ . hub . _stack [ 0 ] . client . getOptions ( ) . release ) . toEqual ( JSON . stringify ( releaseObj ) ) ;
287
+ } ) ;
288
+
282
289
describe ( 'SDK metadata' , ( ) => {
283
290
it ( 'should set SDK data when Sentry.init() is called' , ( ) => {
284
291
init ( { dsn } ) ;
You can’t perform that action at this time.
0 commit comments