Add option to build the app without GA and SW

This commit is contained in:
Stefano Brilli 2021-08-18 11:00:47 +02:00
parent b19099de6b
commit e59b74ae42
1 changed files with 24 additions and 2 deletions

View File

@ -106,5 +106,27 @@ ReactDOM.render(
document.getElementById('root')
);
// serviceWorker.unregister();
serviceWorker.register();
if (process.env.REACT_APP_NO_GA_RELEASE !== 'true') {
serviceWorker.register();
// serviceWorker.unregister();
try {
(function() {
let head = document.getElementsByTagName('head')[0];
let uascript = document.createElement('script');
uascript.type = 'text/javascript';
uascript.src = 'https://www.googletagmanager.com/gtag/js?id=UA-60498490-1';
head.appendChild(uascript);
let pvscript = document.createElement('script');
pvscript.type = 'text/javascript';
pvscript.text = `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-60498490-1');
`;
head.appendChild(pvscript);
})();
} catch (err) {}
}