Skip to content

Commit

Permalink
docs: load adobe analytics only once
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux committed Jun 17, 2024
1 parent f4eeebf commit 2fcf614
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 159 deletions.
30 changes: 29 additions & 1 deletion packages/documentation/src/theme/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { useLocation } from '@docusaurus/router';
import React, { useEffect } from 'react';
import React, { useEffect, useLayoutEffect } from 'react';

declare global {
interface Window {
Expand Down Expand Up @@ -36,5 +36,33 @@ export default function Root({ children }) {
});
}, [pathname]);

useLayoutEffect(() => {
const isAlreadyLoaded = document.head.querySelector(
'meta[name="adobe-loaded"]'
);
if (!isAlreadyLoaded) {
const script = document.createElement('script');
script.setAttribute('no-cors', '');
script.src = '//w3.siemens.com/ote/ote_config.js';
document.head.appendChild(script);

const script2 = document.createElement('script');
script2.src = '//w3.siemens.com/ote/global/ote.js';
document.head.appendChild(script2);

const script3 = document.createElement('script');
script3.src =
'https://assets.adobedtm.com/5dfc7d97c6fb/7699a47b720a/launch-2157063140e5.min.js';
script3.async = true;
document.head.appendChild(script3);

const meta = document.createElement('meta');
meta.name = 'adobe-loaded';
meta.content = 'true';

document.head.appendChild(meta);
}
}, []);

return <>{children}</>;
}
158 changes: 0 additions & 158 deletions packages/documentation/src/theme/SiteMetadata/index.tsx

This file was deleted.

0 comments on commit 2fcf614

Please sign in to comment.