govuk_publishing_components 30.7.1 → 30.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5541caeb04840db83172565a1e2f4f8f572850a113132c5e67d3d46ab00caf1e
4
- data.tar.gz: 81d4933ed8632f6bcc89a575a7a208e4575b7a842d0aa844bbfce317a69de9f9
3
+ metadata.gz: 5a0126e6016869d447d661d4e1c4777d68a10292c19e388bcb22477021877b7b
4
+ data.tar.gz: e83f7124df4f9126819c1f11310bfda63dde08be6c57749ead9395eef1d58ea0
5
5
  SHA512:
6
- metadata.gz: 6f8eea00f619818ebbbf6f83a3ffcb63b7d06c62dda8f45aab579f2b13ae363864ff8dbd4cabdcdac331e1fa95174660a9709e845b972aa06c6be8c9f550d439
7
- data.tar.gz: da2bb07ca8ab25c753f29af58965afb1dea0cfd781f57e7aea2129fce4a26db90346858341f7d9ba7adb572b5f7867db3a45586d487b56b5b98e151d9932d21b
6
+ metadata.gz: 03ac390a2a2a9fa5378699daac0dab1a55551bee3ab995f159487c5a5d295a3ff139629fab6b9f0b95dc52bc4d89d5b941f867e00c20fe9562eafbb5d5af43ef
7
+ data.tar.gz: ee961b5da8eacf0d47567ae446a1c1741ea65576affbdeb84916bb48a64064de8383c1ad64de86da84def9ad5f13c034c7893dca904a7a64e8405b0133754e37
@@ -1,3 +1,5 @@
1
+ // note that because this file is .js.erb it is not linted
2
+ // temporarily rename to .js to check with the linter
1
3
  window.GOVUK = window.GOVUK || {}
2
4
  window.GOVUK.analyticsGA4 = window.GOVUK.analyticsGA4 || {};
3
5
 
@@ -6,14 +8,45 @@ window.GOVUK.analyticsGA4 = window.GOVUK.analyticsGA4 || {};
6
8
 
7
9
  var core = {
8
10
  load: function () {
9
- /* eslint-disable */
10
- (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
11
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
12
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
13
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl+ '&gtm_auth=' + window.GOVUK.analyticsGA4.vars.auth + '&gtm_preview=' + window.GOVUK.analyticsGA4.vars.preview + '&gtm_cookies_win=x';f.parentNode.insertBefore(j,f);
14
- })(window,document,'script','dataLayer',window.GOVUK.analyticsGA4.vars.id);
15
- window.dataLayer.push({ 'gtm.blocklist' : ['customPixels', 'customScripts', 'html', 'nonGoogleScripts'] })
16
- /* eslint-enable */
11
+ var firstScript
12
+ var newScript
13
+
14
+ if (window.GOVUK.analyticsGA4.vars.gtag_id) {
15
+ // initialise gtag
16
+ window.dataLayer = window.dataLayer || []
17
+ var gtag = function () { window.dataLayer.push(arguments) }
18
+ gtag('js', new Date())
19
+ gtag('config', window.GOVUK.analyticsGA4.vars.gtag_id)
20
+
21
+ firstScript = document.getElementsByTagName('script')[0]
22
+ newScript = document.createElement('script')
23
+
24
+ newScript.async = true
25
+ newScript.src = '//www.googletagmanager.com/gtag/js?id=' + window.GOVUK.analyticsGA4.vars.gtag_id
26
+ firstScript.parentNode.insertBefore(newScript, firstScript)
27
+ } else {
28
+ // initialise GTM
29
+ window.dataLayer = window.dataLayer || []
30
+ window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' })
31
+
32
+ firstScript = document.getElementsByTagName('script')[0]
33
+ newScript = document.createElement('script')
34
+
35
+ var auth = window.GOVUK.analyticsGA4.vars.auth || ''
36
+ var preview = window.GOVUK.analyticsGA4.vars.preview || ''
37
+ if (auth) {
38
+ auth = '&gtm_auth=' + auth
39
+ }
40
+ if (preview) {
41
+ preview = '&gtm_preview=' + preview + '&gtm_cookies_win=x'
42
+ }
43
+
44
+ newScript.async = true
45
+ this.googleSrc = 'https://www.googletagmanager.com/gtm.js?id=' + window.GOVUK.analyticsGA4.vars.id + auth + preview
46
+ newScript.src = this.googleSrc
47
+ firstScript.parentNode.insertBefore(newScript, firstScript)
48
+ window.dataLayer.push({ 'gtm.blocklist': ['customPixels', 'customScripts', 'html', 'nonGoogleScripts'] })
49
+ }
17
50
  },
18
51
 
19
52
  sendData: function (data) {
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "30.7.1".freeze
2
+ VERSION = "30.7.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 30.7.1
4
+ version: 30.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-22 00:00:00.000000000 Z
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config