Skip to content

Commit

Permalink
Merge pull request #4227 from alphagov/ga4-redact-visas
Browse files Browse the repository at this point in the history
Add GA4 redaction to GWF and GB EORI numbers
  • Loading branch information
AshGDS committed Sep 17, 2024
2 parents 6321786 + 69f9da3 commit 487cd72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Fix cookie expiration date potentially relying on user's timezone ([PR #4219](https://github.com/alphagov/govuk_publishing_components/pull/4219))
* Stop redacting dates in GA4 tracking on GOVUK search pages ([PR #4223](https://github.com/alphagov/govuk_publishing_components/pull/4223))
* Remove 100 character limit on search results ([PR #4230](https://github.com/alphagov/govuk_publishing_components/pull/4230))
* Add GA4 redaction to GWF and GB EORI numbers ([PR #4227](https://github.com/alphagov/govuk_publishing_components/pull/4227))

## 43.1.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
var UNLOCK_TOKEN_PATTERN = /unlock_token=[a-zA-Z0-9-]+/g
var STATE_PATTERN = /state=.[^&]+/g

// some users mistakenly use GOV.UK to search for the status of their applications.
// e.g. GWF123456789 and GB123456789000
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 +102,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 487cd72

Please sign in to comment.