UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

48 lines 3.02 kB
// import { IHelpfullInput, IHelpfullOutput } from "../../../logic/Errors/friendly"; // import { getCurrentPageLink, getUrlVarsAsStrings } from "../../../logic/Links/UrlFunctions"; // import { SecureCDNalyticsWebAbsolute } from "../../../restAPIs/logging/interfaces/constants"; // import { IZMinErrorAnalytics, } from "../../atoms/easy-analytics/interfaces/analytics"; // import { getThisFPSDigestValueFromUrl } from "../SpHttp/digestValues/fromUrl/getThisFPSDigestValueFromUrl"; // import { doSpJsFetchOrPost } from "../SpHttp/doSpJsFetch"; // export async function saveErrorToLog(errorInfo: IHelpfullOutput, errorInput: IHelpfullInput) : Promise<void> { // //Return if you are not supposed to log an error // if ( errorInput.logErrors !== true ) { return ; } // // https://github.com/mikezimm/fps-library-v2/issues/15 // if ( !errorInfo ) { return ; } // const muteConsole = true; // const { traceString, e, alertMe, consoleLog, logErrors } = errorInput; // let trace: string[] = traceString ? traceString.split('|') : []; // let getParams: string = JSON.stringify(getUrlVarsAsStrings()); // let parsedMessage = errorInfo.returnMess.split('-- FULL ERROR MESSAGE:'); // let zzzRichText1 = parsedMessage.length > 0 ? parsedMessage[0] : 'No friendly error'; // let zzzRichText2 = parsedMessage.length > 0 ? parsedMessage[1] : errorInfo.returnMess; // let saveItem: IZMinErrorAnalytics = { // // https://github.com/fps-solutions/HubCon/issues/103 // __metadata: { type: `` }, // Title: trace[0], // Result: trace[3] ? trace[3] : null as any, // zzzText1: trace[4] ? trace[4] : null as any, // zzzText2: trace[5] ? trace[5] : null as any, // zzzText3: trace[6] ? trace[6] : null as any, // zzzText6: typeof alertMe === 'string' ? alertMe : `${alertMe}`, // zzzText7: typeof consoleLog === 'string' ? consoleLog : `${consoleLog}`, // zzzNumber1: trace[7] ? trace[7] : null as any, // zzzNumber2: trace[8] ? trace[8] : null as any, // getParams: getParams, // PageLink: getCurrentPageLink(), // zzzRichText1: zzzRichText1, // zzzRichText2: zzzRichText2, // }; // let absoluteWebUrl = trace[1] ? trace[1] : `${SecureCDNalyticsWebAbsolute}`; // let list = trace[2] ? trace[2] : 'GeneralErrorLog'; // // https://github.com/fps-solutions/HubCon/issues/103 // // Required for non-PnpJS POST operations // saveItem.__metadata = { type: `SP.Data.${list}ListItem` }; // // https://github.com/fps-solutions/HubCon/issues/103 // const formDigestValue: string = await getThisFPSDigestValueFromUrl( absoluteWebUrl ); // let postAPI: string = `${absoluteWebUrl}/_api/web/lists/getbytitle('${list}')/items`; // doSpJsFetchOrPost(postAPI, 'POST', formDigestValue, '', saveItem, ); // // const TEMPAlert = `saveErrorToLog Alert:\n\nerrorInfo\n${JSON.stringify(errorInfo)}\n\nerrorInput:\n\nerrorInput\n${errorInput}` // // alert(TEMPAlert); // } //# sourceMappingURL=Logging.js.map