feat: add Google Analytics
This commit is contained in:
1 parent
a2fd75326f
commit
50a4db0fbf
5 files changed
+25
-4
No files matched your search
Generated
+5
@@ -12545,6 +12545,11 @@
|
||||
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz",
|
||||
"integrity": "sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew=="
|
||||
},
|
||||
"react-ga": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/react-ga/-/react-ga-3.3.0.tgz",
|
||||
"integrity": "sha512-o8RScHj6Lb8cwy3GMrVH6NJvL+y0zpJvKtc0+wmH7Bt23rszJmnqEQxRbyrqUzk9DTJIHoP42bfO5rswC9SWBQ=="
|
||||
},
|
||||
"react-is": {
|
||||
"version": "16.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@
|
||||
"ky": "^0.28.5",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-ga": "^3.3.0",
|
||||
"react-router-dom": "^5.2.1",
|
||||
"react-scripts": "4.0.3",
|
||||
"web-vitals": "^1.1.2"
|
||||
@@ -40,4 +41,4 @@
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
Redirect,
|
||||
} from 'react-router-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
import FastAverageColor from 'fast-average-color'
|
||||
import ga from 'react-ga'
|
||||
|
||||
import Nav from '../Nav/Nav'
|
||||
import History from '../History/History'
|
||||
@@ -18,11 +18,21 @@ import { get, getMultiple } from '../../Cache'
|
||||
import { addEvent } from '../../socket'
|
||||
|
||||
import PlayingContext from '../../contexts/Playing'
|
||||
import GaContext from '../../contexts/Ga'
|
||||
|
||||
import './Main.css'
|
||||
|
||||
ga.initialize('UA-150749288-3')
|
||||
|
||||
document.setTitle = (prefix, suffix) => {
|
||||
document.title = `${prefix} | ${suffix ?? 'radio-rolnik'}`
|
||||
const title = `${prefix} | ${suffix ?? 'radio-rolnik'}`
|
||||
|
||||
// dont repeat same title
|
||||
if (document.title === title) return
|
||||
|
||||
document.title = title
|
||||
|
||||
ga.pageview(document.location.pathname)
|
||||
}
|
||||
|
||||
var fac = new FastAverageColor()
|
||||
|
||||
@@ -46,7 +46,7 @@ function Nav({ buttons }) {
|
||||
})()
|
||||
|
||||
// don't update for custom titles
|
||||
label && (document.title = `${label} | radio-rolnik`)
|
||||
label && document.setTitle(label)
|
||||
}, [location]) // eslint-disable-line
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { createContext } from "react";
|
||||
|
||||
const GaContext = createContext('ga')
|
||||
|
||||
export default GaContext
|
||||
Reference in new issue
Block a user