Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GA4 redaction to GWF and GB EORI numbers #4227

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Set aria-label text in govuk_logo.html to "GOV.UK" ([PR #4217](https://github.com/alphagov/govuk_publishing_components/pull/4217))
* Fix cookie expiration date potentially relying on user's timezone ([PR #4219](https://github.com/alphagov/govuk_publishing_components/pull/4219))
* 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: might help to add to this comment an example of the numbers this should match.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I've just noticed there's some in the spec file, so 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, will add more specific examples then merge 👍

// 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
Loading