From 04b540f02b34c36c349c80bd3965dad2944fbea5 Mon Sep 17 00:00:00 2001 From: "Harry Ross [SSW]" Date: Fri, 14 Jul 2023 10:14:21 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Partytown=20Reverse=20Proxy=20Fi?= =?UTF-8?q?x=20(#1006)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added debug partytown * Added forward * Added partytown scripts to build * Added datalayer.push * Fixed partytown implementation * Added proxy * Fixed to correct URL * Updated partytown with correct configuration * Removed unused packages, added schema validation * Added hard coded URLs meant to be proxied * Removed some hard coded links * Added shared link whitelist, removed lint warning * Fixed proxied implementation (scoping of variable in resolveUrl function must be in that function) * Removed constants file, duplicated constants (required) * Added builder.io proxy * Removed proxy API route * Added legacy google analytics to conditional * Removed lib file, as copied over in build step anyway --- .gitignore | 3 +++ components/layout/analytics.tsx | 39 +++++++++++++++++++++++++++++---- next.config.js | 3 --- package.json | 5 +++-- pages/_app.tsx | 2 +- 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 02b7cc5726..d208944b23 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ yarn-error.log* # Next bundle analyser /analyze +# Partytown lib files +/public/~partytown + diff --git a/components/layout/analytics.tsx b/components/layout/analytics.tsx index 618140589b..8c839c909a 100644 --- a/components/layout/analytics.tsx +++ b/components/layout/analytics.tsx @@ -1,17 +1,48 @@ -import Script from "next/script"; +import { Partytown } from "@builder.io/partytown/react"; +import Head from "next/head"; const gtmId = process.env.NEXT_PUBLIC_GOOGLE_GTM_ID; export const Analytics = () => { return ( - + + ); }; diff --git a/next.config.js b/next.config.js index 87a190fed0..861ff254b8 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,4 @@ const config = { - experimental: { - nextScriptWorkers: true, - }, i18n: { locales: ["en"], defaultLocale: "en", diff --git a/package.json b/package.json index 1026f06306..2095160eba 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,9 @@ "version": "1.22.19", "private": true, "scripts": { - "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", + "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", + "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", "export": "npm run build && next export", diff --git a/pages/_app.tsx b/pages/_app.tsx index 25a65f6200..4ea70cd9b0 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -56,12 +56,12 @@ const App = ({ Component, pageProps }) => { return ( <> + - ); };