@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
47 lines • 2.33 kB
JavaScript
import { getRequestDigestFromContext } from "./getRequestDigestFromContext";
import { getCurrentFPSDigest } from "../../helpers/getCurrentFPSDigest";
import { check4ThisFPSDigest, } from "../../helpers/check4ThisFPSDigestValue";
import { startPerformOpV2, updatePerformanceEndV2 } from "../../../Performance/functions";
import { check4This, Check4 } from "../../../../../logic/Links/CheckSearch";
import { makeAbsoluteUrl } from "../../../../../logic/Strings/getSiteCollectionUrlFromLink";
/**
* REQUIRES Context!!!!
*
* getThisFPSDigestValue will first check for a valid digestValue, if not found, will try to request from getRequestDigestFromClass
*
* If you need to use digestValues, such as in SE or certain calls,
* It's best to call this during the onInit because you have the context.
*
* Then later on, you can pass in null for the context because the digestValue will already be updated
*
* @param classContext
* @param absoluteUrl
* @returns
*/
export async function getThisFPSDigestValueFromContext(classContext, absoluteUrl) {
const startTime = Date.now();
absoluteUrl = makeAbsoluteUrl(absoluteUrl);
let thisPerformance = startPerformOpV2({ label: `DIGEST ${absoluteUrl}`, includeMsStr: true });
let fpsWindowProps = getCurrentFPSDigest();
let returnDigest = check4ThisFPSDigest(absoluteUrl);
returnDigest.queries++;
if (!returnDigest.digestValue) {
// Go get the digest value
returnDigest.digestValue = await getRequestDigestFromContext(classContext, absoluteUrl);
returnDigest.new++;
// if ( absoluteUrl === AnalyticsWeb ) {
// fpsWindowProps.AnalyticsWeb = thisFPSDigest;
// } else if ( absoluteUrl === SecureCDNalyticsWeb ) {
// fpsWindowProps.SecureCDNAlyticsWeb = thisFPSDigest;
// } else {
// fpsWindowProps.sites.push( thisFPSDigest );
// }
}
thisPerformance = updatePerformanceEndV2({ op: thisPerformance, updateMiliseconds: true, count: 1 });
if (check4This(Check4.fpsShowFetchResults_Eq_true) === true) {
console.log(`fps-core-v7 COMPLETE: getThisFPSDigestValueFromContext ~ 60`, thisPerformance);
}
;
return returnDigest.digestValue;
}
//# sourceMappingURL=getThisFPSDigestValueFromContext.js.map