Skip to content

Commit

Permalink
fix: Update VTEX script initialization and remove unused parameters (#…
Browse files Browse the repository at this point in the history
…2577)

Remove vtexaf initialization from Partytown.
  • Loading branch information
emersonlaurentino committed Jan 20, 2025
1 parent 7cf4b9f commit 3214403
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (process.env.NODE_ENV === 'development' && !includeGTM) {

function ThirdPartyScripts() {
const forwards = []
if (includeVTEX) forwards.push('sendrc', 'vtexaf')
if (includeVTEX) forwards.push('sendrc')

return (
<>
Expand Down
29 changes: 21 additions & 8 deletions packages/core/src/components/ThirdPartyScripts/vtex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,31 @@ function VTEX() {
src="https://io.vtex.com.br/rc/rc.js"
/>
<script
key="vtex-af.js-init"
type="text/partytown"
type="text/javascript"
key="vtexaf-init"
dangerouslySetInnerHTML={{
__html: `f=window.vtexaf=window.vtexaf||function(){(f.q=f.q||[]).push(arguments)};f.l=+new Date`,
__html: `
(function(v,t,e,x,a,f,s){
f=v.vtexaf=v.vtexaf||function(){(f.q=f.q||[]).push(arguments)}
;f.l=+new Date;s=t.createElement(e);s.async=!0;
s.src=x;a=t.getElementsByTagName(e)[0];
a.parentNode.insertBefore(s,a)
})(window,document,'script','https://activity-flow.vtex.com/af/af.js');
`,
}}
/>
<script
key="vtex-af.js-script"
type="text/partytown"
data-an={storeConfig.api.storeId}
async
src="https://activity-flow.vtex.com/af/af.js"
type="text/javascript"
key="vtexaf-config"
dangerouslySetInnerHTML={{
__html: `
window.vtexaf('init', {
account: '${storeConfig.api.storeId}',
env: '${storeConfig.api.environment}',
workspace: '${storeConfig.api.workspace}'
});
`,
}}
/>
</>
)
Expand Down

0 comments on commit 3214403

Please sign in to comment.