govuk_frontend_toolkit 7.3.0 → 7.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/CHANGELOG.md +5 -0
- data/app/assets/README.md +14 -6
- data/app/assets/VERSION.txt +1 -1
- data/app/assets/docs/analytics.md +19 -0
- data/app/assets/javascripts/govuk/analytics/analytics.js +14 -5
- data/app/assets/spec/unit/analytics/analytics.spec.js +43 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7d913fed9e8375459ac2c0cb48ba26fd4bea526a38faa372ca84cbcb0333e2b
|
4
|
+
data.tar.gz: 87d5bacfb307d6586cb334764aa31e5165a4720320374905023498c273ed95a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb987f4d033bd8089be306d3301fb5f93c07ff0fbcc52f5d5938b006413312184d31893fb48869e9d4fcd324a21de6358830f8fa4112f21c5d548a7a848b6af7
|
7
|
+
data.tar.gz: 0340fecd6ab4340d6fdfb47dd7ed6d76b867ab45cd39bd6c5846330a1836c0b414f8f981af5bc0bdeb73da8f93b2cb04c91e02b4a94fb12f3b51a684fed50688
|
data/app/assets/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 7.4.0
|
2
|
+
|
3
|
+
- Allow wrapping arguments to analytics as PII safe to tell the analytics code not to attempt to strip PII from the values: ([PR #448](https://github.com/alphagov/govuk_frontend_toolkit/pull/448))
|
4
|
+
- Documentation improvements: ([PR #446](https://github.com/alphagov/govuk_frontend_toolkit/pull/446), [PR #447](https://github.com/alphagov/govuk_frontend_toolkit/pull/447))
|
5
|
+
|
1
6
|
# 7.3.0
|
2
7
|
|
3
8
|
- Strip PII from all arguments passed to GA. Emails are stripped by default, postcodes can also be stripped if configured to do so: ([PR #435](https://github.com/alphagov/govuk_frontend_toolkit/pull/435)).
|
data/app/assets/README.md
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
# GOV.UK frontend toolkit
|
2
2
|
|
3
|
-
---
|
4
|
-
|
5
|
-
#### You can help us improve the GOV.UK frontend toolkit by completing our [5 minute survey](https://www.surveymonkey.co.uk/r/2MZRS9H).
|
6
|
-
|
7
|
-
---
|
8
|
-
|
9
3
|
A collection of Sass and JavaScript files for using as part of your
|
10
4
|
application's frontend.
|
11
5
|
|
@@ -39,6 +33,20 @@ may need to upgrade to a more recent version to use the grid helpers. Minimal
|
|
39
33
|
compatible versions include `node-sass` 1.0.0, `grunt-sass` 0.16.0,
|
40
34
|
`gulp-sass` 1.2.0 and `libsass` 3.0.0.
|
41
35
|
|
36
|
+
### Django
|
37
|
+
|
38
|
+
Requirement: [NodeJS](https://nodejs.org/en/) installed. This gives you [Node Package Manager](https://docs.npmjs.com/getting-started/installing-node)(NPM) which is required to install npm packages.
|
39
|
+
|
40
|
+
The easiest way to integrate it would be to create a `package.json` file in your application with `npm init`
|
41
|
+
|
42
|
+
You then install the toolkit with `npm install --save govuk_frontend_toolkit`.
|
43
|
+
If you need javascript files, they will live in (`node_modules/govuk_frontend_toolkit/javascripts`).
|
44
|
+
If you need stylesheets they will live in (`node_modules/govuk_frontend_toolkit/stylesheets`).
|
45
|
+
|
46
|
+
With Django you can use https://github.com/jrief/django-sass-processor to compile Sass files.
|
47
|
+
|
48
|
+
Note: if you need complete styles you might want to install govuk-elements-sass package that also installs toolkit
|
49
|
+
|
42
50
|
### Composer
|
43
51
|
|
44
52
|
[govuk_frontend_toolkit_composer][toolkit_composer_github] is an composer package that can be
|
data/app/assets/VERSION.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.4.0
|
@@ -249,3 +249,22 @@ initialize time as follows:
|
|
249
249
|
|
250
250
|
Any value other than the JS literal `true` for `stripPostcodePII` will leave
|
251
251
|
the analytics module configured not to strip postcodes.
|
252
|
+
|
253
|
+
#### Avoding false positives
|
254
|
+
|
255
|
+
Sometimes you will have data you want to send to analytics that looks like PII
|
256
|
+
and would be stripped out. For example on GOV.UK the content_ids that belong
|
257
|
+
to every document can sometimes contain a string of characters that look like a
|
258
|
+
UK postcode: in `eed5b92e-8279-4ca9-a141-5c35ed22fcf1` the substring `c35ed` in
|
259
|
+
the final portion looks like a postcode, `C3 5ED`, and will be transformed into
|
260
|
+
`eed5b92e-8279-4ca9-a141-5[postcode]22fcf1` which breaks the `content_id`. To
|
261
|
+
send data that you know is not PII, but it looks like an email address or a UK
|
262
|
+
postcode you can provide your arguments wrapped in a `GOVUK.Analytics.PIISafe`
|
263
|
+
object. If any argument to an analytics function is an instance of one of these
|
264
|
+
objects the value contained within will be extracted and sent directly to the
|
265
|
+
analytics tracker without attempting to strip PII from it. For example:
|
266
|
+
|
267
|
+
```js
|
268
|
+
GOVUK.analytics.setDimension(1, new GOVUK.Analytics.PIISafe('this-is-not-an@email-address-but-it-looks-like-one'));
|
269
|
+
GOVUK.analytics.trackEvent('report title clicked', new GOVUK.Analytics.PIISafe('this report title looks like it contains a P0 5TC ode but it does not really'));
|
270
|
+
````
|
@@ -29,10 +29,15 @@
|
|
29
29
|
}
|
30
30
|
}
|
31
31
|
|
32
|
+
var PIISafe = function (value) {
|
33
|
+
this.value = value
|
34
|
+
}
|
35
|
+
Analytics.PIISafe = PIISafe
|
36
|
+
|
32
37
|
Analytics.prototype.stripPII = function (value) {
|
33
38
|
if (typeof value === 'string') {
|
34
39
|
return this.stripPIIFromString(value)
|
35
|
-
} else if (Object.prototype.toString.call(value) === '[object Array]') {
|
40
|
+
} else if (Object.prototype.toString.call(value) === '[object Array]' || Object.prototype.toString.call(value) === '[object Arguments]') {
|
36
41
|
return this.stripPIIFromArray(value)
|
37
42
|
} else if (typeof value === 'object') {
|
38
43
|
return this.stripPIIFromObject(value)
|
@@ -51,12 +56,16 @@
|
|
51
56
|
}
|
52
57
|
|
53
58
|
Analytics.prototype.stripPIIFromObject = function (object) {
|
54
|
-
|
55
|
-
|
59
|
+
if (object instanceof Analytics.PIISafe) {
|
60
|
+
return object.value
|
61
|
+
} else {
|
62
|
+
for (var property in object) {
|
63
|
+
var value = object[property]
|
56
64
|
|
57
|
-
|
65
|
+
object[property] = this.stripPII(value)
|
66
|
+
}
|
67
|
+
return object
|
58
68
|
}
|
59
|
-
return object
|
60
69
|
}
|
61
70
|
|
62
71
|
Analytics.prototype.stripPIIFromArray = function (array) {
|
@@ -150,6 +150,24 @@ describe('GOVUK.Analytics', function () {
|
|
150
150
|
analytics.setDimension(1, 'SW1+1AA-value', { label: 'RG209NJ', value: ['data', 'data', 'someone has added their personalIV63 6TU postcode'] })
|
151
151
|
expect(window.ga.calls.mostRecent().args).toEqual(['set', 'dimension1', '[postcode]-value']) // set dimension ignores extra options
|
152
152
|
})
|
153
|
+
|
154
|
+
it('ignores any PIISafe arguments even if they look like emails or postcodes', function () {
|
155
|
+
analytics = new GOVUK.Analytics({
|
156
|
+
universalId: 'universal-id',
|
157
|
+
cookieDomain: '.www.gov.uk',
|
158
|
+
siteSpeedSampleRate: 100,
|
159
|
+
stripPostcodePII: true
|
160
|
+
})
|
161
|
+
|
162
|
+
analytics.trackPageview(new GOVUK.Analytics.PIISafe('/path/to/an/embedded/SW1+1AA/postcode/?with=an&postcode=SP4%207DE'), new GOVUK.Analytics.PIISafe('an.email@example.com'), { label: new GOVUK.Analytics.PIISafe('another.email@example.com'), value: ['data', 'data', new GOVUK.Analytics.PIISafe('someone has added their personalIV63 6TU postcode')] })
|
163
|
+
expect(window.ga.calls.mostRecent().args).toEqual(['send', 'pageview', { page: '/path/to/an/embedded/SW1+1AA/postcode/?with=an&postcode=SP4%207DE', title: 'an.email@example.com', label: 'another.email@example.com', value: ['data', 'data', 'someone has added their personalIV63 6TU postcode'] }])
|
164
|
+
|
165
|
+
analytics.trackEvent(new GOVUK.Analytics.PIISafe('SW1+1AA-category'), new GOVUK.Analytics.PIISafe('an.email@example.com-action'), { label: new GOVUK.Analytics.PIISafe('RG209NJ'), value: ['data', 'data', 'someone has added their personalIV63 6TU postcode'] })
|
166
|
+
expect(window.ga.calls.mostRecent().args).toEqual(['send', { hitType: 'event', eventCategory: 'SW1+1AA-category', eventAction: 'an.email@example.com-action', eventLabel: 'RG209NJ' }]) // trackEvent ignores options other than label or integer values for value
|
167
|
+
|
168
|
+
analytics.setDimension(1, new GOVUK.Analytics.PIISafe('an.email@SW1+1AA-value.com'), { label: new GOVUK.Analytics.PIISafe('RG209NJ'), value: ['data', 'data', new GOVUK.Analytics.PIISafe('someone has added their personalIV63 6TU postcode')] })
|
169
|
+
expect(window.ga.calls.mostRecent().args).toEqual(['set', 'dimension1', 'an.email@SW1+1AA-value.com']) // set dimension ignores extra options
|
170
|
+
})
|
153
171
|
})
|
154
172
|
|
155
173
|
describe('when tracking social media shares', function () {
|
@@ -224,6 +242,31 @@ describe('GOVUK.Analytics', function () {
|
|
224
242
|
value: ['data', 'data', 'someone has added their personal[postcode] postcode']
|
225
243
|
}])
|
226
244
|
})
|
245
|
+
|
246
|
+
it('ignores any PIISafe arguments even if they look like emails or postcodes', function () {
|
247
|
+
analytics = new GOVUK.Analytics({
|
248
|
+
universalId: 'universal-id',
|
249
|
+
cookieDomain: '.www.gov.uk',
|
250
|
+
siteSpeedSampleRate: 100,
|
251
|
+
stripPostcodePII: true
|
252
|
+
})
|
253
|
+
|
254
|
+
analytics.trackShare('email', {
|
255
|
+
to: new GOVUK.Analytics.PIISafe('IV63 6TU'),
|
256
|
+
label: new GOVUK.Analytics.PIISafe('an.email@example.com'),
|
257
|
+
value: new GOVUK.Analytics.PIISafe(['data', 'another.email@example.com', 'someone has added their personalTD15 2SE postcode'])
|
258
|
+
})
|
259
|
+
|
260
|
+
expect(window.ga.calls.mostRecent().args).toEqual(['send', {
|
261
|
+
hitType: 'social',
|
262
|
+
socialNetwork: 'email',
|
263
|
+
socialAction: 'share',
|
264
|
+
socialTarget: jasmine.any(String),
|
265
|
+
to: 'IV63 6TU',
|
266
|
+
label: 'an.email@example.com',
|
267
|
+
value: ['data', 'another.email@example.com', 'someone has added their personalTD15 2SE postcode']
|
268
|
+
}])
|
269
|
+
})
|
227
270
|
})
|
228
271
|
|
229
272
|
describe('when adding a linked domain', function () {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_frontend_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|