Skip to content

Commit

Permalink
Merge pull request #1853 from alphagov/use-pii
Browse files Browse the repository at this point in the history
Use pii code in cross linker
  • Loading branch information
andysellick authored Sep 12, 2019
2 parents 9f0a127 + 46fd7f8 commit 6fdbc9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

var $ = global.jQuery
var GOVUK = global.GOVUK || {}
var pii = new GOVUK.pii()
pii.stripDatePII = true
pii.stripPostcodePII = true

var GoogleAnalyticsUniversalTracker = function (trackingId, fieldsObject) {
function configureProfile () {
Expand All @@ -26,7 +29,7 @@
}

function stripLocationPII () {
sendToGa('set', 'location', stripEmailAddressesFromString(window.location.href))
sendToGa('set', 'location', pii.stripPII(window.location.href))
}

// Support legacy cookieDomain param
Expand Down Expand Up @@ -183,11 +186,6 @@
}
}

function stripEmailAddressesFromString (string) {
var stripped = string.replace(/[^\s=/?&]+(?:@|%40)[^\s=/?&]+/g, '[email]')
return stripped
}

GOVUK.GoogleAnalyticsUniversalTracker = GoogleAnalyticsUniversalTracker

global.GOVUK = GOVUK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,12 @@ describe('GOVUK.GoogleAnalyticsUniversalTracker', function () {
})

describe('when tracking all events', function () {
window.history.replaceState(null, null, '[email protected]')
it('removes any email address from the location', function () {
window.history.replaceState(null, null, '[email protected]&postcode=sw11wa&date=2019-01-01')

it('removes any pii from the location', function () {
expect(window.ga.calls.mostRecent().args[2]).toContain('address=[email]')
expect(window.ga.calls.mostRecent().args[2]).toContain('postcode=[postcode]')
expect(window.ga.calls.mostRecent().args[2]).toContain('date=[date]')
})
})

Expand Down

0 comments on commit 6fdbc9f

Please sign in to comment.