📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Add API calls related to project views
Blue Mouse46baa271a64c
diff --git a/app/api/index.ts b/app/api/index.tsindex 1c32480e4..da521649c 100644--- a/app/api/index.ts+++ b/app/api/index.ts@@ -18,6 +18,7 @@ import { IProject, IOverall, IProjectNames } from 'redux/models/IProject'import { IAlerts } from 'redux/models/IAlerts'import { ISharedProject } from 'redux/models/ISharedProject'import { ISubscribers } from 'redux/models/ISubscribers'+import { IFilter } from 'pages/Project/View/interfaces/traffic'const debug = Debug('swetrix:api')@@ -357,7 +358,7 @@ export const getProjectData = (pid: string,tb: string = 'hour',period: string = '1d',- filters: string[] = [],+ filters: any[] = [],from: string = '',to: string = '',timezone: string = '',@@ -413,7 +414,7 @@ export const getPropertyMetadata = (period: string = '1d',from: string = '',to: string = '',- filters: string[] = [],+ filters: any[] = [],timezone: string = '',password: string | undefined = '',) =>@@ -438,7 +439,7 @@ export const getProjectCompareData = (pid: string,tb: string = 'hour',period: string = '3d',- filters: string[] = [],+ filters: any[] = [],from: string = '',to: string = '',timezone: string = '',@@ -466,7 +467,7 @@ export const getPerfData = (pid: string,tb: string = 'hour',period: string = '3d',- filters: string[] = [],+ filters: any[] = [],from: string = '',to: string = '',timezone: string = '',@@ -493,7 +494,7 @@ export const getPerfData = (export const getSessions = (pid: string,period: string = '3d',- filters: string[] = [],+ filters: any[] = [],from: string = '',to: string = '',take: number = 30,@@ -521,7 +522,7 @@ export const getSessions = (export const getErrors = (pid: string,period: string = '3d',- filters: string[] = [],+ filters: any[] = [],options: any = {},from: string = '',to: string = '',@@ -615,11 +616,51 @@ export const getFunnels = (pid: string, password: string | undefined = '') =>throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message})+export const getProjectViews = (pid: string, password: string | undefined = '') =>+ api+ .get(`project/${pid}/views`, {+ 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 createProjectView = (pid: string, name: string, type: 'traffic' | 'performance', filters: IFilter[]) =>+ api+ .post(`project/${pid}/views`, { name, type, filters })+ .then((response) => response.data)+ .catch((error) => {+ debug('%s', error)+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message+ })++export const updateProjectView = (pid: string, viewId: string, name: string, filters: IFilter[]) =>+ api+ .patch(`project/${pid}/views/${viewId}`, { name, filters })+ .then((response) => response.data)+ .catch((error) => {+ debug('%s', error)+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message+ })++export const deleteProjectView = (pid: string, viewId: string) =>+ api+ .delete(`project/${pid}/views/${viewId}`)+ .then((response) => response.data)+ .catch((error) => {+ debug('%s', error)+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message+ })+export const getCaptchaData = (pid: string,tb: string = 'hour',period: string = '3d',- filters: string[] = [],+ filters: any[] = [],from: string = '',to: string = '',) =>@@ -1034,7 +1075,7 @@ export const getProjectDataCustomEvents = (pid: string,tb: string = 'hour',period: string = '3d',- filters: string[] = [],+ filters: any[] = [],from: string = '',to: string = '',timezone: string = '',@@ -1172,7 +1213,7 @@ export const getUserFlow = (pid: string,tb: string = 'hour',period: string = '3d',- filters: string[] = [],+ filters: any[] = [],from: string = '',to: string = '',timezone: string = '',