govuk_frontend_toolkit 3.5.0 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,13 @@
1
+ #3.5.1
2
+ - Changes Analytics API library to accept one, both or neither of the
3
+ analytics tracking codes. This means we can start removing classic
4
+ tracking codes from apps.
5
+
6
+
1
7
  #3.5.0
2
8
 
3
9
  - Adds cross domain tracking to Analytics API library: https://github.com/alphagov/govuk_frontend_toolkit/pull/185
10
+ - Adds sass variables for discovery and live phases
4
11
 
5
12
  #3.4.2
6
13
 
@@ -1 +1 @@
1
- 3.5.0
1
+ 3.5.1
@@ -18,6 +18,7 @@ The minimum you need to use the analytics function is:
18
18
  * google-analytics-universal-tracker.js
19
19
  * tracker.js
20
20
  2. Copy the following `init` script into your own project and replace the dummy IDs with your own (they begin with `UA-`).
21
+ * Tracker.js accepts one or both analytics tracking code, so if you are only using one type of analytics (Classic or Universal) omit the one you don't need from the instantiation of GOVUK.Tracker. (NB you will still need to include both google-analytics-classic-tracker.js and google-analytics-universal-tracker.js in your project as they are currently loaded ahead of instantiation.)
21
22
  * This initialisation can occur immediately as this API has no dependencies.
22
23
  * Load and create the analytics tracker at the earliest opportunity so that:
23
24
  * the time until the first pageview is tracked is kept small and pageviews aren’t missed
@@ -121,7 +121,10 @@
121
121
  // Match tracker and universal API
122
122
  GoogleAnalyticsClassicTracker.prototype.setDimension = function(index, value, name, scope) {
123
123
  this.setCustomVariable(index, value, name, scope);
124
- }
124
+ };
125
+
126
+ // Match tracker and universal API
127
+ GoogleAnalyticsClassicTracker.prototype.addLinkedTrackerDomain = function() {};
125
128
 
126
129
  GOVUK.GoogleAnalyticsClassicTracker = GoogleAnalyticsClassicTracker;
127
130
  })();
@@ -6,8 +6,13 @@
6
6
  // https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/analytics.md#create-an-analytics-tracker
7
7
 
8
8
  var Tracker = function(config) {
9
- this.universal = new GOVUK.GoogleAnalyticsUniversalTracker(config.universalId, config.cookieDomain);
10
- this.classic = new GOVUK.GoogleAnalyticsClassicTracker(config.classicId, config.cookieDomain);
9
+ this.trackers = [];
10
+ if (typeof config.universalId != 'undefined') {
11
+ this.trackers.push(new GOVUK.GoogleAnalyticsUniversalTracker(config.universalId, config.cookieDomain));
12
+ }
13
+ if (typeof config.classicId != 'undefined') {
14
+ this.trackers.push(new GOVUK.GoogleAnalyticsClassicTracker(config.classicId, config.cookieDomain));
15
+ }
11
16
  };
12
17
 
13
18
  Tracker.load = function() {
@@ -16,8 +21,9 @@
16
21
  };
17
22
 
18
23
  Tracker.prototype.trackPageview = function(path, title) {
19
- this.classic.trackPageview(path);
20
- this.universal.trackPageview(path, title);
24
+ for (var i=0; i < this.trackers.length; i++) {
25
+ this.trackers[i].trackPageview(path, title);
26
+ }
21
27
  };
22
28
 
23
29
  /*
@@ -27,14 +33,16 @@
27
33
  options.nonInteraction – Prevent event from impacting bounce rate
28
34
  */
29
35
  Tracker.prototype.trackEvent = function(category, action, options) {
30
- this.classic.trackEvent(category, action, options);
31
- this.universal.trackEvent(category, action, options);
36
+ for (var i=0; i < this.trackers.length; i++) {
37
+ this.trackers[i].trackEvent(category, action, options);
38
+ }
32
39
  };
33
40
 
34
41
  Tracker.prototype.trackShare = function(network) {
35
42
  var target = location.pathname;
36
- this.classic.trackSocial(network, 'share', target);
37
- this.universal.trackSocial(network, 'share', target);
43
+ for (var i=0; i < this.trackers.length; i++) {
44
+ this.trackers[i].trackSocial(network, 'share', target);
45
+ }
38
46
  };
39
47
 
40
48
  /*
@@ -42,15 +50,18 @@
42
50
  Check this for your app before using this
43
51
  */
44
52
  Tracker.prototype.setDimension = function(index, value, name, scope) {
45
- this.universal.setDimension(index, value);
46
- this.classic.setCustomVariable(index, value, name, scope);
53
+ for (var i=0; i < this.trackers.length; i++) {
54
+ this.trackers[i].setDimension(index, value, name, scope);
55
+ }
47
56
  };
48
57
 
49
58
  /*
50
59
  Add a beacon to track a page in another GA account on another domain.
51
60
  */
52
61
  Tracker.prototype.addLinkedTrackerDomain = function(trackerId, name, domain) {
53
- this.universal.addLinkedTrackerDomain(trackerId, name, domain);
62
+ for (var i=0; i < this.trackers.length; i++) {
63
+ this.trackers[i].addLinkedTrackerDomain(trackerId, name, domain);
64
+ }
54
65
  };
55
66
 
56
67
  GOVUK.Tracker = Tracker;
@@ -6,12 +6,19 @@ var manifest = {
6
6
  '../../javascripts/govuk/primary-links.js',
7
7
  '../../javascripts/govuk/stick-at-top-when-scrolling.js',
8
8
  '../../javascripts/govuk/stop-scrolling-at-footer.js',
9
- '../../javascripts/govuk/selection-buttons.js'
9
+ '../../javascripts/govuk/selection-buttons.js',
10
+ '../../javascripts/govuk/analytics/google-analytics-classic-tracker.js',
11
+ '../../javascripts/govuk/analytics/google-analytics-universal-tracker.js',
12
+ '../../javascripts/govuk/analytics/tracker.js'
13
+
10
14
  ],
