Skip to content

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

@renukote

Description

@renukote

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions