@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
46 lines • 2.38 kB
JavaScript
import { AnalyticsWebAbsolute, SecureCDNalyticsWebAbsolute } from "../../../../../restAPIs/logging/interfaces/constants";
import { getCurrentFPSDigest } from "../../helpers/getCurrentFPSDigest";
import { getFormDigestValueNoContext } from "./getFormDigestValueNoContext";
import { startPerformOpV2, updatePerformanceEndV2 } from "../../../Performance/functions";
import { check4This } from "../../../../../logic/Links/CheckSearch";
import { makeAbsoluteUrl } from "../../../../../logic/Strings/getSiteCollectionUrlFromLink";
/**
* 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 setMultiFPSFormDigests(urls) {
let thisPerformance = startPerformOpV2({ label: `Multi-Digests`, includeMsStr: true });
const startTime = Date.now();
let fpsWindowProps = getCurrentFPSDigest();
// Just make sure all the Urls are absolute urls
const absoluteUrls = [];
urls.map(url => { absoluteUrls.push(makeAbsoluteUrl(url)); });
// NOTE: The vars in the array must be in same order they are called in the Promise.all
const allReturns = await Promise.all(absoluteUrls.map((absoluteUrl, idx) => { return getFormDigestValueNoContext(absoluteUrl); }));
absoluteUrls.map((url, idx) => {
const digestValue = allReturns[idx] ? allReturns[idx] : '';
const thisFPSDigest = { url: url, digestValue: digestValue, time: startTime, new: 0, queries: 0 };
if (url === AnalyticsWebAbsolute) {
fpsWindowProps.AnalyticsWeb = thisFPSDigest;
}
else if (url === SecureCDNalyticsWebAbsolute) {
fpsWindowProps.SecureCDNAlyticsWeb = thisFPSDigest;
}
else {
fpsWindowProps.sites.push(thisFPSDigest);
}
});
thisPerformance = updatePerformanceEndV2({ op: thisPerformance, updateMiliseconds: true, count: 1 });
if (check4This(`fpsShowDigestValue=true`) === true) {
console.log(`fps-core-v7 COMPLETE: setMultiFPSFormDigests ~ 57`, thisPerformance);
}
;
return fpsWindowProps;
}
//# sourceMappingURL=setMultiFPSFormDigests.js.map