UNPKG

@microsoft/msgraph-sdk-core

Version:
30 lines 1.43 kB
import { TelemetryHandler, appendRequestHeader } from "@microsoft/kiota-http-fetchlibrary"; import { coreVersion } from "../utils/Version.js"; /** * Adds telemetry headers to requests made to the Graph API */ export class GraphTelemetryHandler extends TelemetryHandler { /** * Creates a new instance of the GraphTelemetryHandler class */ constructor(graphTelemetryOption) { var _a; const productPrefix = (_a = graphTelemetryOption.graphProductPrefix) !== null && _a !== void 0 ? _a : "graph-typescript"; const coreProduct = `${productPrefix}-core/${coreVersion}`; let product = ""; if (graphTelemetryOption.graphServiceLibraryClientVersion) { const serviceLibVersion = graphTelemetryOption.graphServiceTargetVersion ? `-${graphTelemetryOption.graphServiceTargetVersion}` : ""; product = `${productPrefix}${serviceLibVersion}/${graphTelemetryOption.graphServiceLibraryClientVersion}`; } const versionHeaderValue = product ? `${product}, ${coreProduct}` : coreProduct; super({ telemetryConfigurator: (_url, requestInit, _requestOptions, _telemetryInformation) => { appendRequestHeader(requestInit, "SdkVersion", versionHeaderValue); }, getKey: () => "graphTelemetryOption", }); } } //# sourceMappingURL=GraphTelemetryHandler.js.map