Switched intercom to layout

This commit is contained in:
Vladyslav Matsiiako
2023-06-12 15:38:12 -07:00
parent 9dd0dac2f9
commit d99c54ca50
7 changed files with 71 additions and 44 deletions
+1 -40
View File
@@ -38,51 +38,12 @@ type NextAppProp = AppProps & {
const App = ({ Component, pageProps, ...appProps }: NextAppProp): JSX.Element => {
const router = useRouter();
useEffect(() => {
// Intercom code snippet
(function() {
var w=window;var ic=w.Intercom;
if(typeof ic==="function") {
ic('reattach_activator');
ic('update',w.intercomSettings);
} else {
var d=document;
var i=function() {
// eslint-disable-next-line prefer-rest-params
i.c(arguments);
};
i.q=[];
i.c=function(args) {
i.q.push(args);
};
w.Intercom=i;
var l=function() {
var s=d.createElement('script');
s.type='text/javascript';
s.async=true;
s.src='https://widget.intercom.io/widget/hsg644ru';
var x=d.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s,x);};
if(w.attachEvent) {
w.attachEvent('onload',l);
} else {
w.addEventListener('load',l,false);
}
}
}
)();
window.Intercom('boot', {
app_id: 'hsg644ru'
});
}, []);
useEffect(() => {
// Init for auto capturing
const telemetry = new Telemetry().getInstance();
const handleRouteChange = () => {
(window).Intercom('update');
// (window).Intercom('update');
if (typeof window !== 'undefined') {
telemetry.capture('$pageview');
}