mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
send LocationPathChanged analytics event to core
This commit is contained in:
parent
244ec32f16
commit
e59d656e0e
1 changed files with 16 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue