feat(sh-admin): introducing data analytics and newsletter configurations (#3845)

Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
Joel Jacob Stephen
2024-03-06 20:06:48 +05:30
committed by GitHub
parent 4798d7bbbd
commit 919579b1da
18 changed files with 575 additions and 156 deletions

View File

@@ -67,7 +67,7 @@ const signOut = async (reloadWindow = false) => {
});
};
const getInitialUserDetails = async () => {
const getUserDetails = async () => {
const res = await authQuery.getUserDetails();
return res.data;
};
@@ -80,7 +80,7 @@ const setUser = (user: HoppUser | null) => {
const setInitialUser = async () => {
isGettingInitialUser.value = true;
const res = await getInitialUserDetails();
const res = await getUserDetails();
if (res.errors?.[0]) {
const [error] = res.errors;
@@ -154,7 +154,7 @@ export const auth = {
getCurrentUserStream: () => currentUser$,
getAuthEventsStream: () => authEvents$,
getCurrentUser: () => currentUser$.value,
getUserDetails,
performAuthInit: () => {
const currentUser = JSON.parse(getLocalConfig('login_state') ?? 'null');
currentUser$.next(currentUser);
@@ -232,4 +232,24 @@ export const auth = {
const res = await authQuery.getProviders();
return res.data?.providers;
},
getFirstTimeInfraSetupStatus: async (): Promise<boolean> => {
try {
const res = await authQuery.getFirstTimeInfraSetupStatus();
return res.data?.value === 'true';
} catch (err) {
// Setup is not done
return true;
}
},
updateFirstTimeInfraSetupStatus: async () => {
try {
await authQuery.updateFirstTimeInfraSetupStatus();
return true;
} catch (err) {
console.error(err);
return false;
}
},
};

View File

@@ -17,4 +17,10 @@ const restApi = axios.create({
baseURL: import.meta.env.VITE_BACKEND_API_URL,
});
export { gqlApi, restApi };
const listmonkApi = axios.create({
...baseConfig,
withCredentials: false,
baseURL: 'https://listmonk.hoppscotch.com/api/public',
});
export { gqlApi, restApi, listmonkApi };

View File

@@ -0,0 +1,3 @@
mutation ToggleAnalyticsCollection($status: ServiceStatus!) {
toggleAnalyticsCollection(status: $status)
}

View File

@@ -29,5 +29,7 @@ export default {
token,
deviceIdentifier,
}),
getFirstTimeInfraSetupStatus: () => restApi.get('/site/setup'),
updateFirstTimeInfraSetupStatus: () => restApi.put('/site/setup'),
logout: () => restApi.get('/auth/logout'),
};