Added intercom

This commit is contained in:
Vladyslav Matsiiako
2023-06-11 19:23:30 -07:00
parent 4b99a9ea93
commit 82c1f8607d
2 changed files with 50 additions and 5 deletions
+45
View File
@@ -1,4 +1,9 @@
/* eslint-disable vars-on-top */
/* eslint-disable no-var */
/* eslint-disable func-names */
/* eslint-disable react/jsx-props-no-spreading */
// @ts-nocheck
import { useEffect } from 'react';
import { AppProps } from 'next/app';
import { useRouter } from 'next/router';
@@ -33,11 +38,51 @@ 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');
if (typeof window !== 'undefined') {
telemetry.capture('$pageview');
}