-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(browser): Remove showReportDialog on browser client (#4973)
Remove `showReportDialog` as a client method so it can be tree-shaken out if not used. Also allow for hub to be explicitly passed in to `showReportDialog`.
- Loading branch information
1 parent
de2822b
commit 389f4ee
Showing
6 changed files
with
68 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { SDK_VERSION } from '@sentry/core'; | ||
import { getReportDialogEndpoint, SDK_VERSION } from '@sentry/core'; | ||
|
||
import { | ||
addBreadcrumb, | ||
|
@@ -24,6 +24,14 @@ const dsn = 'https://[email protected]/4291'; | |
// eslint-disable-next-line no-var | ||
declare var global: any; | ||
|
||
jest.mock('@sentry/core', () => { | ||
const original = jest.requireActual('@sentry/core'); | ||
return { | ||
...original, | ||
getReportDialogEndpoint: jest.fn(), | ||
}; | ||
}); | ||
|
||
describe('SentryBrowser', () => { | ||
const beforeSend = jest.fn(); | ||
|
||
|
@@ -74,16 +82,14 @@ describe('SentryBrowser', () => { | |
}); | ||
|
||
describe('showReportDialog', () => { | ||
beforeEach(() => { | ||
(getReportDialogEndpoint as jest.Mock).mockReset(); | ||
}); | ||
|
||
describe('user', () => { | ||
const EX_USER = { email: '[email protected]' }; | ||
const options = getDefaultBrowserClientOptions({ dsn }); | ||
const client = new BrowserClient(options); | ||
const reportDialogSpy = jest.spyOn(client, 'showReportDialog'); | ||
|
||
beforeEach(() => { | ||
reportDialogSpy.mockReset(); | ||
}); | ||
|
||
it('uses the user on the scope', () => { | ||
configureScope(scope => { | ||
scope.setUser(EX_USER); | ||
|
@@ -92,8 +98,11 @@ describe('SentryBrowser', () => { | |
|
||
showReportDialog(); | ||
|
||
expect(reportDialogSpy).toBeCalled(); | ||
expect(reportDialogSpy.mock.calls[0][0]!.user!.email).toBe(EX_USER.email); | ||
expect(getReportDialogEndpoint).toHaveBeenCalledTimes(1); | ||
expect(getReportDialogEndpoint).toHaveBeenCalledWith( | ||
expect.any(Object), | ||
expect.objectContaining({ user: { email: EX_USER.email } }), | ||
); | ||
}); | ||
|
||
it('prioritizes options user over scope user', () => { | ||
|
@@ -105,8 +114,11 @@ describe('SentryBrowser', () => { | |
const DIALOG_OPTION_USER = { email: '[email protected]' }; | ||
showReportDialog({ user: DIALOG_OPTION_USER }); | ||
|
||
expect(reportDialogSpy).toBeCalled(); | ||
expect(reportDialogSpy.mock.calls[0][0]!.user!.email).toBe(DIALOG_OPTION_USER.email); | ||
expect(getReportDialogEndpoint).toHaveBeenCalledTimes(1); | ||
expect(getReportDialogEndpoint).toHaveBeenCalledWith( | ||
expect.any(Object), | ||
expect.objectContaining({ user: { email: DIALOG_OPTION_USER.email } }), | ||
); | ||
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters