send LocationPathChanged analytics event to core

This commit is contained in:
nklhrstv 2021-01-20 18:40:32 +02:00
parent 244ec32f16
commit e59d656e0e

View file

@ -28,6 +28,22 @@ const App = () => {
}), []);
const [coreInitialized, setCoreInitialized] = React.useState(false);
const [shellInitialized, setShellInitialized] = React.useState(false);
React.useEffect(() => {
let prevPath = window.location.hash.slice(1);
const onLocationHashChange = () => {
if (services.core.active) {
services.core.transport.analytics({
event: 'LocationPathChanged',
args: { prevPath }
});
}
prevPath = window.location.hash.slice(1);
};
window.addEventListener('hashchange', onLocationHashChange);
return () => {
window.removeEventListener('hashchange', onLocationHashChange);
};
}, []);
React.useEffect(() => {
const onCoreStateChanged = () => {
setCoreInitialized(services.core.active);