Skip to content

Commit 0c1a455

Browse files
authored
Merge pull request #466 from EarthyScience/jp/pinger
Ping on load
2 parents 220a47a + a4b3eb9 commit 0c1a455

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/components/LandingHome.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@ import { ZarrDataset, GetStore } from '@/components/zarr/ZarrLoaderLRU';
66
import { useEffect, useMemo } from 'react';
77
import { PlotArea, Plot, LandingShapes } from '@/components/plots';
88
import { MainPanel } from '@/components/ui';
9-
import { Loading, Navbar, Error } from '@/components/ui';
9+
import { Loading, Navbar, Error as ErrorComponent } from '@/components/ui';
1010
import { useGlobalStore, useZarrStore } from '@/utils/GlobalStates';
1111
import { useShallow } from 'zustand/shallow';
1212

13+
async function sendPing() {
14+
const url = "https://www.bgc-jena.mpg.de/~jpoehls/browzarr/visitor_logger.php";
15+
16+
try {
17+
const response = await fetch(url, {
18+
method: "GET",
19+
});
20+
21+
if (!response.ok) {
22+
throw new Error(`HTTP error! Status: ${response.status}`);
23+
}
24+
} catch (error) {
25+
console.error("Request failed:", error);
26+
}
27+
}
28+
1329
export function LandingHome() {
1430
const {
1531
initStore, timeSeries, variable, plotOn,
@@ -64,12 +80,15 @@ export function LandingHome() {
6480
return () => { isMounted = false; };
6581
}, [currentStore, setZMeta, setVariables, setTitleDescription])
6682

83+
useEffect(()=>{
84+
sendPing()
85+
},[])
6786

6887
return (
6988
<>
7089
<MainPanel/>
7190
{variable == 'Default' && <LandingShapes />}
72-
<Error />
91+
<ErrorComponent />
7392
{!plotOn && <Navbar />}
7493
<Loading />
7594

0 commit comments

Comments
 (0)