-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(analytics): track api errors - makePayments: '620' - submitPaymentDetails: '621' - submitThreeDS2Fingerprint: '622' - createOrder: '623' * test(UIElement): added tests for sending error event to the analytics
- Loading branch information
1 parent
a27d6dc
commit 933f970
Showing
14 changed files
with
229 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@adyen/adyen-web': minor | ||
--- | ||
|
||
Start tracking API errors for the following endpoints for analytics purposes: | ||
- `/sessions/${session.id}/payments` | ||
- `/sessions/${session.id}/orders` | ||
- `/sessions/${session.id}/paymentDetails` | ||
- `v1/submitThreeDS2Fingerprint` |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { render } from '@testing-library/preact'; | ||
import { mockDeep } from 'jest-mock-extended'; | ||
import { AnalyticsModule } from '../../types/global-types'; | ||
import AdyenCheckoutError from '../../core/Errors/AdyenCheckoutError'; | ||
import { ANALYTICS_ERROR_TYPE, ANALYTICS_EVENT } from '../../core/Analytics/constants'; | ||
import ANCV from './ANCV'; | ||
|
||
const flushPromises = () => new Promise(process.nextTick); | ||
|
||
describe('ANCV', () => { | ||
const resources = global.resources; | ||
const i18n = global.i18n; | ||
|
||
const baseProps = { | ||
amount: { value: 1000, currency: 'EUR' }, | ||
i18n, | ||
loadingContext: 'mock' | ||
}; | ||
|
||
describe('createOrder', () => { | ||
test('should send an error event to the analytics if the createOrder call fails for the session flow', async () => { | ||
const code = 'mockErrorCode'; | ||
const analytics = mockDeep<AnalyticsModule>(); | ||
const mockedSendAnalytics = analytics.sendAnalytics as jest.Mock; | ||
|
||
const ancv = new ANCV(global.core, { | ||
...baseProps, | ||
modules: { | ||
resources, | ||
analytics | ||
}, | ||
onError: () => {}, | ||
// @ts-ignore test only | ||
session: { | ||
createOrder: () => { | ||
return Promise.reject(new AdyenCheckoutError('NETWORK_ERROR', '', { code })); | ||
} | ||
} | ||
}); | ||
render(ancv.render()); | ||
await ancv.createOrder(); | ||
await flushPromises(); | ||
expect(mockedSendAnalytics).toHaveBeenCalledWith( | ||
'ancv', | ||
{ code, errorType: ANALYTICS_ERROR_TYPE.apiError, type: ANALYTICS_EVENT.error }, | ||
undefined | ||
); | ||
}); | ||
}); | ||
}); |
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
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
Oops, something went wrong.