UNPKG

1.18 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright (c) 2016, salesforce.com, inc.
4 * All rights reserved.
5 * Licensed under the BSD 3-Clause license.
6 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7 * This module hooks into HttpApi request to get perfMetrics from the response header then returns the original request back.
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10const HttpApi = require("jsforce/lib/http-api");
11exports.request = HttpApi.prototype.request;
12exports.requestPerfMetrics = [];
13function getPerfMetricsFromResponse(response) {
14 let metrics = response.headers['perfmetrics'];
15 /* istanbul ignore else */
16 if (metrics) {
17 let perfMetrics = {
18 requestPath: response.req.path,
19 perfMetrics: JSON.parse(metrics)
20 };
21 exports.requestPerfMetrics.push(perfMetrics);
22 }
23}
24exports.getPerfMetricsFromResponse = getPerfMetricsFromResponse;
25HttpApi.prototype.request = function (req, ...args) {
26 this.on('response', getPerfMetricsFromResponse);
27 return exports.request.call(this, req, ...args);
28};
29
30//# sourceMappingURL=perfMetricsRequest.js.map