Skip to content

Commit

Permalink
😔- Commented Out Partytown (#1091)
Browse files Browse the repository at this point in the history
* Commented Partytown

* Removed Partytown copy lib from dev and build scripts
  • Loading branch information
Harry-Ross authored Jul 21, 2023
1 parent 2768abb commit 033071b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 49 deletions.
95 changes: 48 additions & 47 deletions components/layout/analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
import { Partytown } from "@builder.io/partytown/react";
import Head from "next/head";
import Script from "next/script";

const gtmId = process.env.NEXT_PUBLIC_GOOGLE_GTM_ID;

export const Analytics = () => {
return (
<Head>
<Partytown
debug={false}
logScriptExecution
logSendBeaconRequests
forward={[
"gtag",
"dataLayer.push",
"_hsq.push, fbq, __tag_assistant_forwarder",
"hj",
"hjBootstrap",
"hjBootstrapCalled",
"hjLazyModules",
"hjSiteSettings",
"_hjSettings",
"clarity",
]}
resolveUrl={(url, location, type) => {
const proxiedWhitelist = [
"connect.facebook.net",
"snap.licdn.com",
"cdn3l.ink",
"googleads.g.doubleclick.net",
"js.hs-analytics.net",
"www.google.com",
];
// TODO - uncomment this when we're ready to use Partytown
// <Head>
// <Partytown
// debug={false}
// logScriptExecution
// logSendBeaconRequests
// forward={[
// "gtag",
// "dataLayer.push",
// "_hsq.push, fbq, __tag_assistant_forwarder",
// "hj",
// "hjBootstrap",
// "hjBootstrapCalled",
// "hjLazyModules",
// "hjSiteSettings",
// "_hjSettings",
// "clarity",
// ]}
// resolveUrl={(url, location, type) => {
// const proxiedWhitelist = [
// "connect.facebook.net",
// "snap.licdn.com",
// "cdn3l.ink",
// "googleads.g.doubleclick.net",
// "js.hs-analytics.net",
// "www.google.com",
// ];

if (
(type === "script" &&
!url.pathname.includes("gtm.js") &&
proxiedWhitelist.includes(url.hostname)) ||
url.href.includes("https://www.google-analytics.com/analytics.js")
) {
const proxiedUrl = new URL(
"https://cdn.builder.io/api/v1/proxy-api"
);
proxiedUrl.searchParams.append("url", url.href);
return proxiedUrl;
}
return url;
}}
/>
<script id="google-tag-manager" type="text/partytown">
{`
// if (
// (type === "script" &&
// !url.pathname.includes("gtm.js") &&
// proxiedWhitelist.includes(url.hostname)) ||
// url.href.includes("https://www.google-analytics.com/analytics.js")
// ) {
// const proxiedUrl = new URL(
// "https://cdn.builder.io/api/v1/proxy-api"
// );
// proxiedUrl.searchParams.append("url", url.href);
// return proxiedUrl;
// }
// return url;
// }}
// />

// </Head>
<Script id="google-tag-manager" strategy="afterInteractive">
{`
(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','${gtmId}');
`}
</script>
</Head>
</Script>
);
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.22.19",
"private": true,
"scripts": {
"dev": "npm run partytown && tinacms dev -c \"node --require ./appInsight-api.js node_modules/next/dist/bin/next dev\"",
"build": "npm run partytown && tinacms build && next build && next-sitemap --config next-sitemap.config.js",
"dev": "tinacms dev -c \"node --require ./appInsight-api.js node_modules/next/dist/bin/next dev\"",
"build": "tinacms build && next build && next-sitemap --config next-sitemap.config.js",
"partytown": "partytown copylib public/~partytown",
"postbuild": "next-sitemap --config next-sitemap.config.js",
"start": "tinacms build && node_modules/next/dist/bin/next start -p $PORT",
Expand Down

0 comments on commit 033071b

Please sign in to comment.