By deleting microsoft clarity script my nextjs application breaks

141 views Asked by At

I want to remove clarity from my app and when I remove the script my whole nextjs application breaks. I'm importing this code on my _app.js file but by removing it the app breaks on production. I don't know why this is happening and how can I properly remove clarity from my nextjs app.

      <script
          dangerouslySetInnerHTML={{
            __html: `
              if(${process.env.ENV_NAME_SHORT == 'prod'}){
          (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",'${
          process.env.MICROSOFT_CLARITY
          }');}`,
          }}
        />

The error is:

Next.js Application error: a client-side exception has occurred (see the browser console for more information)

and the console shows some error on insertBefore but that should not break the whole application

0

There are 0 answers