Skip to content

Commit

Permalink
feat: fix redundant logging(#263854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai Nicolae committed Feb 6, 2024
1 parent 2b50327 commit e123cf6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tabs/src/data/apiProvider.js
Expand Up @@ -34,15 +34,15 @@ export async function apiGet(path, credentialType = 'app') {
}
}

export async function apiPost(path, data, credentialType = 'app') {
export async function apiPost(path, data, credentialType = 'app', skipLog) {
try {
return await callApiFunction(constants.API_FUNCTION, 'post', {
credentialType: credentialType,
data: data,
path: path,
});
} catch (err) {
logError(err, path, data);
!skipLog && logError(err, path, data);
throw err;
}
}
Expand Down Expand Up @@ -108,8 +108,7 @@ export async function getConfiguration() {
}

export async function logError(err, apiPath, data) {
const spConfig = await getConfiguration(),
userMail = await getUserMail();
const userMail = await getUserMail();

const title = err.response?.data?.error?.body || err.message;

Expand All @@ -125,9 +124,16 @@ export async function logError(err, apiPath, data) {
},
};

let graphURL =
'/sites/' + spConfig.SharepointSiteId + '/lists/' + spConfig.LoggingListId + '/items';
await apiPost(graphURL, fields);
if (_configuration) {
await apiPost(
`/sites/${_configuration.SharepointSiteId}/lists/${_configuration.LoggingListId}/items`,
fields,
'app',
true,
);
} else {
console.log('Configuration not loaded cannot proceed');
}
}

export async function logInfo(message, apiPath, data, action) {
Expand Down

0 comments on commit e123cf6

Please sign in to comment.