Skip to content

Commit

Permalink
Merge pull request #3759 from alphagov/PP-11638-log-additional-events
Browse files Browse the repository at this point in the history
PP-11638 Add additional client-side logging
  • Loading branch information
stephencdaly authored Nov 8, 2023
2 parents e30fbde + ddf693b commit 17f1fd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/javascripts/browsered/web-payments/apple-pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = () => {
}).then(response => {
if (response.status >= 200 && response.status < 300) {
ga('send', 'event', 'Apple Pay', 'Successful', 'auth/capture request')
sendLogMessage(window.paymentDetails.chargeID, 'ApplePaySuccessfulAuthorisation')
return response.json().then(data => {
session.completePayment(ApplePaySession.STATUS_SUCCESS)
window.location.href = data.url
Expand All @@ -89,13 +90,15 @@ module.exports = () => {
toggleSubmitButtons()
showErrorSummary(i18n.fieldErrors.webPayments.apple)
ga('send', 'event', 'Apple Pay', 'Error', 'During authorisation/capture')
sendLogMessage(window.paymentDetails.chargeID, 'ApplePayFailedAuthorisation')
}
}).catch(err => {
session.abort()
hideSpinnerAndShowMainContent()
toggleSubmitButtons()
showErrorSummary(i18n.fieldErrors.webPayments.apple)
ga('send', 'event', 'Apple Pay', 'Error', 'Couldn’t post to /web-payments-auth-request/apple/{chargeId}')
sendLogMessage(window.paymentDetails.chargeID, 'ApplePayErrorMakingRequestToAuthorise')
return err
})
}
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/browsered/web-payments/google-pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const submitGooglePayAuthRequest = (paymentResponse) => {
})
.then(response => {
ga('send', 'event', 'Google Pay', 'Successful', 'auth/capture request')
sendLogMessage(window.paymentDetails.chargeID, 'GooglePaySuccessfulAuthorisation')
if (response.status >= 200 && response.status < 300) {
return response.json().then(data => {
window.location.href = data.url
Expand All @@ -38,13 +39,15 @@ const submitGooglePayAuthRequest = (paymentResponse) => {
toggleSubmitButtons()
showErrorSummary(i18n.fieldErrors.webPayments.failureTitle, i18n.fieldErrors.webPayments.failureBody)
ga('send', 'event', 'Google Pay', 'Error', 'During authorisation/capture')
sendLogMessage(window.paymentDetails.chargeID, 'GooglePayFailedAuthorisation')
}
})
.catch(err => {
hideSpinnerAndShowMainContent()
toggleSubmitButtons()
showErrorSummary(i18n.fieldErrors.webPayments.failureTitle, i18n.fieldErrors.webPayments.failureBody)
ga('send', 'event', 'Google Pay', 'Error', 'During authorisation/capture')
sendLogMessage(window.paymentDetails.chargeID, 'GooglePayErrorMakingRequestToAuthorise')
return err
})
}
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/client-side-logging.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ const LOG_CODES = {
ApplePayAborted: 'Apple Pay attempt aborted by user',
ApplePayMerchantIdNotValid: 'Apple Pay Merchant ID not valid',
ApplePayMerchantValidationError: 'Error completing Apple Pay merchant validation',
ApplePayErrorMakingRequestToAuthorise: 'There was an error making a request to the server to authorise an Apple Pay payment',
ApplePaySuccessfulAuthorisation: 'Apple Pay authorisation was successful',
ApplePayFailedAuthorisation: 'Apple Pay authorisation failed',
GooglePayAvailable: 'Google Pay is available on this device',
GooglePayStarted: 'User chose Google Pay method',
GooglePayAborted: 'Google Pay attempt aborted by user'
GooglePayAborted: 'Google Pay attempt aborted by user',
GooglePayErrorMakingRequestToAuthorise: 'There was an error making a request to the server to authorise an Google Pay payment',
GooglePaySuccessfulAuthorisation: 'Google Pay authorisation was successful',
GooglePayFailedAuthorisation: 'Google Pay authorisation failed'
}

function log (req, res) {
Expand Down

0 comments on commit 17f1fd5

Please sign in to comment.