-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
😔- Commented Out Partytown (#1091)
* Commented Partytown * Removed Partytown copy lib from dev and build scripts
- Loading branch information
1 parent
2768abb
commit 033071b
Showing
2 changed files
with
50 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters