@faststore/core 3.97.0-dev.3 → 3.97.0-dev.4
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 +22 -22
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- 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/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +6 -6
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/2445.js +12 -1
- package/.next/server/chunks/3890.js +492 -0
- package/.next/server/chunks/3951.js +7 -0
- package/.next/server/chunks/4365.js +1 -1
- package/.next/server/chunks/870.js +1 -1
- package/.next/server/chunks/9563.js +1 -1
- package/.next/server/functions-config-manifest.json +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 +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/api/fs/logout.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js +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 +28 -13
- package/.next/server/pages/en-US/500.html +28 -13
- package/.next/server/pages/en-US/checkout.html +28 -13
- package/.next/server/pages/en-US/login.html +28 -13
- package/.next/server/pages/en-US/s.html +28 -13
- package/.next/server/pages/en-US.html +28 -13
- 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/pvt/account/403.js +1 -1
- package/.next/server/pages/pvt/account/403.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/404.js +1 -1
- package/.next/server/pages/pvt/account/404.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/[...unknown].js +1 -1
- package/.next/server/pages/pvt/account/[...unknown].js.nft.json +1 -1
- package/.next/server/pages/pvt/account/orders/[id].js +1 -1
- package/.next/server/pages/pvt/account/orders/[id].js.nft.json +1 -1
- package/.next/server/pages/pvt/account/orders.js +1 -1
- package/.next/server/pages/pvt/account/orders.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/profile.js +1 -1
- package/.next/server/pages/pvt/account/profile.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/security.js +1 -1
- package/.next/server/pages/pvt/account/security.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/user-details.js +1 -1
- package/.next/server/pages/pvt/account/user-details.js.nft.json +1 -1
- package/.next/server/pages/pvt/account.js +1 -1
- package/.next/server/pages/pvt/account.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/{6skPsTs9THh3repcOD2W9 → MP_8ZYG-CrNK2l6CQ3WRL}/_buildManifest.js +1 -1
- package/.next/static/chunks/{4330.f109e9f5a57b55f1.js → 4330.e6cd2878ad7a8beb.js} +1 -1
- package/.next/static/chunks/7692.8d5bf4560341a2f6.js +1 -0
- package/.next/static/chunks/941.3e2782ab9c490eb0.js +1 -0
- package/.next/static/chunks/{UIToast.c4250a6c006ff759.js → UIToast.f6a836acc0442d54.js} +1 -1
- package/.next/static/chunks/pages/_app-f531201d1d916a86.js +1 -0
- package/.next/static/chunks/{webpack-79aa85173d156fd1.js → webpack-639c88ba267a2928.js} +1 -1
- package/.next/trace +140 -140
- package/.turbo/turbo-build.log +24 -24
- package/.turbo/turbo-test.log +5 -5
- package/CHANGELOG.md +6 -0
- package/discovery.config.default.js +1 -0
- package/package.json +2 -2
- package/src/Layout.tsx +2 -2
- package/src/components/ThirdPartyScripts/GoogleTagManager.tsx +19 -10
- package/src/components/ThirdPartyScripts/ThirdPartyScripts.tsx +1 -22
- package/src/components/ThirdPartyScripts/vtex.tsx +6 -1
- package/src/constants.ts +2 -0
- package/src/pages/_document.tsx +40 -0
- package/src/sdk/analytics/hooks/usePageViewEvent.ts +7 -2
- package/src/sdk/analytics/platform/vtex/search.ts +22 -8
- package/.next/server/chunks/4168.js +0 -1
- package/.next/server/chunks/9630.js +0 -495
- package/.next/static/chunks/7692.a352cce6d744fa8b.js +0 -1
- package/.next/static/chunks/941.417f354fd61bae91.js +0 -1
- package/.next/static/chunks/pages/_app-c8d9fffc5023f6bc.js +0 -1
- /package/.next/static/{6skPsTs9THh3repcOD2W9 → MP_8ZYG-CrNK2l6CQ3WRL}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.97.0-dev.
|
|
2
|
+
> @faststore/core@3.97.0-dev.3 prebuild /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> na run partytown && na run generate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @faststore/core@3.97.0-dev.
|
|
6
|
+
> @faststore/core@3.97.0-dev.3 partytown /home/runner/work/faststore/faststore/packages/core
|
|
7
7
|
> partytown copylib ./public/~partytown
|
|
8
8
|
|
|
9
9
|
Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
|
|
10
10
|
|
|
11
|
-
> @faststore/core@3.97.0-dev.
|
|
11
|
+
> @faststore/core@3.97.0-dev.3 generate /home/runner/work/faststore/faststore/packages/core
|
|
12
12
|
> na run generate:schema && na run generate:codegen && na run format:generated
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
> @faststore/core@3.97.0-dev.
|
|
15
|
+
> @faststore/core@3.97.0-dev.3 generate:schema /home/runner/work/faststore/faststore/packages/core
|
|
16
16
|
> tsx src/server/generator/generateGraphQLSchemaFile.ts
|
|
17
17
|
|
|
18
18
|
Schema GraphQL file generated successfully
|
|
19
19
|
|
|
20
|
-
> @faststore/core@3.97.0-dev.
|
|
20
|
+
> @faststore/core@3.97.0-dev.3 generate:codegen /home/runner/work/faststore/faststore/packages/core
|
|
21
21
|
> graphql-codegen
|
|
22
22
|
|
|
23
23
|
[STARTED] Parse Configuration
|
|
@@ -37,11 +37,11 @@ Running lifecycle hook "afterStart" scripts...
|
|
|
37
37
|
[CLI] Loading Documents
|
|
38
38
|
[CLI] Generating output
|
|
39
39
|
|
|
40
|
-
> @faststore/core@3.97.0-dev.
|
|
40
|
+
> @faststore/core@3.97.0-dev.3 format:generated /home/runner/work/faststore/faststore/packages/core
|
|
41
41
|
> prettier --write "@generated/**/*.{ts,js,tsx,jsx,json}" --loglevel error
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
> @faststore/core@3.97.0-dev.
|
|
44
|
+
> @faststore/core@3.97.0-dev.3 build /home/runner/work/faststore/faststore/packages/core
|
|
45
45
|
> next build
|
|
46
46
|
|
|
47
47
|
⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
|
|
@@ -79,52 +79,52 @@ Import trace for requested module:
|
|
|
79
79
|
|
|
80
80
|
Collecting page data ...
|
|
81
81
|
Generating static pages (0/6) ...
|
|
82
|
-
Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
|
|
83
82
|
|
|
84
83
|
Generating static pages (1/6)
|
|
85
84
|
|
|
86
85
|
Generating static pages (2/6)
|
|
86
|
+
Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
|
|
87
87
|
|
|
88
88
|
Generating static pages (4/6)
|
|
89
89
|
|
|
90
90
|
✓ Generating static pages (6/6)
|
|
91
91
|
Finalizing page optimization ...
|
|
92
92
|
Collecting build traces ...
|
|
93
93
|
|
|
94
94
|
Route (pages) Size First Load JS
|
|
95
|
-
┌ ● / 7.34 kB
|
|
95
|
+
┌ ● / 7.34 kB 147 kB
|
|
96
96
|
├ └ css/02259c549b2179f2.css 3.1 kB
|
|
97
97
|
├ /_app 0 B 108 kB
|
|
98
|
-
├ ● /[...slug] 2.56 kB
|
|
99
|
-
├ ● /[slug]/p 97.8 kB
|
|
98
|
+
├ ● /[...slug] 2.56 kB 158 kB
|
|
99
|
+
├ ● /[slug]/p 97.8 kB 237 kB
|
|
100
100
|
├ └ css/146571b0d2ad7ca7.css 19.4 kB
|
|
101
|
-
├ ○ /404 1.57 kB
|
|
102
|
-
├ ● /500 1.57 kB
|
|
101
|
+
├ ○ /404 1.57 kB 141 kB
|
|
102
|
+
├ ● /500 1.57 kB 141 kB
|
|
103
103
|
├ λ /api/fs/logout 0 B 108 kB
|
|
104
104
|
├ λ /api/graphql 0 B 108 kB
|
|
105
105
|
├ λ /api/health/live 0 B 108 kB
|
|
106
106
|
├ λ /api/health/ready 0 B 108 kB
|
|
107
107
|
├ λ /api/preview 0 B 108 kB
|
|
108
|
-
├ ● /checkout 749 B
|
|
109
|
-
├ ● /login 1.69 kB
|
|
110
|
-
├ λ /pvt/account 247 B
|
|
111
|
-
├ ● /pvt/account/[...unknown] 287 B
|
|
108
|
+
├ ● /checkout 749 B 140 kB
|
|
109
|
+
├ ● /login 1.69 kB 141 kB
|
|
110
|
+
├ λ /pvt/account 247 B 108 kB
|
|
111
|
+
├ ● /pvt/account/[...unknown] 287 B 108 kB
|
|
112
112
|
├ λ /pvt/account/403 2.98 kB 143 kB
|
|
113
113
|
├ └ css/0fae3d432331aae9.css 4.68 kB
|
|
114
|
-
├ λ /pvt/account/404 2.18 kB
|
|
114
|
+
├ λ /pvt/account/404 2.18 kB 142 kB
|
|
115
115
|
├ └ css/0fc6b2ff69142c6a.css 4.74 kB
|
|
116
|
-
├ λ /pvt/account/orders 9.71 kB
|
|
116
|
+
├ λ /pvt/account/orders 9.71 kB 149 kB
|
|
117
117
|
├ └ css/40a294d0a24ad01d.css 14.1 kB
|
|
118
|
-
├ λ /pvt/account/orders/[id] 13.6 kB
|
|
118
|
+
├ λ /pvt/account/orders/[id] 13.6 kB 153 kB
|
|
119
119
|
├ └ css/08d03445f1797608.css 13.8 kB
|
|
120
120
|
├ λ /pvt/account/profile 1.98 kB 142 kB
|
|
121
121
|
├ └ css/47f1b4e8de15d314.css 4.42 kB
|
|
122
122
|
├ λ /pvt/account/security 3.96 kB 144 kB
|
|
123
123
|
├ └ css/973dd40d4773e8cd.css 5.74 kB
|
|
124
|
-
├ λ /pvt/account/user-details 1.91 kB
|
|
124
|
+
├ λ /pvt/account/user-details 1.91 kB 141 kB
|
|
125
125
|
├ └ css/05c399956ff24b77.css 4.54 kB
|
|
126
126
|
└ ● /s 3.35 kB 159 kB
|
|
127
|
-
+ First Load JS shared by all
|
|
127
|
+
+ First Load JS shared by all 111 kB
|
|
128
128
|
├ chunks/framework-d514426edf885c68.js 45.4 kB
|
|
129
129
|
├ chunks/main-ec03882c4375091d.js 33.2 kB
|
|
130
|
-
├ chunks/pages/_app-
|
|
131
|
-
├ chunks/webpack-
|
|
130
|
+
├ chunks/pages/_app-f531201d1d916a86.js 25.2 kB
|
|
131
|
+
├ chunks/webpack-639c88ba267a2928.js 3.86 kB
|
|
132
132
|
└ css/0f070d03aacd9cc5.css 3.57 kB
|
|
133
133
|
|
|
134
134
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.97.0-dev.
|
|
2
|
+
> @faststore/core@3.97.0-dev.3 test /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> jest
|
|
4
4
|
|
|
5
|
-
PASS test/utils/multipleTemplates.test.ts (
|
|
6
|
-
PASS test/utils/clearCookies.test.ts (
|
|
5
|
+
PASS test/utils/multipleTemplates.test.ts (30.161 s)
|
|
6
|
+
PASS test/utils/clearCookies.test.ts (29.161 s)
|
|
7
7
|
PASS test/server/cms/global.test.ts
|
|
8
8
|
PASS test/utils/cookieCacheBusting.test.ts
|
|
9
9
|
PASS test/server/cms/index.test.ts
|
|
10
|
-
PASS test/server/index.test.ts (
|
|
10
|
+
PASS test/server/index.test.ts (33.598 s)
|
|
11
11
|
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
|
|
12
12
|
|
|
13
13
|
Test Suites: 6 passed, 6 total
|
|
14
14
|
Tests: 47 passed, 47 total
|
|
15
15
|
Snapshots: 0 total
|
|
16
|
-
Time: 34.
|
|
16
|
+
Time: 34.88 s
|
|
17
17
|
Ran all test suites.
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.97.0-dev.4](https://github.com/vtex/faststore/compare/v3.97.0-dev.3...v3.97.0-dev.4) (2026-02-10)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- scripts improvements - update RC url + Partytown loading + logs + fix bugs. ([#3198](https://github.com/vtex/faststore/issues/3198)) ([9a35b63](https://github.com/vtex/faststore/commit/9a35b63a91bc5cd53de553c053ceeed8bb983184))
|
|
11
|
+
|
|
6
12
|
# [3.97.0-dev.3](https://github.com/vtex/faststore/compare/v3.97.0-dev.2...v3.97.0-dev.3) (2026-02-06)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.97.0-dev.
|
|
3
|
+
"version": "3.97.0-dev.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"ts-jest": "29.1.1",
|
|
124
124
|
"typescript": "5.3.2"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "56312eb70d134933d2d9efbb04b8a6ffe97d623d"
|
|
127
127
|
}
|
package/src/Layout.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isValidElement, type PropsWithChildren } from 'react'
|
|
2
2
|
|
|
3
3
|
import { usePageViewEvent } from './sdk/analytics/hooks/usePageViewEvent'
|
|
4
4
|
|
|
5
5
|
function Layout({ children }: PropsWithChildren) {
|
|
6
|
-
const props =
|
|
6
|
+
const props = isValidElement(children) ? children.props : undefined
|
|
7
7
|
usePageViewEvent(props)
|
|
8
8
|
|
|
9
9
|
return <>{children}</>
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { LOG_LABEL_STYLE } from 'src/constants'
|
|
2
|
+
import storeConfig from '../../../discovery.config'
|
|
3
|
+
|
|
4
|
+
const enableScriptsLogs = storeConfig.experimental?.enableScriptsLogs === true
|
|
5
|
+
|
|
1
6
|
interface Props {
|
|
2
7
|
containerId: string
|
|
3
8
|
dataLayerName?: string
|
|
@@ -5,16 +10,20 @@ interface Props {
|
|
|
5
10
|
|
|
6
11
|
export const GTM_DEBUG_QUERY_STRING = 'gtm_debug'
|
|
7
12
|
|
|
8
|
-
const useSnippet = (opts: Props & { partytownScript: boolean }) =>
|
|
9
|
-
opts.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const useSnippet = (opts: Props & { partytownScript: boolean }) => {
|
|
14
|
+
const dataLayer = opts.dataLayerName ?? 'dataLayer'
|
|
15
|
+
return `${
|
|
16
|
+
opts.partytownScript ? '!' : ''
|
|
17
|
+
}window.location.search.includes('${GTM_DEBUG_QUERY_STRING}=')&&
|
|
18
|
+
(function(w,d,s,l,i){w[l]=w[l]||[];
|
|
19
|
+
${enableScriptsLogs ? `w[l].push=(function(orig){return function(){console.debug("%cvtex%c GTM dataLayer.push","${LOG_LABEL_STYLE}","color:inherit",arguments);return orig.apply(this, arguments);}})(w[l].push);` : ''}
|
|
20
|
+
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
|
21
|
+
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
22
|
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
23
|
+
})(window,document,'script',${JSON.stringify(
|
|
24
|
+
dataLayer
|
|
25
|
+
)},${JSON.stringify(opts.containerId)});`
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
/**
|
|
20
29
|
* Google Tag Manager script adapted to be executed only when necessary.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Partytown } from '@builder.io/partytown/react'
|
|
2
1
|
import storeConfig from 'discovery.config'
|
|
3
2
|
import OverrideComponents from 'src/customizations/src/GlobalOverrides'
|
|
4
|
-
import GoogleTagManager
|
|
3
|
+
import GoogleTagManager from './GoogleTagManager'
|
|
5
4
|
import VTEX from './vtex'
|
|
6
5
|
|
|
7
6
|
const gtmContainerId = storeConfig.analytics?.gtmContainerId
|
|
@@ -16,31 +15,11 @@ if (process.env.NODE_ENV === 'development' && !includeGTM) {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
function ThirdPartyScripts() {
|
|
19
|
-
const forwards = []
|
|
20
|
-
if (includeVTEX) forwards.push('sendrc')
|
|
21
|
-
|
|
22
18
|
return (
|
|
23
19
|
<>
|
|
24
|
-
{/* We're setting the partytown config (forward property) dynamically based on the gtm_debug query string
|
|
25
|
-
* This helps users see the GTM events properly when using GTM preview. All it does is NOT forward dataLayer.push
|
|
26
|
-
* calls to partytown when the gtm_debug query string is present.
|
|
27
|
-
*
|
|
28
|
-
* This is not done in the component because the window var is not available yet.
|
|
29
|
-
*/}
|
|
30
|
-
<script
|
|
31
|
-
dangerouslySetInnerHTML={{
|
|
32
|
-
__html: `var partytown={forward:[...${JSON.stringify(
|
|
33
|
-
forwards
|
|
34
|
-
)},!window.location.search.includes('${GTM_DEBUG_QUERY_STRING}=')&&${includeGTM}?'dataLayer.push':null].filter(Boolean)}`,
|
|
35
|
-
}}
|
|
36
|
-
/>
|
|
37
20
|
{includeGTM && <GoogleTagManager containerId={gtmContainerId} />}
|
|
38
21
|
{includeVTEX && <VTEX />}
|
|
39
22
|
<OverrideComponents.ThirdPartyScripts />
|
|
40
|
-
{/* Only render Partytown when not in an iframe to prevent cross-origin errors. */}
|
|
41
|
-
{typeof window !== 'undefined' && window.self === window.top && (
|
|
42
|
-
<Partytown key="partytown" />
|
|
43
|
-
)}
|
|
44
23
|
</>
|
|
45
24
|
)
|
|
46
25
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { LOG_LABEL_STYLE } from 'src/constants'
|
|
1
2
|
import storeConfig from '../../../discovery.config'
|
|
2
3
|
|
|
4
|
+
const enableScriptsLogs = storeConfig.experimental?.enableScriptsLogs === true
|
|
5
|
+
|
|
3
6
|
function VTEX() {
|
|
4
7
|
return (
|
|
5
8
|
<>
|
|
@@ -10,6 +13,7 @@ function VTEX() {
|
|
|
10
13
|
__html: `
|
|
11
14
|
window.VTEX_METADATA = {account:'${storeConfig.api.storeId}', renderer: 'faststore'};
|
|
12
15
|
window.sendrc=function(en,ed){window.NavigationCapture&&window.NavigationCapture.sendEvent(en,ed)};
|
|
16
|
+
${enableScriptsLogs ? 'window.sendrc=(function(orig){return function(en,ed){console.debug("%cvtex%c RC sendrc","' + LOG_LABEL_STYLE + '","color:inherit",en,ed);return orig(en,ed)}})(window.sendrc);' : ''}
|
|
13
17
|
`,
|
|
14
18
|
}}
|
|
15
19
|
/>
|
|
@@ -17,7 +21,7 @@ function VTEX() {
|
|
|
17
21
|
key="vtexrc.js-script"
|
|
18
22
|
type="text/partytown"
|
|
19
23
|
async
|
|
20
|
-
src="https://
|
|
24
|
+
src="https://io2.vtex.com/rc/rc.js"
|
|
21
25
|
/>
|
|
22
26
|
<script
|
|
23
27
|
type="text/javascript"
|
|
@@ -26,6 +30,7 @@ function VTEX() {
|
|
|
26
30
|
__html: `
|
|
27
31
|
(function(v,t,e,x,a,f,s){
|
|
28
32
|
f=v.vtexaf=v.vtexaf||function(){(f.q=f.q||[]).push(arguments)}
|
|
33
|
+
${enableScriptsLogs ? 'f=(function(orig){return function(){console.debug("%cvtex%c AF","' + LOG_LABEL_STYLE + '","color:inherit",arguments);return orig.apply(this, arguments)}})(f);v.vtexaf=f;' : ''}
|
|
29
34
|
;f.l=+new Date;s=t.createElement(e);s.async=!0;
|
|
30
35
|
s.src=x;a=t.getElementsByTagName(e)[0];
|
|
31
36
|
a.parentNode.insertBefore(s,a)
|
package/src/constants.ts
CHANGED
package/src/pages/_document.tsx
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { Head, Html, Main, NextScript } from 'next/document'
|
|
2
2
|
import storeConfig from '../../discovery.config'
|
|
3
3
|
|
|
4
|
+
import { GTM_DEBUG_QUERY_STRING } from 'src/components/ThirdPartyScripts/GoogleTagManager'
|
|
4
5
|
import { WebFonts } from 'src/customizations/src/GlobalOverrides'
|
|
5
6
|
|
|
6
7
|
function Document() {
|
|
7
8
|
const direction = storeConfig.direction || 'ltr'
|
|
9
|
+
const gtmContainerId = storeConfig.analytics?.gtmContainerId
|
|
10
|
+
const includeGTM = typeof gtmContainerId === 'string'
|
|
11
|
+
const includeVTEX = storeConfig.platform === 'vtex'
|
|
12
|
+
const enableScriptsLogs = storeConfig.experimental?.enableScriptsLogs === true
|
|
13
|
+
const forwards = []
|
|
14
|
+
if (includeVTEX) forwards.push('sendrc')
|
|
8
15
|
|
|
9
16
|
return (
|
|
10
17
|
<Html dir={direction}>
|
|
@@ -19,6 +26,39 @@ function Document() {
|
|
|
19
26
|
/>
|
|
20
27
|
<meta name="storefront" content="fast_store" />
|
|
21
28
|
<WebFonts />
|
|
29
|
+
{/* Partytown config must be set before loading the library.
|
|
30
|
+
* We're setting the partytown config (forward property) dynamically based on the gtm_debug query string
|
|
31
|
+
* This helps users see the GTM events properly when using GTM preview. All it does is NOT forward dataLayer.push
|
|
32
|
+
* calls to partytown when the gtm_debug query string is present.
|
|
33
|
+
*
|
|
34
|
+
* This is not done in the component because the window var is not available yet.
|
|
35
|
+
*/}
|
|
36
|
+
<script
|
|
37
|
+
dangerouslySetInnerHTML={{
|
|
38
|
+
__html: `var partytown={
|
|
39
|
+
debug:${enableScriptsLogs},
|
|
40
|
+
logCalls:${enableScriptsLogs},
|
|
41
|
+
forward:[...${JSON.stringify(
|
|
42
|
+
forwards
|
|
43
|
+
)},!window.location.search.includes('${GTM_DEBUG_QUERY_STRING}=')&&${includeGTM}?'dataLayer.push':null].filter(Boolean)
|
|
44
|
+
}`,
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
{/* Only load Partytown when not in an iframe to prevent cross-origin errors.
|
|
48
|
+
* https://github.com/vtex/faststore/pull/3155
|
|
49
|
+
*/}
|
|
50
|
+
<script
|
|
51
|
+
dangerouslySetInnerHTML={{
|
|
52
|
+
__html: `
|
|
53
|
+
if (window.self === window.top) {
|
|
54
|
+
var partytownScript = document.createElement('script');
|
|
55
|
+
partytownScript.async = true;
|
|
56
|
+
partytownScript.src = '/~partytown/partytown.js';
|
|
57
|
+
document.head.appendChild(partytownScript);
|
|
58
|
+
}
|
|
59
|
+
`,
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
22
62
|
</Head>
|
|
23
63
|
<body className="theme">
|
|
24
64
|
<Main />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PageViewEvent } from '@faststore/sdk'
|
|
2
2
|
import { useRouter } from 'next/router'
|
|
3
|
-
import { useCallback, useEffect } from 'react'
|
|
3
|
+
import { useCallback, useEffect, useRef } from 'react'
|
|
4
4
|
|
|
5
5
|
export const usePageViewEvent = (props?: any) => {
|
|
6
6
|
const sendPageViewEvent = useCallback(() => {
|
|
@@ -18,10 +18,15 @@ export const usePageViewEvent = (props?: any) => {
|
|
|
18
18
|
}, [props])
|
|
19
19
|
|
|
20
20
|
const router = useRouter()
|
|
21
|
+
const lastPathRef = useRef<string | null>(null)
|
|
21
22
|
|
|
22
23
|
useEffect(() => {
|
|
24
|
+
if (lastPathRef.current === router.asPath) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
lastPathRef.current = router.asPath
|
|
23
28
|
sendPageViewEvent()
|
|
24
|
-
}, [router.
|
|
29
|
+
}, [router.asPath, sendPageViewEvent])
|
|
25
30
|
|
|
26
31
|
return { sendPageViewEvent }
|
|
27
32
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { AnalyticsEvent } from '@faststore/sdk'
|
|
5
5
|
import type { SearchEvents } from '../../types'
|
|
6
6
|
|
|
7
|
+
import { LOG_LABEL_STYLE } from 'src/constants'
|
|
7
8
|
import { getBaseDomain } from 'src/utils/getBaseDomain'
|
|
8
9
|
import { getCookie } from 'src/utils/getCookie'
|
|
9
10
|
import config from '../../../../../discovery.config'
|
|
@@ -11,6 +12,7 @@ import config from '../../../../../discovery.config'
|
|
|
11
12
|
const THIRTY_MINUTES_S = 30 * 60
|
|
12
13
|
const ONE_YEAR_S = 365 * 24 * 3600
|
|
13
14
|
|
|
15
|
+
const enableScriptsLogs = config.experimental?.enableScriptsLogs === true
|
|
14
16
|
const randomUUID = () =>
|
|
15
17
|
typeof crypto.randomUUID === 'function'
|
|
16
18
|
? crypto.randomUUID().replaceAll('-', '')
|
|
@@ -83,19 +85,31 @@ type SearchEvent =
|
|
|
83
85
|
type: 'search.autocomplete.click'
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
const sendEvent = (options: SearchEvent & { url?: string }) =>
|
|
87
|
-
|
|
88
|
+
const sendEvent = (options: SearchEvent & { url?: string }) => {
|
|
89
|
+
const payload = {
|
|
90
|
+
...options,
|
|
91
|
+
userAgent: navigator.userAgent,
|
|
92
|
+
anonymous: user.anonymous(),
|
|
93
|
+
session: user.session(),
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (enableScriptsLogs) {
|
|
97
|
+
console.debug(
|
|
98
|
+
'%cvtex%c Search Event',
|
|
99
|
+
LOG_LABEL_STYLE,
|
|
100
|
+
'color:inherit',
|
|
101
|
+
payload
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return fetch(`https://sp.vtex.com/event-api/v1/${config.api.storeId}/event`, {
|
|
88
106
|
method: 'POST',
|
|
89
|
-
body: JSON.stringify(
|
|
90
|
-
...options,
|
|
91
|
-
userAgent: navigator.userAgent,
|
|
92
|
-
anonymous: user.anonymous(),
|
|
93
|
-
session: user.session(),
|
|
94
|
-
}),
|
|
107
|
+
body: JSON.stringify(payload),
|
|
95
108
|
headers: {
|
|
96
109
|
'content-type': 'application/json',
|
|
97
110
|
},
|
|
98
111
|
})
|
|
112
|
+
}
|
|
99
113
|
|
|
100
114
|
const isFullTextSearch = (url: URL) =>
|
|
101
115
|
typeof url.searchParams.get('q') === 'string' &&
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
exports.id=4168,exports.ids=[4168],exports.modules={38038:e=>{e.exports={seo:{title:"FastStore Starter",description:"Fast Demo Store",titleTemplate:"%s | FastStore",author:"Store Framework",name:"FastStore",publisherId:"",plp:{titleTemplate:"%s | FastStore PLP",descriptionTemplate:"%s products on FastStore Product Listing Page"},pdp:{titleTemplate:"%s | FastStore PDP",descriptionTemplate:"%s products on FastStore Product Detail Page",minPriceAmountFractionDigits:void 0},search:{titleTemplate:"%s | Search results",descriptionTemplate:"%s Search results description",noIndex:!0,noFollow:!0,bodyH1:"Showing results for:"}},theme:"custom-theme",platform:"vtex",api:{storeId:"storeframework",workspace:"master",subDomainPrefix:["www"],environment:"vtexcommercestable",hideUnavailableItems:!1,showSponsored:!1,incrementAddress:!0,enableUnavailableItemsOnCart:!1},session:{currency:{code:"USD",symbol:"$"},locale:"en-US",channel:'{"salesChannel":"1","regionId":"","hasOnlyDefaultSalesChannel":"true"}',country:"USA",deliveryMode:null,addressType:null,city:null,postalCode:null,geoCoordinates:null,b2b:null,person:null,marketingData:{utmCampaign:"",utmMedium:"",utmSource:"",utmiCampaign:"",utmiPart:"",utmiPage:""},refreshAfter:null},cart:{id:"",items:[],messages:[],shouldSplitItem:!0},storeUrl:"https://homebrewqa.fast.store",secureSubdomain:"https://homebrewqa.fast.store",checkoutUrl:"https://homebrewqa.fast.store/checkout",loginUrl:"https://homebrewqa.fast.store/api/io/login",accountUrl:"https://homebrewqa.fast.store/api/io/account",previewRedirects:{home:"/",plp:"/office",search:"/s?q=headphone",pdp:"/apple-magic-mouse/p",500:"/500",404:"/404"},lighthouse:{server:process.env.BASE_SITE_URL||"http://localhost:3000",pages:{home:"/",pdp:"/4k-philips-monitor-99988213/p",collection:"/office"}},cypress:{pages:{home:"/",pdp:"/4k-philips-monitor-99988213/p",collection:"/office",collection_2:"/technology",collection_filtered:"/office/?category-1=office&marca=acer&facets=category-1%2Cmarca",search:"/s?q=orange"}},analytics:{gtmContainerId:"GTM-PGHZ95N"},cms:{data:process.env.CMS_DATA},contentSource:{type:"CMS"},deliveryPromise:{enabled:!1,mandatory:!1},experimental:{cypressVersion:12,enableCypressExtension:!1,noRobots:!1,noindex:!1,nofollow:!1,preact:!1,enableRedirects:!1,enableSearchSSR:!1,enableFaststoreMyAccount:!1,graphqlCacheControl:{maxAge:0,staleWhileRevalidate:3600},refreshToken:!1,scrollRestoration:!1},direction:"ltr"}},43412:(e,t,o)=>{let r=o(38038),s=o(2512),n=o(56330),a=n(r,s);e.exports=a},2512:e=>{e.exports={}},39729:(e,t,o)=>{"use strict";o.d(t,{Q:()=>c,Z:()=>i});var r=o(20997);let fonts_WebFonts=function(){return r.jsx(r.Fragment,{})},s={components:{WebFonts:fonts_WebFonts}},n={components:{ThirdPartyScripts:()=>r.jsx(r.Fragment,{})}};function ownKeys(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,r)}return o}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach(function(t){var r;r=o[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))})}return e}let a=_objectSpread(_objectSpread(_objectSpread(_objectSpread({WebFonts:fonts_WebFonts},n.components),s.components),s.components),n.components),c=a.WebFonts,i=a}};
|