app/assets/javascripts/govuk/analytics/analytics.js in govuk_frontend_toolkit-7.3.0 vs app/assets/javascripts/govuk/analytics/analytics.js in govuk_frontend_toolkit-7.4.0
- old
+ new
@@ -27,14 +27,19 @@
delete config.govukTrackerUrl
this.trackers.push(new GOVUK.GOVUKTracker(govukTrackerUrl))
}
}
+ var PIISafe = function (value) {
+ this.value = value
+ }
+ Analytics.PIISafe = PIISafe
+
Analytics.prototype.stripPII = function (value) {
if (typeof value === 'string') {
return this.stripPIIFromString(value)
- } else if (Object.prototype.toString.call(value) === '[object Array]') {
+ } else if (Object.prototype.toString.call(value) === '[object Array]' || Object.prototype.toString.call(value) === '[object Arguments]') {
return this.stripPIIFromArray(value)
} else if (typeof value === 'object') {
return this.stripPIIFromObject(value)
} else {
return value
@@ -49,15 +54,19 @@
return emailStripped
}
}
Analytics.prototype.stripPIIFromObject = function (object) {
- for (var property in object) {
- var value = object[property]
+ if (object instanceof Analytics.PIISafe) {
+ return object.value
+ } else {
+ for (var property in object) {
+ var value = object[property]
- object[property] = this.stripPII(value)
+ object[property] = this.stripPII(value)
+ }
+ return object
}
- return object
}
Analytics.prototype.stripPIIFromArray = function (array) {
for (var i = 0, l = array.length; i < l; i++) {
var elem = array[i]