Git Product home page Git Product logo

Comments (2)

j0Shi82 avatar j0Shi82 commented on July 18, 2024

I'm using resolveUrl in many projects and it seems to work fine. See: https://www.partydawn.top/?sgtm&pt

It uses the following settings code:

const params = new URLSearchParams(location.search);
const pt = params.has("pt");
const xhrfetch = params.has("xhrfetch");
const xhrallow = params.has("xhrallow");
partytown = {
    forward: pt ? ["dataLayer.push"] : [],
    allowXhrCredentials: xhrallow,
    debug: true,
    logCalls: true,
    logGetters: true,
    logSetters: true,
    logImageRequests: true,
    logScriptExecution: true,
    logSendBeaconRequests: true,
    logStackTraces: false,
};

if (xhrfetch) {
    partytown.resolveUrl = function (url, location, type) {
        if (type === "script" && url.host !== "proxy.partydawn.top") {
            const proxyUrl = new URL("https://proxy.partydawn.top/api/partytown/proxy");
            proxyUrl.searchParams.set("url", url.href);
            proxyUrl.searchParams.set("xhrfetch", true);
            return proxyUrl;
        }

        return url;
    };
} else {
    partytown.resolveUrl = function (url, location, type) {
        if (type === "script" && url.host !== "proxy.partydawn.top") {
            const proxyUrl = new URL("https://proxy.partydawn.top/api/partytown/proxy");
            proxyUrl.searchParams.set("url", url.href);
            return proxyUrl;
        }

        return url;
    };
}

from partytown.

totodot avatar totodot commented on July 18, 2024

Same here resolveUrl not fired i nextjs app

 <Partytown
    debug={true}
    resolveUrl={(url, location, type) => {
      console.log(url);
      return url;
    }}
    forward={['dataLayer.push']}
  />
  <script
    key="plugin-google-tagmanager"
    type="text/partytown"
    dangerouslySetInnerHTML={{
      __html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','${GOOGLE_TAG_MANAGER}');`,
    }}
  />

Other props like logScriptExecution don't work too.
So only debug and forward props works fine for Partytown component.

from partytown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.