@faststore/core 3.0.126 → 3.0.129
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +32 -32
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +75 -3
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/153.js +1 -1
- package/.next/server/chunks/158.js +1 -1
- package/.next/server/chunks/188.js +1 -0
- package/.next/server/chunks/244.js +1 -0
- package/.next/server/chunks/295.js +1 -0
- package/.next/server/chunks/524.js +1 -0
- package/.next/server/chunks/624.js +1 -1
- package/.next/server/chunks/646.js +2 -2
- package/.next/server/chunks/671.js +1 -0
- package/.next/server/chunks/679.js +1 -1
- package/.next/server/chunks/844.js +1 -0
- package/.next/server/chunks/880.js +1 -0
- package/.next/server/chunks/917.js +1 -1
- package/.next/server/chunks/96.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.js +1 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.js +1 -1
- package/.next/server/pages/500.js.nft.json +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/[...slug].js.nft.json +1 -1
- package/.next/server/pages/[slug]/p.js +1 -1
- package/.next/server/pages/[slug]/p.js.nft.json +1 -1
- package/.next/server/pages/_app.js +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/account.js +1 -1
- package/.next/server/pages/account.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js.nft.json +1 -1
- package/.next/server/pages/api/health/live.js.nft.json +1 -1
- package/.next/server/pages/api/health/ready.js.nft.json +1 -1
- package/.next/server/pages/api/preview.js.nft.json +1 -1
- package/.next/server/pages/checkout.js +1 -1
- package/.next/server/pages/checkout.js.nft.json +1 -1
- package/.next/server/pages/en-US/404.html +1 -1
- package/.next/server/pages/en-US/500.html +1 -1
- package/.next/server/pages/en-US/account.html +1 -1
- package/.next/server/pages/en-US/checkout.html +1 -1
- package/.next/server/pages/en-US/login.html +1 -1
- package/.next/server/pages/en-US/s.html +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/index.js +1 -1
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/login.js +1 -1
- package/.next/server/pages/login.js.nft.json +1 -1
- package/.next/server/pages/s.js +1 -1
- package/.next/server/pages/s.js.nft.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/{CZZ2zui7yn1tQvA7P4g_a → Ywtu8htMrJApXXIOtVA2F}/_buildManifest.js +1 -1
- package/.next/static/chunks/153.70d524f369fef82b.js +1 -0
- package/.next/static/chunks/195.5f46b2d90f69ddfc.js +1 -0
- package/.next/static/chunks/{235-f262d03219a7a999.js → 235-a7d9d6cf81ae08ef.js} +1 -1
- package/.next/static/chunks/295.a3098958c7ef54ec.js +1 -0
- package/.next/static/chunks/343.f76546894e65db1a.js +1 -0
- package/.next/static/chunks/{624.455cdc0925956ae5.js → 624.5aef4b13bbfa8d1d.js} +1 -1
- package/.next/static/chunks/65.7506de28495fdae8.js +1 -0
- package/.next/static/chunks/{758.a411edd1cbd09134.js → 758.829db9862d9c4add.js} +1 -1
- package/.next/static/chunks/87-5709356a398fea13.js +1 -0
- package/.next/static/chunks/968-dffabcd6f064d487.js +1 -0
- package/.next/static/chunks/pages/[...slug]-0fa9da2ac039ffed.js +1 -0
- package/.next/static/chunks/pages/[slug]/p-a316db4e36c17eef.js +1 -0
- package/.next/static/chunks/pages/{_app-68b16ab75cae8271.js → _app-ed807a0c1aebeb38.js} +1 -1
- package/.next/static/chunks/pages/s-e561526ac9252bf9.js +1 -0
- package/.next/static/chunks/webpack-904b033805de64d4.js +1 -0
- package/.next/trace +94 -94
- package/.turbo/turbo-build.log +5 -5
- package/.turbo/turbo-test.log +4 -4
- package/package.json +7 -7
- package/src/components/cart/CartItem/CartItem.tsx +34 -33
- package/src/components/cart/CartSidebar/CartSidebar.tsx +19 -18
- package/src/components/search/SearchInput/SearchInput.tsx +16 -12
- package/src/components/sections/ProductDetails/ProductDetails.tsx +24 -23
- package/src/sdk/analytics/hooks/usePageViewEvent.ts +11 -10
- package/src/sdk/analytics/hooks/useViewItemListEvent.ts +22 -20
- package/src/sdk/cart/useBuyButton.ts +26 -25
- package/src/sdk/cart/useRemoveButton.ts +24 -23
- package/src/sdk/product/useProductGalleryQuery.ts +12 -12
- package/src/sdk/product/useProductLink.ts +37 -36
- package/src/sdk/search/useSuggestions.ts +14 -13
- package/src/server/index.ts +2 -2
- package/.next/server/chunks/24.js +0 -1
- package/.next/server/chunks/933.js +0 -1
- package/.next/static/chunks/65.8e4235e2d3871cb7.js +0 -1
- package/.next/static/chunks/885-9feec0602c610671.js +0 -1
- package/.next/static/chunks/968-fed67c31f0fa4d91.js +0 -1
- package/.next/static/chunks/pages/[...slug]-c1d01fe8611f37bd.js +0 -1
- package/.next/static/chunks/pages/[slug]/p-f2220885452cffb6.js +0 -1
- package/.next/static/chunks/pages/s-e3d1cc458d242d70.js +0 -1
- package/.next/static/chunks/webpack-abe9adb7914f7244.js +0 -1
- /package/.next/static/{CZZ2zui7yn1tQvA7P4g_a → Ywtu8htMrJApXXIOtVA2F}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -50,7 +50,7 @@ Route (pages) Size First Load JS
|
|
|
50
50
|
├ /_app 0 B 90.7 kB
|
|
51
51
|
├ ● /[...slug] 2.79 kB 155 kB
|
|
52
52
|
├ └ css/e47f1a002bdcf76f.css 2.38 kB
|
|
53
|
-
├ ● /[slug]/p 11.
|
|
53
|
+
├ ● /[slug]/p 11.2 kB 152 kB
|
|
54
54
|
├ └ css/9b6bba2472d272ec.css 10.5 kB
|
|
55
55
|
├ ○ /404 1.28 kB 126 kB
|
|
56
56
|
├ ● /500 1.29 kB 126 kB
|
|
@@ -61,12 +61,12 @@ Route (pages) Size First Load JS
|
|
|
61
61
|
├ λ /api/preview 0 B 90.7 kB
|
|
62
62
|
├ ● /checkout 661 B 126 kB
|
|
63
63
|
├ ● /login 1.4 kB 126 kB
|
|
64
|
-
└ ● /s 2.22 kB
|
|
65
|
-
+ First Load JS shared by all 93.
|
|
64
|
+
└ ● /s 2.22 kB 155 kB
|
|
65
|
+
+ First Load JS shared by all 93.8 kB
|
|
66
66
|
├ chunks/framework-8e279965036b6169.js 45.4 kB
|
|
67
67
|
├ chunks/main-029f1328cfee9686.js 33.1 kB
|
|
68
|
-
├ chunks/pages/_app-
|
|
69
|
-
├ chunks/webpack-
|
|
68
|
+
├ chunks/pages/_app-ed807a0c1aebeb38.js 9.87 kB
|
|
69
|
+
├ chunks/webpack-904b033805de64d4.js 2.45 kB
|
|
70
70
|
└ css/ee0556daedda6306.css 3.07 kB
|
|
71
71
|
|
|
72
72
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
$ jest
|
|
2
|
-
PASS test/utils/multipleTemplates.test.ts (
|
|
3
|
-
PASS test/server/cms/index.test.ts (
|
|
4
|
-
PASS test/server/index.test.ts (
|
|
2
|
+
PASS test/utils/multipleTemplates.test.ts (34.431 s)
|
|
3
|
+
PASS test/server/cms/index.test.ts (34.65 s)
|
|
4
|
+
PASS test/server/index.test.ts (37.634 s)
|
|
5
5
|
|
|
6
6
|
Test Suites: 3 passed, 3 total
|
|
7
7
|
Tests: 19 passed, 19 total
|
|
8
8
|
Snapshots: 0 total
|
|
9
|
-
Time:
|
|
9
|
+
Time: 38.771 s
|
|
10
10
|
Ran all test suites.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.129",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@antfu/ni": "^0.21.12",
|
|
41
41
|
"@builder.io/partytown": "^0.6.1",
|
|
42
|
-
"@envelop/core": "^
|
|
43
|
-
"@envelop/graphql-jit": "^
|
|
44
|
-
"@envelop/parser-cache": "^
|
|
45
|
-
"@envelop/validation-cache": "^
|
|
46
|
-
"@faststore/api": "^3.0.
|
|
42
|
+
"@envelop/core": "^4.0.0",
|
|
43
|
+
"@envelop/graphql-jit": "^4.0.0",
|
|
44
|
+
"@envelop/parser-cache": "^4.0.0",
|
|
45
|
+
"@envelop/validation-cache": "^4.0.0",
|
|
46
|
+
"@faststore/api": "^3.0.129",
|
|
47
47
|
"@faststore/components": "^3.0.116",
|
|
48
48
|
"@faststore/graphql-utils": "^3.0.116",
|
|
49
49
|
"@faststore/lighthouse": "^3.0.116",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"node": "18.19.0",
|
|
129
129
|
"yarn": "1.19.1"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "8de84b10ff99f3c137e73c2bb27970f03dc28d62"
|
|
132
132
|
}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
AddToCartEvent,
|
|
3
|
+
CurrencyCode,
|
|
4
|
+
RemoveFromCartEvent,
|
|
5
|
+
} from '@faststore/sdk'
|
|
2
6
|
import {
|
|
3
7
|
CartItem as UICartItem,
|
|
4
8
|
CartItemImage as UICartItemImage,
|
|
5
9
|
CartItemSummary as UICartItemSummary,
|
|
6
10
|
} from '@faststore/ui'
|
|
7
11
|
import { useCallback, useMemo } from 'react'
|
|
8
|
-
import type {
|
|
9
|
-
AddToCartEvent,
|
|
10
|
-
CurrencyCode,
|
|
11
|
-
RemoveFromCartEvent,
|
|
12
|
-
} from '@faststore/sdk'
|
|
13
12
|
|
|
14
13
|
import { Image } from 'src/components/ui/Image'
|
|
14
|
+
import type { AnalyticsItem } from 'src/sdk/analytics/types'
|
|
15
|
+
import type { CartItem as ICartItem } from 'src/sdk/cart'
|
|
15
16
|
import { cartStore } from 'src/sdk/cart'
|
|
17
|
+
import { useRemoveButton } from 'src/sdk/cart/useRemoveButton'
|
|
16
18
|
import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
|
|
17
19
|
import { useSession } from 'src/sdk/session'
|
|
18
|
-
import { useRemoveButton } from 'src/sdk/cart/useRemoveButton'
|
|
19
|
-
import type { CartItem as ICartItem } from 'src/sdk/cart'
|
|
20
|
-
import type { AnalyticsItem } from 'src/sdk/analytics/types'
|
|
21
20
|
|
|
22
21
|
function useCartItemEvent() {
|
|
23
22
|
const {
|
|
@@ -28,30 +27,32 @@ function useCartItemEvent() {
|
|
|
28
27
|
(item: Props['item'], quantity: number) => {
|
|
29
28
|
const quantityDelta = quantity - item.quantity
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
31
|
+
return sendAnalyticsEvent<
|
|
32
|
+
AddToCartEvent<AnalyticsItem> | RemoveFromCartEvent<AnalyticsItem>
|
|
33
|
+
>({
|
|
34
|
+
name: quantityDelta > 0 ? 'add_to_cart' : 'remove_from_cart',
|
|
35
|
+
params: {
|
|
36
|
+
currency: code as CurrencyCode,
|
|
37
|
+
// TODO: In the future, we can explore more robust ways of
|
|
38
|
+
// calculating the value (gift items, discounts, etc.).
|
|
39
|
+
value: item.price * Math.abs(quantityDelta),
|
|
40
|
+
items: [
|
|
41
|
+
{
|
|
42
|
+
item_id: item.itemOffered.isVariantOf.productGroupID,
|
|
43
|
+
item_name: item.itemOffered.isVariantOf.name,
|
|
44
|
+
item_brand: item.itemOffered.brand.name,
|
|
45
|
+
item_variant: item.itemOffered.sku,
|
|
46
|
+
quantity: Math.abs(quantityDelta),
|
|
47
|
+
price: item.price,
|
|
48
|
+
discount: item.listPrice - item.price,
|
|
49
|
+
currency: code as CurrencyCode,
|
|
50
|
+
item_variant_name: item.itemOffered.name,
|
|
51
|
+
product_reference_id: item.itemOffered.gtin,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
})
|
|
55
56
|
})
|
|
56
57
|
},
|
|
57
58
|
[code]
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
2
1
|
import {
|
|
3
2
|
Button as UIButton,
|
|
4
3
|
CartSidebar as UICartSidebar,
|
|
@@ -28,24 +27,26 @@ function useViewCartEvent() {
|
|
|
28
27
|
const { items, gifts, total } = useCart()
|
|
29
28
|
|
|
30
29
|
const sendViewCartEvent = useCallback(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
value: total,
|
|
36
|
-
items: items.concat(gifts).map((item) => ({
|
|
37
|
-
item_id: item.itemOffered.isVariantOf.productGroupID,
|
|
38
|
-
item_name: item.itemOffered.isVariantOf.name,
|
|
39
|
-
item_brand: item.itemOffered.brand.name,
|
|
40
|
-
item_variant: item.itemOffered.sku,
|
|
41
|
-
quantity: item.quantity,
|
|
42
|
-
price: item.price,
|
|
43
|
-
discount: item.listPrice - item.price,
|
|
30
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
31
|
+
return sendAnalyticsEvent<ViewCartEvent>({
|
|
32
|
+
name: 'view_cart',
|
|
33
|
+
params: {
|
|
44
34
|
currency: code as CurrencyCode,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
value: total,
|
|
36
|
+
items: items.concat(gifts).map((item) => ({
|
|
37
|
+
item_id: item.itemOffered.isVariantOf.productGroupID,
|
|
38
|
+
item_name: item.itemOffered.isVariantOf.name,
|
|
39
|
+
item_brand: item.itemOffered.brand.name,
|
|
40
|
+
item_variant: item.itemOffered.sku,
|
|
41
|
+
quantity: item.quantity,
|
|
42
|
+
price: item.price,
|
|
43
|
+
discount: item.listPrice - item.price,
|
|
44
|
+
currency: code as CurrencyCode,
|
|
45
|
+
item_variant_name: item.itemOffered.name,
|
|
46
|
+
product_reference_id: item.itemOffered.gtin,
|
|
47
|
+
})),
|
|
48
|
+
},
|
|
49
|
+
})
|
|
49
50
|
})
|
|
50
51
|
}, [code, gifts, items, total])
|
|
51
52
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SearchEvent, SearchState } from '@faststore/sdk'
|
|
2
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
3
2
|
|
|
4
3
|
import type {
|
|
5
4
|
SearchInputFieldProps as UISearchInputFieldProps,
|
|
@@ -22,7 +21,6 @@ import {
|
|
|
22
21
|
useState,
|
|
23
22
|
} from 'react'
|
|
24
23
|
|
|
25
|
-
import { formatSearchPath } from 'src/sdk/search/formatSearchPath'
|
|
26
24
|
import useSearchHistory from 'src/sdk/search/useSearchHistory'
|
|
27
25
|
import useSuggestions from 'src/sdk/search/useSuggestions'
|
|
28
26
|
import useOnClickOutside from 'src/sdk/ui/useOnClickOutside'
|
|
@@ -46,9 +44,11 @@ export type SearchInputRef = UISearchInputFieldRef & {
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
const sendAnalytics = async (term: string) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
48
|
+
sendAnalyticsEvent<SearchEvent>({
|
|
49
|
+
name: 'search',
|
|
50
|
+
params: { search_term: term },
|
|
51
|
+
})
|
|
52
52
|
})
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -119,13 +119,17 @@ const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
|
|
|
119
119
|
placeholder={placeholder}
|
|
120
120
|
onChange={(e) => setSearchQuery(e.target.value)}
|
|
121
121
|
onSubmit={(term) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
import('src/sdk/search/formatSearchPath').then(
|
|
123
|
+
({ formatSearchPath }) => {
|
|
124
|
+
const path = formatSearchPath({
|
|
125
|
+
term,
|
|
126
|
+
sort: sort as SearchState['sort'],
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
onSearchSelection(term, path)
|
|
130
|
+
router.push(path)
|
|
131
|
+
}
|
|
132
|
+
)
|
|
129
133
|
}}
|
|
130
134
|
onFocus={() => setSearchDropdownVisible(true)}
|
|
131
135
|
value={searchQuery}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import type { CurrencyCode, ViewItemEvent } from '@faststore/sdk'
|
|
4
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
5
4
|
|
|
6
5
|
import { gql } from '@generated'
|
|
7
6
|
import type { AnalyticsItem } from 'src/sdk/analytics/types'
|
|
@@ -12,10 +11,10 @@ import Section from '../Section'
|
|
|
12
11
|
|
|
13
12
|
import styles from './section.module.scss'
|
|
14
13
|
|
|
15
|
-
import {
|
|
14
|
+
import { getOverridableSection } from '../../../sdk/overrides/getOverriddenSection'
|
|
16
15
|
import { useOverrideComponents } from '../../../sdk/overrides/OverrideContext'
|
|
16
|
+
import { usePDP } from '../../../sdk/overrides/PageProvider'
|
|
17
17
|
import { ProductDetailsDefaultComponents } from './DefaultComponents'
|
|
18
|
-
import { getOverridableSection } from '../../../sdk/overrides/getOverriddenSection'
|
|
19
18
|
|
|
20
19
|
export interface ProductDetailsProps {
|
|
21
20
|
productTitle: {
|
|
@@ -115,25 +114,27 @@ function ProductDetails({
|
|
|
115
114
|
} = product
|
|
116
115
|
|
|
117
116
|
useEffect(() => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
117
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
118
|
+
sendAnalyticsEvent<ViewItemEvent<AnalyticsItem>>({
|
|
119
|
+
name: 'view_item',
|
|
120
|
+
params: {
|
|
121
|
+
currency: currency.code as CurrencyCode,
|
|
122
|
+
value: price,
|
|
123
|
+
items: [
|
|
124
|
+
{
|
|
125
|
+
item_id: isVariantOf.productGroupID,
|
|
126
|
+
item_name: isVariantOf.name,
|
|
127
|
+
item_brand: brand.name,
|
|
128
|
+
item_variant: sku,
|
|
129
|
+
price,
|
|
130
|
+
discount: listPrice - price,
|
|
131
|
+
currency: currency.code as CurrencyCode,
|
|
132
|
+
item_variant_name: variantName,
|
|
133
|
+
product_reference_id: gtin,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
})
|
|
137
138
|
})
|
|
138
139
|
}, [
|
|
139
140
|
isVariantOf.productGroupID,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { useCallback, useEffect } from 'react'
|
|
2
|
-
import { useRouter } from 'next/router'
|
|
3
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
4
1
|
import type { PageViewEvent } from '@faststore/sdk'
|
|
2
|
+
import { useRouter } from 'next/router'
|
|
3
|
+
import { useCallback, useEffect } from 'react'
|
|
5
4
|
|
|
6
5
|
export const usePageViewEvent = () => {
|
|
7
6
|
const sendPageViewEvent = useCallback(() => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
8
|
+
sendAnalyticsEvent<PageViewEvent>({
|
|
9
|
+
name: 'page_view',
|
|
10
|
+
params: {
|
|
11
|
+
page_title: document.title,
|
|
12
|
+
page_location: location.href,
|
|
13
|
+
send_page_view: true,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
15
16
|
})
|
|
16
17
|
}, [])
|
|
17
18
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
2
1
|
import { useCallback } from 'react'
|
|
3
2
|
import type { CurrencyCode, ViewItemListEvent } from '@faststore/sdk'
|
|
4
3
|
|
|
@@ -25,25 +24,28 @@ export const useViewItemListEvent = ({
|
|
|
25
24
|
} = useSession()
|
|
26
25
|
|
|
27
26
|
const sendViewItemListEvent = useCallback(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
28
|
+
sendAnalyticsEvent<ViewItemListEvent<AnalyticsItem>>({
|
|
29
|
+
name: 'view_item_list',
|
|
30
|
+
params: {
|
|
31
|
+
item_list_name: title,
|
|
32
|
+
item_list_id: title,
|
|
33
|
+
items: products.map(({ node: product }, index) => ({
|
|
34
|
+
item_id: product.isVariantOf.productGroupID,
|
|
35
|
+
item_name: product.isVariantOf.name,
|
|
36
|
+
item_brand: product.brand.name,
|
|
37
|
+
item_variant: product.sku,
|
|
38
|
+
price: product.offers.offers[0].price,
|
|
39
|
+
index: page * pageSize + index + 1,
|
|
40
|
+
discount:
|
|
41
|
+
product.offers.offers[0].listPrice -
|
|
42
|
+
product.offers.offers[0].price,
|
|
43
|
+
currency: code as CurrencyCode,
|
|
44
|
+
item_variant_name: product.name,
|
|
45
|
+
product_reference_id: product.gtin,
|
|
46
|
+
})),
|
|
47
|
+
},
|
|
48
|
+
})
|
|
47
49
|
})
|
|
48
50
|
}, [code, products, title, page, pageSize])
|
|
49
51
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AddToCartEvent, CurrencyCode } from '@faststore/sdk'
|
|
2
2
|
import { useCallback } from 'react'
|
|
3
|
-
import type { CurrencyCode, AddToCartEvent } from '@faststore/sdk'
|
|
4
3
|
|
|
5
4
|
import type { AnalyticsItem } from 'src/sdk/analytics/types'
|
|
6
5
|
import type { CartItem } from 'src/sdk/cart'
|
|
7
6
|
|
|
8
|
-
import { useSession } from '../session'
|
|
9
7
|
import { useUI } from '@faststore/ui'
|
|
8
|
+
import { useSession } from '../session'
|
|
10
9
|
import { cartStore } from './index'
|
|
11
10
|
|
|
12
11
|
export const useBuyButton = (item: CartItem | null) => {
|
|
@@ -23,28 +22,30 @@ export const useBuyButton = (item: CartItem | null) => {
|
|
|
23
22
|
return
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
26
|
+
sendAnalyticsEvent<AddToCartEvent<AnalyticsItem>>({
|
|
27
|
+
name: 'add_to_cart',
|
|
28
|
+
params: {
|
|
29
|
+
currency: code as CurrencyCode,
|
|
30
|
+
// TODO: In the future, we can explore more robust ways of
|
|
31
|
+
// calculating the value (gift items, discounts, etc.).
|
|
32
|
+
value: item.price * item.quantity,
|
|
33
|
+
items: [
|
|
34
|
+
{
|
|
35
|
+
item_id: item.itemOffered.isVariantOf.productGroupID,
|
|
36
|
+
item_name: item.itemOffered.isVariantOf.name,
|
|
37
|
+
item_brand: item.itemOffered.brand.name,
|
|
38
|
+
item_variant: item.itemOffered.sku,
|
|
39
|
+
quantity: item.quantity,
|
|
40
|
+
price: item.price,
|
|
41
|
+
discount: item.listPrice - item.price,
|
|
42
|
+
currency: code as CurrencyCode,
|
|
43
|
+
item_variant_name: item.itemOffered.name,
|
|
44
|
+
product_reference_id: item.itemOffered.gtin,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
})
|
|
48
49
|
})
|
|
49
50
|
|
|
50
51
|
cartStore.addItem(item)
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
2
|
-
import { useCallback } from 'react'
|
|
3
1
|
import type { CurrencyCode, RemoveFromCartEvent } from '@faststore/sdk'
|
|
2
|
+
import { useCallback } from 'react'
|
|
4
3
|
|
|
5
4
|
import type { AnalyticsItem } from 'src/sdk/analytics/types'
|
|
6
5
|
|
|
6
|
+
import type { CartItem } from '.'
|
|
7
7
|
import { useSession } from '../session'
|
|
8
8
|
import { cartStore } from './index'
|
|
9
|
-
import type { CartItem } from '.'
|
|
10
9
|
|
|
11
10
|
export const useRemoveButton = (item: CartItem | null) => {
|
|
12
11
|
const {
|
|
@@ -21,26 +20,28 @@ export const useRemoveButton = (item: CartItem | null) => {
|
|
|
21
20
|
return
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
24
|
+
sendAnalyticsEvent<RemoveFromCartEvent<AnalyticsItem>>({
|
|
25
|
+
name: 'remove_from_cart',
|
|
26
|
+
params: {
|
|
27
|
+
currency: code as CurrencyCode,
|
|
28
|
+
value: item.price * item.quantity, // TODO: In the future, we can explore more robust ways of calculating the value (gift items, discounts, etc.).
|
|
29
|
+
items: [
|
|
30
|
+
{
|
|
31
|
+
item_id: item.itemOffered.isVariantOf.productGroupID,
|
|
32
|
+
item_name: item.itemOffered.isVariantOf.name,
|
|
33
|
+
item_brand: item.itemOffered.brand.name,
|
|
34
|
+
item_variant: item.itemOffered.sku,
|
|
35
|
+
quantity: item.quantity,
|
|
36
|
+
price: item.price,
|
|
37
|
+
discount: item.listPrice - item.price,
|
|
38
|
+
currency: code as CurrencyCode,
|
|
39
|
+
item_variant_name: item.itemOffered.name,
|
|
40
|
+
product_reference_id: item.itemOffered.gtin,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
})
|
|
44
45
|
})
|
|
45
46
|
|
|
46
47
|
cartStore.removeItem(item.id)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
2
|
-
|
|
3
1
|
import { gql } from '@generated'
|
|
4
2
|
import { useQuery } from 'src/sdk/graphql/useQuery'
|
|
5
3
|
import { useSession } from 'src/sdk/session'
|
|
@@ -83,16 +81,18 @@ export const useProductGalleryQuery = ({
|
|
|
83
81
|
return useQuery<Query, Variables>(query, localizedVariables, {
|
|
84
82
|
onSuccess: (data) => {
|
|
85
83
|
if (data && term) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
import('@faststore/sdk').then(({ sendAnalyticsEvent }) => {
|
|
85
|
+
sendAnalyticsEvent<IntelligentSearchQueryEvent>({
|
|
86
|
+
name: 'intelligent_search_query',
|
|
87
|
+
params: {
|
|
88
|
+
locale,
|
|
89
|
+
term,
|
|
90
|
+
url: window.location.href,
|
|
91
|
+
logicalOperator: data.search.metadata?.logicalOperator ?? 'and',
|
|
92
|
+
isTermMisspelled: data.search.metadata?.isTermMisspelled ?? false,
|
|
93
|
+
totalCount: data.search.products.pageInfo.totalCount,
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
96
|
})
|
|
97
97
|
}
|
|
98
98
|
},
|