diff --git a/src/public/modules/core/services/gtag.client.service.js b/src/public/modules/core/services/gtag.client.service.js index ad7a0cb3a8..632ff5b1bb 100644 --- a/src/public/modules/core/services/gtag.client.service.js +++ b/src/public/modules/core/services/gtag.client.service.js @@ -500,5 +500,12 @@ function GTag(Auth, $rootScope, $window) { }) } + /** + * Logs client form reCAPTCHA onError. + */ + gtagService.reCaptchaOnError = (form) => { + _gtagPublicFormEvents(form, 'reCAPTCHA connection failure') + } + return gtagService } diff --git a/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html b/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html index b0b2b12d70..6e06a9c165 100644 --- a/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html +++ b/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html @@ -115,7 +115,7 @@ size="invisible" on-create="captchaService.setWidget(widgetId)" on-success="captchaService.onSuccess(response, submitForm)" - on-error="captchaService.onError()" + on-error="captchaService.onError(form)" on-expire="captchaService.expire()" data-badge="inline" > diff --git a/src/public/modules/forms/services/captcha.client.service.js b/src/public/modules/forms/services/captcha.client.service.js index a6f29df6c6..ea3e506a34 100644 --- a/src/public/modules/forms/services/captcha.client.service.js +++ b/src/public/modules/forms/services/captcha.client.service.js @@ -6,10 +6,11 @@ angular '$window', 'vcRecaptchaService', 'Toastr', + 'GTag', captchaService, ]) -function captchaService($window, vcRecaptchaService, Toastr) { +function captchaService($window, vcRecaptchaService, Toastr, GTag) { /** * Captcha public key associated with app */ @@ -64,10 +65,15 @@ function captchaService($window, vcRecaptchaService, Toastr) { cb() } - this.onError = function () { + /** + * Show error toast and log error with Google Analytics + * @param {*} form the form this error occurred for + */ + this.onError = function (form) { Toastr.error( 'Error: Cannot connect to reCAPTCHA. Please check your internet connectivity or try submitting on another device.', ) + GTag.reCaptchaOnError(form) } /**