Skip to content

Commit

Permalink
Bump govuk front end toolkit to 4.3.0
Browse files Browse the repository at this point in the history
4.3.0
Allow javascript error tracking to be filtered to avoid noise from
plugins

https://github.com/alphagov/govuk_frontend_toolkit/blob/master/CHANGELOG
.md
  • Loading branch information
gemmaleigh committed Sep 21, 2015
1 parent 88aa5b8 commit 7c059f0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
39 changes: 29 additions & 10 deletions govuk/public/javascripts/govuk/analytics/error-tracking.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
// Extension to track errors using google analytics as a data store.
(function() {

"use strict";

GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {};

GOVUK.analyticsPlugins.error = function () {
GOVUK.analyticsPlugins.error = function (options) {
var options = options || {},
filenameMustMatch = options.filenameMustMatch;

var trackJavaScriptError = function (e) {
var errorSource = e.filename + ': ' + e.lineno;
GOVUK.analytics.trackEvent('JavaScript Error', e.message, {
label: errorSource,
value: 1,
nonInteraction: true
});
var errorFilename = e.filename,
errorSource = errorFilename + ': ' + e.lineno;

if (shouldTrackThisError(errorFilename)) {
GOVUK.analytics.trackEvent('JavaScript Error', e.message, {
label: errorSource,
value: 1,
nonInteraction: true
});
}
};

function shouldTrackThisError(errorFilename) {
// Errors in page should always be tracked
// If there's no filename filter, everything is tracked
if (!errorFilename || !filenameMustMatch) {
return true;
}

// If there's a filter and the error matches it, track it
if (filenameMustMatch.test(errorFilename)) {
return true;
}

return false;
}

if (window.addEventListener) {
window.addEventListener('error', trackJavaScriptError, false);
} else if (window.attachEvent) {
Expand All @@ -23,5 +43,4 @@
window.onerror = trackJavaScriptError;
}
}

}());
2 changes: 1 addition & 1 deletion govuk/public/javascripts/govuk/selection-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$elms = $(elmsOrSelector);
this.selector = elmsOrSelector;
this.setInitialState($(this.selector));
} else {
} else if (elmsOrSelector !== undefined) {
this.$elms = elmsOrSelector;
this.setInitialState(this.$elms);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"consolidate": "^0.10.0",
"express": "^3.18.4",
"express-writer": "0.0.4",
"govuk_frontend_toolkit": "^4.2.1",
"govuk_frontend_toolkit": "^4.3.0",
"govuk_template_mustache": "^0.15.1",
"grunt": "^0.4.2",
"grunt-concurrent": "^0.4.3",
Expand Down

0 comments on commit 7c059f0

Please sign in to comment.