1 | export function Telemetry() {
|
2 | return (instance) => {
|
3 | instance.on.pre(async function (url, init, result) {
|
4 | let clientTag = "PnPCoreJS:3.3.2:";
|
5 |
|
6 | const { pathname } = new URL(url);
|
7 |
|
8 | clientTag += pathname.substring(pathname.indexOf("_api/") + 5).split("/").map((value, index, arr) => index === arr.length - 1 ? value : value[0]).join(".");
|
9 | if (clientTag.length > 32) {
|
10 | clientTag = clientTag.substring(0, 32);
|
11 | }
|
12 | this.log(`Request Tag: ${clientTag}`, 0);
|
13 | init.headers = { ...init.headers, ["X-ClientService-ClientTag"]: clientTag };
|
14 | return [url, init, result];
|
15 | });
|
16 | return instance;
|
17 | };
|
18 | }
|
19 |
|
\ | No newline at end of file |