@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
19 lines • 971 B
JavaScript
export function Telemetry() {
return (instance) => {
instance.on.pre(async function (url, init, result) {
let clientTag = "PnPCoreJS:3.3.2:";
// make our best guess based on url to the method called
const { pathname } = new URL(url);
// remove anything before the _api as that is potentially PII and we don't care, just want to get the called path to the REST API
clientTag += pathname.substring(pathname.indexOf("_api/") + 5).split("/").map((value, index, arr) => index === arr.length - 1 ? value : value[0]).join(".");
if (clientTag.length > 32) {
clientTag = clientTag.substring(0, 32);
}
this.log(`Request Tag: ${clientTag}`, 0);
init.headers = { ...init.headers, ["X-ClientService-ClientTag"]: clientTag };
return [url, init, result];
});
return instance;
};
}
//# sourceMappingURL=telemetry.js.map