From ddeb6c177642108434ecabe95e50820f42e2cd9d Mon Sep 17 00:00:00 2001 From: LH_R Date: Sun, 7 Jan 2024 14:31:18 +0800 Subject: [PATCH] feat: dynamic loading clarity --- index.html | 7 ------- src/main.tsx | 13 +++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index b1ff9cd..5fe2ee4 100644 --- a/index.html +++ b/index.html @@ -11,12 +11,5 @@
- diff --git a/src/main.tsx b/src/main.tsx index fe4fa7e..b355232 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -4,6 +4,19 @@ import App from './App' import './index.css' import './i18n' +if (import.meta.env.PROD) { + const script = document.createElement('script') + script.textContent = ` + (function(c,l,a,r,i,t,y){ + c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; + t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; + y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); + })(window, document, "clarity", "script", "k06rclje17"); + ` + script.async = true + document.body.appendChild(script) +} + ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(