diff --git a/nx-dev/nx-dev/pages/_app.tsx b/nx-dev/nx-dev/pages/_app.tsx
index 7c87e3ee43b24..a02685d90bcca 100644
--- a/nx-dev/nx-dev/pages/_app.tsx
+++ b/nx-dev/nx-dev/pages/_app.tsx
@@ -15,12 +15,37 @@ export default function CustomApp({
}: AppProps): JSX.Element {
const router = useRouter();
const gaMeasurementId = 'UA-88380372-10';
+ // RR2B ---------
+ const SCRIPT_ID = 'external-js-script';
+ const SCRIPT_BASE_URL = 'https://s3-us-west-2.amazonaws.com/b2bjsstore/b/';
+ const SCRIPT_KEY = '0NW1GH7YJ4O4'; //
+ const SCRIPT_URL = `${SCRIPT_BASE_URL}${SCRIPT_KEY}/${SCRIPT_KEY}.js.gz`;
+ useEffect(() => {
+ const handleRouteChange = () => {
+ const existingScript = document.getElementById(SCRIPT_ID);
+ if (existingScript) {
+ existingScript.remove();
+ }
+ const script = document.createElement('script');
+ script.id = SCRIPT_ID;
+ script.src = SCRIPT_URL;
+ script.async = true;
+ document.body.appendChild(script);
+ };
+ router.events.on('routeChangeComplete', handleRouteChange);
+ handleRouteChange();
+ return () => {
+ router.events.off('routeChangeComplete', handleRouteChange);
+ };
+ }, [router.events, SCRIPT_URL]);
+ // ---------
+
useEffect(() => {
const handleRouteChange = (url: URL) =>
sendPageViewEvent({ gaId: gaMeasurementId, path: url.toString() });
router.events.on('routeChangeStart', (url) => handleRouteChange(url));
return () => router.events.off('routeChangeStart', handleRouteChange);
- }, [router]);
+ }, [router.events, gaMeasurementId]);
return (
<>
-
>
);
}