@graphcommerce/googleanalytics 1.1.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,45 +1,49 @@
1
1
  # Change Log
2
2
 
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
3
+ ## 2.0.0
5
4
 
6
- ## [1.1.4](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/googleanalytics@1.1.3...@graphcommerce/googleanalytics@1.1.4) (2021-12-20)
7
-
8
-
9
- ### Bug Fixes
10
-
11
- * make sure analytics only tracks once on page load ([94def43](https://github.com/ho-nl/m2-pwa/commit/94def43db7075b6b039696612547c6b6ff7c7c6e))
12
- * make sure we're not loading gogole properties when keys are not given ([8636715](https://github.com/ho-nl/m2-pwa/commit/8636715d61985e0919208ffb64354c3ebb43ed01))
5
+ ### Major Changes
13
6
 
7
+ - [#1258](https://github.com/ho-nl/m2-pwa/pull/1258)
8
+ [`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)
9
+ Thanks [@paales](https://github.com/paales)! - Upgraded to Material UI 5
14
10
 
11
+ All notable changes to this project will be documented in this file. See
12
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
15
13
 
14
+ # [1.2.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/googleanalytics@1.1.4...@graphcommerce/googleanalytics@1.2.0) (2021-12-21)
16
15
 
16
+ ### Features
17
17
 
18
- ## [1.1.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/googleanalytics@1.1.1...@graphcommerce/googleanalytics@1.1.2) (2021-12-17)
18
+ - **googleanalytics:** moved to gtag
19
+ ([c586a8f](https://github.com/ho-nl/m2-pwa/commit/c586a8f66547cf7c332113e991a257181ce8d338))
19
20
 
21
+ ## [1.1.4](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/googleanalytics@1.1.3...@graphcommerce/googleanalytics@1.1.4) (2021-12-20)
20
22
 
21
23
  ### Bug Fixes
22
24
 
23
- * pageview with analytics not registered ([7cdb68d](https://github.com/ho-nl/m2-pwa/commit/7cdb68d9770a00044fa5a1f143fd05701ea72d59))
24
-
25
+ - make sure analytics only tracks once on page load
26
+ ([94def43](https://github.com/ho-nl/m2-pwa/commit/94def43db7075b6b039696612547c6b6ff7c7c6e))
27
+ - make sure we're not loading gogole properties when keys are not given
28
+ ([8636715](https://github.com/ho-nl/m2-pwa/commit/8636715d61985e0919208ffb64354c3ebb43ed01))
25
29
 
30
+ ## [1.1.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/googleanalytics@1.1.1...@graphcommerce/googleanalytics@1.1.2) (2021-12-17)
26
31
 
32
+ ### Bug Fixes
27
33
 
34
+ - pageview with analytics not registered
35
+ ([7cdb68d](https://github.com/ho-nl/m2-pwa/commit/7cdb68d9770a00044fa5a1f143fd05701ea72d59))
28
36
 
29
37
  ## [1.1.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/googleanalytics@1.1.0...@graphcommerce/googleanalytics@1.1.1) (2021-12-17)
30
38
 
31
-
32
39
  ### Bug Fixes
33
40
 
34
- * **googleanalytics:** make sure ga is defined ([787dd9f](https://github.com/ho-nl/m2-pwa/commit/787dd9f6945469e36ebf627213fdb5eefb8146cd))
35
-
36
-
37
-
38
-
41
+ - **googleanalytics:** make sure ga is defined
42
+ ([787dd9f](https://github.com/ho-nl/m2-pwa/commit/787dd9f6945469e36ebf627213fdb5eefb8146cd))
39
43
 
40
44
  # 1.1.0 (2021-12-17)
41
45
 
42
-
43
46
  ### Features
44
47
 
45
- * **googleanalytics:** created pacakge to support Google Analytics ([308b6df](https://github.com/ho-nl/m2-pwa/commit/308b6df1f216d2bc726c770a9ead039bd114a995))
48
+ - **googleanalytics:** created pacakge to support Google Analytics
49
+ ([308b6df](https://github.com/ho-nl/m2-pwa/commit/308b6df1f216d2bc726c770a9ead039bd114a995))
package/README.md CHANGED
@@ -7,8 +7,5 @@ webshop.
7
7
 
8
8
  1. Fill `NEXT_PUBLIC_GOOGLE_ANALYTICS` in your .env file
9
9
  [example](../../examples/magento-graphcms/.env.example)
10
- 2. Add `<GoogleTagManagerScript/>` to your `pages/_app.tsx` file.
10
+ 2. Add `<GoogleAnalyticsScript/>` to your `pages/_app.tsx` file.
11
11
  [example](../../examples/magento-graphcms/pages/_app.tsx)
12
- 3. Add `<GoogleTagManagerNoScript/>` to your `pages/_document.tsx` file, in the
13
- body section above `<Main />`
14
- [example](../../examples/magento-graphcms/pages/_document_.tsx)
@@ -1,6 +1,4 @@
1
- import { useRouter } from 'next/router'
2
1
  import Script from 'next/script'
3
- import React, { useEffect } from 'react'
4
2
 
5
3
  export default function GoogleAnalyticsScript() {
6
4
  const id = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS
@@ -8,22 +6,19 @@ export default function GoogleAnalyticsScript() {
8
6
  if (process.env.NODE_ENV !== 'production' && !id)
9
7
  console.warn('[@graphcommerce/googletagmanager]: NEXT_PUBLIC_GOOGLE_ANALYTICS not found')
10
8
 
11
- const router = useRouter()
12
-
13
- useEffect(() => {
14
- const onRouteChangeComplete = (url: string) => globalThis.ga?.('send', 'pageview', url)
15
- router.events.on('routeChangeComplete', onRouteChangeComplete)
16
- return () => router.events.off('routeChangeComplete', onRouteChangeComplete)
17
- }, [router.events])
18
-
19
9
  if (!id) return null
20
10
 
21
11
  return (
22
12
  <>
23
- <Script strategy='afterInteractive' src='https://www.google-analytics.com/analytics.js' />
24
- <Script id='google-analytics-init' strategy='afterInteractive'>{`
25
- window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
26
- ga('create', '${id}', 'auto');
13
+ <Script
14
+ strategy='afterInteractive'
15
+ src={`https://www.googletagmanager.com/gtag/js?id=${id}`}
16
+ />
17
+ <Script id='gtag' strategy='afterInteractive'>{`
18
+ window.dataLayer = window.dataLayer || [];
19
+ function gtag(){dataLayer.push(arguments);}
20
+ gtag('js', new Date());
21
+ gtag('config', '${id}');
27
22
  `}</Script>
28
23
  </>
29
24
  )
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "@graphcommerce/googleanalytics",
3
- "version": "1.1.4",
3
+ "version": "2.0.0",
4
4
  "sideEffects": false,
5
5
  "prettier": "@graphcommerce/prettier-config-pwa",
6
- "browserslist": [
7
- "extends @graphcommerce/browserslist-config-pwa"
8
- ],
9
6
  "eslintConfig": {
10
7
  "extends": "@graphcommerce/eslint-config-pwa",
11
8
  "parserOptions": {
@@ -13,16 +10,14 @@
13
10
  }
14
11
  },
15
12
  "devDependencies": {
16
- "@graphcommerce/browserslist-config-pwa": "^3.0.3",
17
- "@graphcommerce/eslint-config-pwa": "^3.1.9",
18
- "@graphcommerce/prettier-config-pwa": "^3.0.5",
19
- "@graphcommerce/typescript-config-pwa": "^3.1.2",
20
- "@types/google.analytics": "^0.0.42"
13
+ "@graphcommerce/eslint-config-pwa": "^4.0.0",
14
+ "@graphcommerce/prettier-config-pwa": "^4.0.0",
15
+ "@graphcommerce/typescript-config-pwa": "^4.0.0",
16
+ "@types/gtag.js": "^0.0.8"
21
17
  },
22
18
  "dependencies": {
23
- "next": "^12.0.7",
19
+ "next": "^12.0.10",
24
20
  "react": "^17.0.2",
25
21
  "react-dom": "^17.0.2"
26
- },
27
- "gitHead": "fb1eb0f747fea50f920970faf9020a3303066559"
22
+ }
28
23
  }