11
15
  test : [
12
16
  '../unit/MultivariateTestSpec.js',
13
17
  '../unit/PrimaryLinksSpec.js',
14
18
  '../unit/StickAtTopWhenScrollingSpec.js',
15
- '../unit/SelectionButtonSpec.js'
19
+ '../unit/SelectionButtonSpec.js',
20
+ '../unit/analytics/GoogleAnalyticsClassicTrackerSpec.js',
21
+ '../unit/analytics/GoogleAnalyticsUniversalTrackerSpec.js',
22
+ '../unit/analytics/TrackerSpec.js'
16
23
  ]
17
24
  };
@@ -3,16 +3,16 @@
3
3
  <head>
4
4
  <title>Jasmine Test Runner</title>
5
5
 
6
- <link rel="stylesheet" type="text/css" href="../../node_modules/grunt-contrib-jasmine/vendor/jasmine-1.3.1/jasmine.css">
6
+ <link rel="stylesheet" type="text/css" href="../../node_modules/grunt-contrib-jasmine/vendor/jasmine-2.0.1/jasmine.css">
7
7
  <style>
8
8
  #wrapper { display: none; }
9
9
  </style>
10
10
 
11
11
  <!-- JASMINE FILES -->
12
- <script type="text/javascript" src="../../node_modules/grunt-contrib-jasmine/vendor/jasmine-1.3.1/jasmine.js"></script>
13
- <script type="text/javascript" src="../../node_modules/grunt-contrib-jasmine/vendor/jasmine-1.3.1/jasmine-html.js"></script>
12
+ <script type="text/javascript" src="../../node_modules/grunt-contrib-jasmine/vendor/jasmine-2.0.1/jasmine.js"></script>
13
+ <script type="text/javascript" src="../../node_modules/grunt-contrib-jasmine/vendor/jasmine-2.0.1/jasmine-html.js"></script>
14
14
 
15
- <script type="text/javascript" src="./console-runner.js"></script>
15
+ <script type="text/javascript" src="../../node_modules/grunt-contrib-jasmine/vendor/jasmine-2.0.1/boot.js"></script>
16
16
  <script type="text/javascript" src="./load.js"></script>
17
17
  </head>
18
18
  <body>
@@ -1,5 +1,5 @@
1
1
  (function (root) {
2
- "use strict";
2
+ "use strict"
3
3
  var loadedScripts = 0,
4
4
  totalScripts,
5
5
  merge,
@@ -22,7 +22,7 @@
22
22
  };
23
23
  loadScript = function (src, nextIdx) {
24
24
  var script = document.createElement('script'),
25
- nextScript;
25
+ nextScript;
26
26
 
27
27
  script.type = 'text/javascript';
28
28
  script.src = src;
@@ -32,23 +32,15 @@
32
32
  script.onload = function () {
33
33
  if (nextIdx < totalScripts.length) {
34
34
  loadScript(totalScripts[nextIdx], nextIdx + 1);
35
- } else {
36
- runJasmine();
37
35
  }
38
36
  };
39
37
  return script;
40
38
  };
41
- runJasmine = function () {
42
- var console_reporter = new jasmine.ConsoleReporter();
43
- jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
44
- jasmine.getEnv().addReporter(console_reporter);
45
- jasmine.getEnv().execute();
46
- };
47
39
  manifestScript = loadScript('../manifest.js');
48
40
 
49
41
  manifestScript.onload = function () {
50
42
  var idx = 0;
51
-
43
+
52
44
  totalScripts = merge([manifest.support, manifest.test]);
53
45
  loadScript(totalScripts[idx], idx + 1);
54
46
  };
@@ -25,6 +25,26 @@ describe("GOVUK.Tracker", function() {
25
25
  expect(window._gaq[1]).toEqual(['_setDomainName', '.www.gov.uk']);
26
26
  expect(universalSetupArguments[0]).toEqual(['create', 'universal-id', {'cookieDomain': '.www.gov.uk'}]);
27
27
  });
28
+
29
+ });
30
+
31
+ describe('when created with only universal analytics', function() {
32
+ var universalSetupArguments;
33
+
34
+ beforeEach(function () {
35
+ });
36
+
37
+ it ('doesn\'t require both trackers to be present', function() {
38
+ universalOnlyConfig = { universalId: 'universal-id',
39
+ cookieDomain: '.www.gov.uk'
40
+ };
41
+
42
+ var tracker = new GOVUK.Tracker(universalOnlyConfig);
43
+
44
+ universalSetupArguments = window.ga.calls.allArgs();
45
+ expect(typeof(window._gaq[0])).toEqual('undefined');
46
+ expect(universalSetupArguments[0]).toEqual(['create', 'universal-id', {'cookieDomain': '.www.gov.uk'}]);
47
+ });
28
48
  });
29
49
 
30
50
  describe('when tracking pageviews, events and custom dimensions', function() {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_frontend_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-06 00:00:00.000000000 Z
12
+ date: 2015-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -288,7 +288,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
288
  version: '0'
289
289
  segments:
290
290
  - 0
291
- hash: -3226103132821622177
291
+ hash: 609319140606558990
292
292
  required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  none: false
294
294
  requirements:
@@ -297,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
297
  version: '0'
298
298
  segments:
299
299
  - 0
300
- hash: -3226103132821622177
300
+ hash: 609319140606558990
301
301
  requirements: []
302
302
  rubyforge_project:
303
303
  rubygems_version: 1.8.23