Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Add getMonitorStats function to get uptime average stats

Blue Mousee77e9d444d54
diff --git a/app/api/index.ts b/app/api/index.ts
index d46d73cbf..84fbf78e7 100644
--- a/app/api/index.ts
+++ b/app/api/index.ts
@@ -1030,6 +1030,31 @@ export const getMonitorOverallStats = (
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
+export const getMonitorStats = (
+ pid: string,
+ monitorId: string,
+ period: string = '1d',
+ timeBucket: string = 'hour',
+ from: string = '',
+ to: string = '',
+ timezone: string = '',
+ password: string | undefined = '',
+) =>
+ api
+ .get(
+ `log/monitor-data?pid=${pid}&monitorId=${monitorId}&timeBucket=${timeBucket}&period=${period}&from=${from}&to=${to}&timezone=${timezone}`,
+ {
+ headers: {
+ 'x-password': password,
+ },
+ },
+ )
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
+ })
+
export const createMonitor = (pid: string, data: ICreateMonitor) =>
api
.post(`project/${pid}/monitor`, data)