Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] Partytown throwing 404 on the live site #619

Open
renukote opened this issue Aug 31, 2024 · 1 comment
Open

[🐞] Partytown throwing 404 on the live site #619

renukote opened this issue Aug 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@renukote
Copy link

renukote commented Aug 31, 2024

Describe the bug

I'm using partytown version ^0.10.2 in my Gatsy project to load GTM and Netlify to host the repo. Everything works fine in preview deployments but as soon as I make it live, partytown call in the network tab throws 404.

Screenshot from live site
Screenshot from 2024-08-31 16-41-28

Screenshot from deployment preview
Screenshot from 2024-08-31 16-37-16

I'm loading all the lib files in gatsby-node.js as suggested in https://partytown.builder.io/gatsby

I tried using both onPreBuild and onPreBootstrap but the output is the same. I tried it twice on the production site and reverted it.

Here is the code from my project

gatsby-node.js

exports.onPreBuild = async () => {
  await copyLibFiles(path.join(__dirname, 'static', '~partytown'));
};

gatsby-ssr.js (inside onRenderBody)

  setHeadComponents([
    <Partytown key="partytown" forward={['dataLayer.push', 'gtag']} />,
    <script key="google-analytics" type="text/partytown" src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GOOGLE_TAGMANAGER_ID}`} />,
    <script
      key="google-analytics-config"
      type="text/partytown"
      // eslint-disable-next-line react/no-danger
      dangerouslySetInnerHTML={{
        __html: `window.dataLayer = window.dataLayer || [];
            window.gtag = function gtag(){ window.dataLayer.push(arguments);}
            gtag('js', new Date()); 
            gtag('config', '${process.env.GOOGLE_TAGMANAGER_ID}', { send_page_view: false })`
      }}
    />
  ]);

package.json (inside dependencies)
"@builder.io/partytown": "^0.10.2",

Am I missing something here?

Reproduction

Steps to reproduce

  • Add partytown to Gatsby as shown above
  • Load GTM inside partytown
  • Deploy in Netlify, test the deployment preview (partytown should load normally)
  • Publish the deployment to live site (partytown should throw 404)

Browser Info

Chromium

Additional Information

No response

@renukote renukote added the bug Something isn't working label Aug 31, 2024
@renukote renukote changed the title [🐞] Partytown not loading only on live [🐞] Partytown not loading on the live site Aug 31, 2024
@renukote renukote changed the title [🐞] Partytown not loading on the live site [🐞] Partytown throwing 404 on the live site Aug 31, 2024
@renukote
Copy link
Author

renukote commented Sep 1, 2024

image

Since it's showing partytown library is not being found, I also tried manually pushing all the lib files into the static folder and deployed it to live to see if that resolves the issue. Even that didn't work. I got the above error in the console.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant