@graphcommerce/google-datalayer 8.1.0-canary.6 → 8.1.0-canary.8
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 +4 -0
- package/package.json +9 -9
- package/plugins/GoogleDatalayerCartStartCheckoutLinkOrButton.tsx +1 -1
- package/plugins/GoogleDatalayerPaymentMethodContextProvider.tsx +1 -2
- package/plugins/GoogleDatalayerProductListItem.tsx +2 -5
- package/plugins/GoogleDatalayerRemoveItemFromCart.tsx +7 -10
- package/plugins/GoogleDatalayerRemoveItemFromCartFab.tsx +7 -8
- package/plugins/GoogleDatalayerViewItem.tsx +3 -3
- package/plugins/GoogleDatalayerWebVitals.tsx +9 -8
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/google-datalayer",
|
|
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.8",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.
|
|
16
|
-
"@graphcommerce/magento-cart": "^8.1.0-canary.
|
|
17
|
-
"@graphcommerce/magento-cart-payment-method": "^8.1.0-canary.
|
|
18
|
-
"@graphcommerce/magento-cart-shipping-method": "^8.1.0-canary.
|
|
19
|
-
"@graphcommerce/magento-product": "^8.1.0-canary.
|
|
20
|
-
"@graphcommerce/next-ui": "^8.1.0-canary.
|
|
21
|
-
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.
|
|
22
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.8",
|
|
16
|
+
"@graphcommerce/magento-cart": "^8.1.0-canary.8",
|
|
17
|
+
"@graphcommerce/magento-cart-payment-method": "^8.1.0-canary.8",
|
|
18
|
+
"@graphcommerce/magento-cart-shipping-method": "^8.1.0-canary.8",
|
|
19
|
+
"@graphcommerce/magento-product": "^8.1.0-canary.8",
|
|
20
|
+
"@graphcommerce/next-ui": "^8.1.0-canary.8",
|
|
21
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.8",
|
|
22
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.8",
|
|
23
23
|
"@mui/material": "^5.14.20",
|
|
24
24
|
"next": "^14",
|
|
25
25
|
"react": "^18.2.0",
|
|
@@ -15,7 +15,7 @@ export function GoogleDatalayerCartStartCheckoutLinkOrButton(
|
|
|
15
15
|
<Prev
|
|
16
16
|
{...rest}
|
|
17
17
|
onStart={(e, cart) => {
|
|
18
|
-
sendEvent('begin_checkout', cartToBeginCheckout(cart))
|
|
18
|
+
if (cart) sendEvent('begin_checkout', cartToBeginCheckout(cart))
|
|
19
19
|
return onStart?.(e, cart)
|
|
20
20
|
}}
|
|
21
21
|
/>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { PaymentMethodContextProviderProps } from '@graphcommerce/magento-cart-payment-method'
|
|
2
2
|
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
|
-
import { purchase } from '../mapping/orderToPurchase'
|
|
4
|
-
import { orderToPurchase } from '../mapping/orderToPurchase/orderToPurchase'
|
|
5
3
|
import { sendEvent } from '../api/sendEvent'
|
|
4
|
+
import { orderToPurchase } from '../mapping/orderToPurchase/orderToPurchase'
|
|
6
5
|
|
|
7
6
|
export const component = 'PaymentMethodContextProvider'
|
|
8
7
|
export const exported = '@graphcommerce/magento-cart-payment-method'
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProductListItemProps } from '@graphcommerce/magento-product'
|
|
2
2
|
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { useEventCallback } from '@mui/material'
|
|
4
|
-
import { ComponentProps } from 'react'
|
|
5
4
|
import { useViewItemList } from '../components/DatalayerViewItemList'
|
|
6
5
|
|
|
7
6
|
export const component = 'ProductListItem'
|
|
8
7
|
export const exported = '@graphcommerce/magento-product'
|
|
9
8
|
|
|
10
|
-
function GoogleDatalayerProductListItem(
|
|
11
|
-
props: PluginProps<ComponentProps<typeof ProductListItem>>,
|
|
12
|
-
) {
|
|
9
|
+
function GoogleDatalayerProductListItem(props: PluginProps<ProductListItemProps>) {
|
|
13
10
|
const { Prev, onClick, ...rest } = props
|
|
14
11
|
const selectItem = useViewItemList()
|
|
15
12
|
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { RemoveItemFromCartProps } from '@graphcommerce/magento-cart-items'
|
|
2
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { sendEvent } from '../api/sendEvent'
|
|
4
4
|
import { cartItemToRemoveFromCart } from '../mapping/cartItemToRemoveFromCart/cartToRemoveFromCart'
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
'@graphcommerce/magento-cart-items
|
|
6
|
+
export const config: PluginConfig = {
|
|
7
|
+
type: 'component',
|
|
8
|
+
module: '@graphcommerce/magento-cart-items',
|
|
9
|
+
}
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
props,
|
|
12
|
-
) => {
|
|
11
|
+
export function RemoveItemFromCart(props: PluginProps<RemoveItemFromCartProps>) {
|
|
13
12
|
const { Prev, buttonProps } = props
|
|
14
13
|
|
|
15
14
|
return (
|
|
@@ -28,5 +27,3 @@ export const GoogleDatalayerRemoveItemFromCart: ReactPlugin<typeof RemoveItemFro
|
|
|
28
27
|
/>
|
|
29
28
|
)
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
export const Plugin = GoogleDatalayerRemoveItemFromCart
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { RemoveItemFromCartFabProps } from '@graphcommerce/magento-cart-items'
|
|
2
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { sendEvent } from '../api/sendEvent'
|
|
4
4
|
import { cartItemToRemoveFromCart } from '../mapping/cartItemToRemoveFromCart/cartToRemoveFromCart'
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
'@graphcommerce/magento-cart-items
|
|
6
|
+
export const config: PluginConfig = {
|
|
7
|
+
type: 'component',
|
|
8
|
+
module: '@graphcommerce/magento-cart-items',
|
|
9
|
+
}
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
+
export function RemoveItemFromCartFab(props: PluginProps<RemoveItemFromCartFabProps>) {
|
|
11
12
|
const { Prev, fabProps } = props
|
|
12
13
|
|
|
13
14
|
return (
|
|
@@ -26,5 +27,3 @@ export const GoogleDatalayerRemoveItemFromCartFab: ReactPlugin<typeof Original>
|
|
|
26
27
|
/>
|
|
27
28
|
)
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
export const Plugin = GoogleDatalayerRemoveItemFromCartFab
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProductPageMetaProps } from '@graphcommerce/magento-product'
|
|
2
2
|
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { useMemoObject } from '@graphcommerce/next-ui'
|
|
4
|
-
import
|
|
4
|
+
import { useEffect } from 'react'
|
|
5
5
|
import { sendEvent } from '../api/sendEvent'
|
|
6
6
|
import { productToViewItem } from '../mapping/productToViewItem/productToViewItem'
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ export const component = 'ProductPageMeta'
|
|
|
9
9
|
export const exported = '@graphcommerce/magento-product'
|
|
10
10
|
|
|
11
11
|
/** When a product is added to the Cart, send a Google Analytics event */
|
|
12
|
-
function GoogleDatalayerViewItem(props: PluginProps<
|
|
12
|
+
function GoogleDatalayerViewItem(props: PluginProps<ProductPageMetaProps>) {
|
|
13
13
|
const { Prev, product } = props
|
|
14
14
|
|
|
15
15
|
const viewItem = useMemoObject(productToViewItem(product))
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import type { PagesProps } from '@graphcommerce/framer-next-pages'
|
|
2
|
-
import type {
|
|
2
|
+
import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { useEventCallback } from '@mui/material'
|
|
4
4
|
import { useEffect } from 'react'
|
|
5
5
|
import { onCLS, onFCP, onFID, onINP, onLCP, onTTFB, Metric } from 'web-vitals/attribution'
|
|
6
6
|
import { sendEvent } from '../api/sendEvent'
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export const config: PluginConfig = {
|
|
9
|
+
type: 'component',
|
|
10
|
+
module: '@graphcommerce/framer-next-pages',
|
|
11
|
+
ifConfig: 'dataLayer.coreWebVitals',
|
|
12
|
+
}
|
|
11
13
|
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* When a product is added to the Cart, send a Google Analytics event.
|
|
13
16
|
*
|
|
14
17
|
* Based on this information: https://github.com/GoogleChrome/web-vitals?tab=readme-ov-file#send-the-results-to-google-analytics
|
|
15
18
|
*/
|
|
16
|
-
function
|
|
19
|
+
export function FramerNextPages(props: PluginProps<PagesProps>) {
|
|
17
20
|
const { Prev, ...rest } = props
|
|
18
21
|
|
|
19
22
|
const sendCoreWebVitals = useEventCallback((m: Metric, debug_target?: string | undefined) => {
|
|
@@ -36,5 +39,3 @@ function GoogleDatalayerCoreWebVitals(props: PluginProps<PagesProps>) {
|
|
|
36
39
|
|
|
37
40
|
return <Prev {...rest} />
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
export const Plugin = GoogleDatalayerCoreWebVitals
|