Skip to content

Commit

Permalink
Add GA4 redaction to GWF and GB EORI numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Sep 16, 2024
1 parent 47ab761 commit 74da2ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
var UNLOCK_TOKEN_PATTERN = /unlock_token=[a-zA-Z0-9-]+/g
var STATE_PATTERN = /state=.[^&]+/g

// prevent visa application IDs from being tracked, as some mistakenly use GOV.UK. to search for these.
var VISA_PATTERN_GWF = /GWF\d{9}/g
var VISA_PATTERN_GB = /GB\d{12}/g

function shouldStripDates () {
var metas = document.querySelectorAll('meta[name="govuk:ga4-strip-dates"]')
return metas.length > 0
Expand Down Expand Up @@ -97,6 +101,8 @@
stripped = stripped.replace(RESET_PASSWORD_TOKEN_PATTERN, 'reset_password_token=[reset_password_token]')
stripped = stripped.replace(UNLOCK_TOKEN_PATTERN, 'unlock_token=[unlock_token]')
stripped = stripped.replace(STATE_PATTERN, 'state=[state]')
stripped = stripped.replace(VISA_PATTERN_GWF, '[gwf number]')
stripped = stripped.replace(VISA_PATTERN_GB, '[gb eori number]')
stripped = this.stripQueryStringParameters(stripped)

if (this.stripDatePII === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ describe('GOVUK.analyticsGa4.PIIRemover', function () {
arr = pii.stripPII(arr)
expect(arr).toEqual(strippedArr)
})

it('strips visa application numbers', function () {
var string = pii.stripPII('my visa application numbers are GWF123456789 and GB123456789000')
expect(string).toEqual('my visa application numbers are [gwf number] and [gb eori number]')
})
})

describe('by default for account specific PII', function () {
Expand Down

0 comments on commit 74da2ea

Please sign in to comment.