packages/target-tools/src/fetchWithTelemetry.js
/**
 * Fetch implementation that uses builtin https module and listens to socket events to capture telemetry data for requests.
 * The request/response interface align with the browser fetch implementation to preserve cross-compatibility.
 * @param {String} url The request url
 * @param {Object} requestOpts Options that can be used to configure the request (optional)
 * @param {Function} requestImpl Low-level request function that can be used to override the default http/s module (optional)
 * @return {Promise<import("../types/FetchResponse").FetchResponse>}
 */
Fetch implementation that uses builtin https module and listens to socket events to capture telemetry data for requests.
The request/response interface align with the browser fetch implementation to preserve cross-compatibility.
@param {String} url The request url
@param {Object} requestOpts Options that can be used to configure the request (optional)
@param {Function} requestImpl Low-level request function that can be used to override the default http/s module (optional)
@return {Promise}
Fetch implementation that uses builtin https module and listens to socket events to capture telemetry data for requests . The request / response interface align with the browser fetch implementation to preserve cross - compatibility . @param { String } url The request url @param { Object } requestOpts Options that can be used to configure the request ( optional ) @param { Function } requestImpl Low - level request function that can be used to override the default http / s module ( optional ) @return { Promise }
function fetchWithTelemetry(url, requestOpts, requestImpl) {
  const urlObject = new URL(url);
  const host = urlObject.hostname;
  const path = urlObject.pathname;
  const queryParams = urlObject.search;
  requestOpts.protocol = urlObject.protocol;
  return handleRequest(host, path, queryParams, requestOpts, requestImpl);
}
function fetchWithTelemetry ( url , requestOpts , requestImpl ) { const urlObject = new URL ( url ) ; const host = urlObject . hostname ; const path = urlObject . pathname ; const queryParams = urlObject . search ; requestOpts . protocol = urlObject . protocol ; return handleRequest ( host , path , queryParams , requestOpts , requestImpl ) ; }
Fetch implementation that uses builtin https module and listens to socket events to capture telemetry data for requests.
Fetch implementation that uses builtin https module and listens to socket events to capture telemetry data for requests .