-
-
Notifications
You must be signed in to change notification settings - Fork 261
chore: Replace deprecated error reporting service calls with Messenger.captureException
#7542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,10 +67,7 @@ const getRootMessenger = (): RootMessenger => { | |
| MessengerActions<NetworkControllerMessenger>, | ||
| MessengerEvents<NetworkControllerMessenger> | ||
| >({ namespace: MOCK_ANY_NAMESPACE }); | ||
| rootMessenger.registerActionHandler( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was only added to the test messenger, the controller doesn't actually use |
||
| 'ErrorReportingService:captureException', | ||
| jest.fn(), | ||
| ); | ||
|
|
||
| return rootMessenger; | ||
| }; | ||
|
|
||
|
|
@@ -93,10 +90,7 @@ const setupNetworkController = async ({ | |
| >({ | ||
| namespace: 'NetworkController', | ||
| parent: rootMessenger, | ||
| }); | ||
| rootMessenger.delegate({ | ||
| messenger: networkControllerMessenger, | ||
| actions: ['ErrorReportingService:captureException'], | ||
| captureException: jest.fn(), | ||
| }); | ||
|
|
||
| const infuraProjectId = '123'; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -608,23 +608,18 @@ describe('SnapAccountProvider', () => { | |
|
|
||
| it('creates new accounts if de-synced', async () => { | ||
| const { provider, messenger } = setup(); | ||
| const captureExceptionSpy = jest.spyOn(messenger, 'captureException'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Test spy timing prevents capturing captureException callsThe Additional Locations (2) |
||
|
|
||
| messenger.registerActionHandler( | ||
| 'SnapController:handleRequest', | ||
| jest.fn().mockResolvedValue([mockAccounts[0]].map(asKeyringAccount)), | ||
| ); | ||
|
|
||
| const mockCaptureException = jest.fn(); | ||
| messenger.registerActionHandler( | ||
| 'ErrorReportingService:captureException', | ||
| mockCaptureException, | ||
| ); | ||
|
|
||
| const createAccountsSpy = jest.spyOn(provider, 'createAccounts'); | ||
|
|
||
| await provider.resyncAccounts(mockAccounts); | ||
|
|
||
| expect(mockCaptureException).toHaveBeenCalledWith( | ||
| expect(captureExceptionSpy).toHaveBeenCalledWith( | ||
| new Error( | ||
| `Snap "${TEST_SNAP_ID}" has de-synced accounts, we'll attempt to re-sync them...`, | ||
| ), | ||
|
|
@@ -639,21 +634,16 @@ describe('SnapAccountProvider', () => { | |
|
|
||
| it('reports an error if a Snap has more accounts than MetaMask', async () => { | ||
| const { provider, messenger } = setup(); | ||
| const captureExceptionSpy = jest.spyOn(messenger, 'captureException'); | ||
|
|
||
| messenger.registerActionHandler( | ||
| 'SnapController:handleRequest', | ||
| jest.fn().mockResolvedValue(mockAccounts.map(asKeyringAccount)), | ||
| ); | ||
|
|
||
| const mockCaptureException = jest.fn(); | ||
| messenger.registerActionHandler( | ||
| 'ErrorReportingService:captureException', | ||
| mockCaptureException, | ||
| ); | ||
|
|
||
| await provider.resyncAccounts([mockAccounts[0]]); // Less accounts than the Snap | ||
|
|
||
| expect(mockCaptureException).toHaveBeenCalledWith( | ||
| expect(captureExceptionSpy).toHaveBeenCalledWith( | ||
| new Error( | ||
| `Snap "${TEST_SNAP_ID}" has de-synced accounts, Snap has more accounts than MetaMask!`, | ||
| ), | ||
|
|
@@ -662,18 +652,13 @@ describe('SnapAccountProvider', () => { | |
|
|
||
| it('does not throw errors if any provider is not able to re-sync', async () => { | ||
| const { provider, messenger } = setup(); | ||
| const captureExceptionSpy = jest.spyOn(messenger, 'captureException'); | ||
|
|
||
| messenger.registerActionHandler( | ||
| 'SnapController:handleRequest', | ||
| jest.fn().mockResolvedValue([mockAccounts[0]].map(asKeyringAccount)), | ||
| ); | ||
|
|
||
| const mockCaptureException = jest.fn(); | ||
| messenger.registerActionHandler( | ||
| 'ErrorReportingService:captureException', | ||
| mockCaptureException, | ||
| ); | ||
|
|
||
| const createAccountsSpy = jest.spyOn(provider, 'createAccounts'); | ||
|
|
||
| const providerError = new Error('Unable to create accounts'); | ||
|
|
@@ -683,17 +668,17 @@ describe('SnapAccountProvider', () => { | |
|
|
||
| expect(createAccountsSpy).toHaveBeenCalled(); | ||
|
|
||
| expect(mockCaptureException).toHaveBeenNthCalledWith( | ||
| expect(captureExceptionSpy).toHaveBeenNthCalledWith( | ||
| 1, | ||
| new Error( | ||
| `Snap "${TEST_SNAP_ID}" has de-synced accounts, we'll attempt to re-sync them...`, | ||
| ), | ||
| ); | ||
| expect(mockCaptureException).toHaveBeenNthCalledWith( | ||
| expect(captureExceptionSpy).toHaveBeenNthCalledWith( | ||
| 2, | ||
| new Error('Unable to re-sync account: 0'), | ||
| ); | ||
| expect(mockCaptureException.mock.lastCall[0]).toHaveProperty( | ||
| expect(captureExceptionSpy.mock.lastCall[0]).toHaveProperty( | ||
| 'cause', | ||
| providerError, | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependency wasn't used at all.