Browse Source

add gtag

main
matthew 2 years ago
parent
commit
c48056dffb
  1. 10
      searching-front/pages/_document.tsx
  2. 5
      searching-front/services/main.ts
  3. 2
      searching-front/services/modules/parser/index.ts

10
searching-front/pages/_document.tsx

@ -12,6 +12,8 @@ class MyDocument extends Document {
<Head /> <Head />
<body> <body>
<Main /> <Main />
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DTHZT6R255"></script>
<script type="text/javascript" dangerouslySetInnerHTML={{__html: ` <script type="text/javascript" dangerouslySetInnerHTML={{__html: `
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date(); m[i].l=1*new Date();
@ -23,7 +25,13 @@ class MyDocument extends Document {
clickmap:true, clickmap:true,
trackLinks:true, trackLinks:true,
accurateTrackBounce:true accurateTrackBounce:true
});`}} > });
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-DTHZT6R255');
`}} >
</script> </script>

5
searching-front/services/main.ts

@ -18,5 +18,10 @@ const hour = 60 * minute;
run(); run();
setInterval(()=>{ setInterval(()=>{
console.log(new Date(), 'Health check');
},hour)
setInterval(()=>{
console.log(new Date(), 'Cron parse start')
run() run()
},3 * hour) },3 * hour)

2
searching-front/services/modules/parser/index.ts

@ -16,7 +16,6 @@ interface ParseUrlResult {
} }
const isInnerLink = (link: string) => { const isInnerLink = (link: string) => {
console.log(link)
return link.startsWith("/") return link.startsWith("/")
} }
@ -44,7 +43,6 @@ class Parser {
// собираем все ссылки и складываем их в сэт для дальнейшей обработки // собираем все ссылки и складываем их в сэт для дальнейшей обработки
dom.window.document.querySelectorAll("a").forEach(({ href }) => { dom.window.document.querySelectorAll("a").forEach(({ href }) => {
console.log(href)
if (isInnerLink(href)) { if (isInnerLink(href)) {
const url = new URL("ton://a.ton" + href) const url = new URL("ton://a.ton" + href)
if (!isInvalidLink(url.pathname)) { if (!isInvalidLink(url.pathname)) {

Loading…
Cancel
Save