@graphcommerce/googleanalytics 8.1.0-canary.47 → 8.1.0-canary.49
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 +9 -0
- package/index.ts +1 -0
- package/package.json +12 -12
- package/plugins/GoogleAnalyticsTag.tsx +23 -10
- package/components/GoogleAnalyticsScript.tsx +0 -21
- package/components/index.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.1.0-canary.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2317](https://github.com/graphcommerce-org/graphcommerce/pull/2317) [`2f4a61d`](https://github.com/graphcommerce-org/graphcommerce/commit/2f4a61dfee853579c96fceb5351e459aa9524a60) - Moved import locations of Google Analytics and Google Tagmanager scripts to their recommended locations
|
|
8
|
+
([@paales](https://github.com/paales))
|
|
9
|
+
|
|
10
|
+
## 8.1.0-canary.48
|
|
11
|
+
|
|
3
12
|
## 8.1.0-canary.47
|
|
4
13
|
|
|
5
14
|
## 8.1.0-canary.46
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/googleanalytics",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "8.1.0-canary.
|
|
5
|
+
"version": "8.1.0-canary.49",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@graphcommerce/google-datalayer": "8.1.0-canary.
|
|
15
|
+
"@graphcommerce/google-datalayer": "8.1.0-canary.49"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.
|
|
19
|
-
"@graphcommerce/graphql-mesh": "^8.1.0-canary.
|
|
20
|
-
"@graphcommerce/magento-cart": "^8.1.0-canary.
|
|
21
|
-
"@graphcommerce/magento-cart-payment-method": "^8.1.0-canary.
|
|
22
|
-
"@graphcommerce/magento-cart-shipping-method": "^8.1.0-canary.
|
|
23
|
-
"@graphcommerce/magento-product": "^8.1.0-canary.
|
|
24
|
-
"@graphcommerce/next-config": "^8.1.0-canary.
|
|
25
|
-
"@graphcommerce/next-ui": "^8.1.0-canary.
|
|
26
|
-
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.
|
|
27
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.
|
|
18
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.49",
|
|
19
|
+
"@graphcommerce/graphql-mesh": "^8.1.0-canary.49",
|
|
20
|
+
"@graphcommerce/magento-cart": "^8.1.0-canary.49",
|
|
21
|
+
"@graphcommerce/magento-cart-payment-method": "^8.1.0-canary.49",
|
|
22
|
+
"@graphcommerce/magento-cart-shipping-method": "^8.1.0-canary.49",
|
|
23
|
+
"@graphcommerce/magento-product": "^8.1.0-canary.49",
|
|
24
|
+
"@graphcommerce/next-config": "^8.1.0-canary.49",
|
|
25
|
+
"@graphcommerce/next-ui": "^8.1.0-canary.49",
|
|
26
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.49",
|
|
27
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.49",
|
|
28
28
|
"@mui/material": "^5.10.16",
|
|
29
29
|
"next": "*",
|
|
30
30
|
"react": "^18.2.0",
|
|
@@ -1,23 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const ifConfig: IfConfig = 'googleAnalyticsId'
|
|
1
|
+
/* eslint-disable @next/next/no-document-import-in-page */
|
|
2
|
+
/* eslint-disable @next/next/next-script-for-ga */
|
|
3
|
+
/* eslint-disable react/no-danger */
|
|
4
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
|
5
|
+
import { storefrontConfig } from '@graphcommerce/next-ui/server'
|
|
6
|
+
import type { DocumentProps } from 'next/document'
|
|
8
7
|
|
|
9
8
|
export const config: PluginConfig = {
|
|
10
9
|
type: 'component',
|
|
11
|
-
module: '@graphcommerce/
|
|
10
|
+
module: '@graphcommerce/next-ui/server',
|
|
12
11
|
ifConfig: 'googleAnalyticsId',
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export function
|
|
14
|
+
export function DocumentHeadEnd(props: PluginProps<DocumentProps>) {
|
|
16
15
|
const { Prev, ...rest } = props
|
|
17
16
|
|
|
17
|
+
const id =
|
|
18
|
+
storefrontConfig(rest.locale)?.googleAnalyticsId ?? import.meta.graphCommerce.googleAnalyticsId
|
|
19
|
+
|
|
18
20
|
return (
|
|
19
21
|
<>
|
|
20
|
-
<
|
|
22
|
+
<script async src='https://www.googletagmanager.com/gtag/js?id=G-E0275MGY12' />
|
|
23
|
+
<script
|
|
24
|
+
dangerouslySetInnerHTML={{
|
|
25
|
+
__html: `
|
|
26
|
+
window.dataLayer = window.dataLayer || [];
|
|
27
|
+
function gtag(){dataLayer.push(arguments);}
|
|
28
|
+
gtag('js', new Date());
|
|
29
|
+
|
|
30
|
+
gtag('config', '${id}');
|
|
31
|
+
`,
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
21
34
|
<Prev {...rest} />
|
|
22
35
|
</>
|
|
23
36
|
)
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useStorefrontConfig } from '@graphcommerce/next-ui'
|
|
2
|
-
import Script from 'next/script'
|
|
3
|
-
|
|
4
|
-
export function GoogleAnalyticsScript() {
|
|
5
|
-
const id = useStorefrontConfig().googleAnalyticsId ?? import.meta.graphCommerce.googleAnalyticsId
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
<Script
|
|
10
|
-
strategy='afterInteractive'
|
|
11
|
-
src={`https://www.googletagmanager.com/gtag/js?id=${id}`}
|
|
12
|
-
/>
|
|
13
|
-
<Script id='gtag' strategy='afterInteractive'>{`
|
|
14
|
-
window.dataLayer = window.dataLayer || [];
|
|
15
|
-
function gtag(){dataLayer.push(arguments);}
|
|
16
|
-
gtag('js', new Date());
|
|
17
|
-
gtag('config', '${id}', { 'debug_mode':true });
|
|
18
|
-
`}</Script>
|
|
19
|
-
</>
|
|
20
|
-
)
|
|
21
|
-
}
|
package/components/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './GoogleAnalyticsScript'
|