Skip to content

Commit f909ea1

Browse files
committed
Added logic that stringifies release if it is an object in brower sdk
1 parent eb36b32 commit f909ea1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/browser/src/sdk.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ export function init(options: BrowserOptions = {}): void {
8383
if (window.SENTRY_RELEASE && window.SENTRY_RELEASE.id) {
8484
options.release = window.SENTRY_RELEASE.id;
8585
}
86+
} else if (typeof options.release !== 'string') {
87+
options.release = JSON.stringify(options.release);
8688
}
89+
8790
if (options.autoSessionTracking === undefined) {
8891
options.autoSessionTracking = true;
8992
}

packages/browser/test/unit/index.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ describe('SentryBrowser initialization', () => {
185185
expect(global.__SENTRY__.hub._stack[0].client.getOptions().release).to.be.undefined;
186186
});
187187

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+
188195
describe('SDK metadata', () => {
189196
it('should set SDK data when Sentry.init() is called', () => {
190197
init({ dsn });

0 commit comments

Comments
 (0)