@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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @graphcommerce/google-datalayer
2
2
 
3
+ ## 8.1.0-canary.8
4
+
5
+ ## 8.1.0-canary.7
6
+
3
7
  ## 8.1.0-canary.6
4
8
 
5
9
  ## 8.1.0-canary.5
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.6",
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.6",
16
- "@graphcommerce/magento-cart": "^8.1.0-canary.6",
17
- "@graphcommerce/magento-cart-payment-method": "^8.1.0-canary.6",
18
- "@graphcommerce/magento-cart-shipping-method": "^8.1.0-canary.6",
19
- "@graphcommerce/magento-product": "^8.1.0-canary.6",
20
- "@graphcommerce/next-ui": "^8.1.0-canary.6",
21
- "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.6",
22
- "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.6",
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 { ProductListItem } from '@graphcommerce/magento-product'
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 { RemoveItemFromCart } from '@graphcommerce/magento-cart-items'
2
- import type { ReactPlugin } from '@graphcommerce/next-config'
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 component = 'RemoveItemFromCart'
7
- export const exported =
8
- '@graphcommerce/magento-cart-items/components/RemoveItemFromCart/RemoveItemFromCart'
6
+ export const config: PluginConfig = {
7
+ type: 'component',
8
+ module: '@graphcommerce/magento-cart-items',
9
+ }
9
10
 
10
- export const GoogleDatalayerRemoveItemFromCart: ReactPlugin<typeof RemoveItemFromCart> = (
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 { RemoveItemFromCartFab as Original } from '@graphcommerce/magento-cart-items'
2
- import type { ReactPlugin } from '@graphcommerce/next-config'
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 component = 'RemoveItemFromCartFab'
7
- export const exported =
8
- '@graphcommerce/magento-cart-items/components/RemoveItemFromCart/RemoveItemFromCartFab'
6
+ export const config: PluginConfig = {
7
+ type: 'component',
8
+ module: '@graphcommerce/magento-cart-items',
9
+ }
9
10
 
10
- export const GoogleDatalayerRemoveItemFromCartFab: ReactPlugin<typeof Original> = (props) => {
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 { ProductPageMeta } from '@graphcommerce/magento-product'
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 React, { useEffect } from 'react'
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<React.ComponentProps<typeof ProductPageMeta>>) {
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 { IfConfig, PluginProps } from '@graphcommerce/next-config'
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 component = 'FramerNextPages'
9
- export const exported = '@graphcommerce/framer-next-pages'
10
- export const ifConfig: IfConfig = 'dataLayer.coreWebVitals'
8
+ export const config: PluginConfig = {
9
+ type: 'component',
10
+ module: '@graphcommerce/framer-next-pages',
11
+ ifConfig: 'dataLayer.coreWebVitals',
12
+ }
11
13
 
12
- /** When a product is added to the Cart, send a Google Analytics event.
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 GoogleDatalayerCoreWebVitals(props: PluginProps<PagesProps>) {
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