This commit is contained in:
Piyali Jana 2018-08-27 12:51:55 -07:00
Родитель 27f4f30ff0
Коммит 12db75d889
6 изменённых файлов: 5206 добавлений и 211 удалений

2
dist/ai.0.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

2
dist/ai.0.js.map поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

5200
dist/ai.1.0.20.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

2
dist/ai.1.0.20.min.js поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

209
dist/ai.js поставляемый
Просмотреть файл

@ -4425,208 +4425,6 @@ var Microsoft;
})(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
/// <reference path="../Logging.ts" />
/// <reference path="../Util.ts" />
/// <reference path="./ajaxUtils.ts" />
/// <reference path="./ajaxRecord.ts" />
/// <reference path="../RequestResponseHeaders.ts" />
/// <reference path="../Telemetry/RemoteDependencyData.ts" />
/// <reference path="../AppInsights.ts" />
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
"use strict";
var FetchMonitor = /** @class */ (function () {
function FetchMonitor(appInsights) {
this.currentWindowHost = window.location.host && window.location.host.toLowerCase();
this.appInsights = appInsights;
this.initialized = false;
this.Init();
}
FetchMonitor.prototype.Init = function () {
if (this.supportsMonitoring()) {
this.instrumentFetch();
this.initialized = true;
}
};
FetchMonitor.prototype.isMonitoredInstance = function (input) {
return this.initialized && input[FetchMonitor.DisabledPropertyName] !== true;
};
FetchMonitor.prototype.supportsMonitoring = function () {
var result = true;
// polyfilled fetch on old browsers (IE) will try to use XMLHttpRequest instead
var fetchPolyfill = "new XMLHttpRequest";
if (ApplicationInsights.extensions.IsNullOrUndefined(window.Request) ||
ApplicationInsights.extensions.IsNullOrUndefined(window.Request.prototype) ||
ApplicationInsights.extensions.IsNullOrUndefined(window.fetch) ||
window.fetch.toString().indexOf(fetchPolyfill) !== -1) {
result = false;
}
return result;
};
FetchMonitor.prototype.instrumentFetch = function () {
var originalFetch = window.fetch;
var fetchMonitorInstance = this;
window.fetch = function fetch(input, init) {
var ajaxData;
if (fetchMonitorInstance.isMonitoredInstance(input)) {
try {
ajaxData = fetchMonitorInstance.createAjaxRecord(input, init);
init = fetchMonitorInstance.includeCorrelationHeaders(ajaxData, input, init);
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.CRITICAL, ApplicationInsights._InternalMessageId.FailedMonitorAjaxOpen, "Failed to monitor Window.fetch, monitoring data for this fetch call may be incorrect.", {
ajaxDiagnosticsMessage: FetchMonitor.getFailedFetchDiagnosticsMessage(input),
exception: Microsoft.ApplicationInsights.Util.dump(e)
});
}
}
return originalFetch(input, init)
.then(function (response) {
fetchMonitorInstance.onFetchComplete(response, ajaxData);
return response;
})
.catch(function (reason) {
fetchMonitorInstance.onFetchFailed(input, ajaxData, reason);
throw reason;
});
};
window.fetch[FetchMonitor.instrumentedByAppInsightsName] = true;
};
FetchMonitor.prototype.createAjaxRecord = function (input, init) {
// this format corresponds with activity logic on server-side and is required for the correct correlation
var id = "|" + this.appInsights.context.operation.id + "." + ApplicationInsights.Util.newId();
var ajaxData = new ApplicationInsights.ajaxRecord(id);
ajaxData.requestSentTime = ApplicationInsights.dateTime.Now();
if (input instanceof Request) {
input.ajaxData = ajaxData;
ajaxData.requestUrl = input ? input.url : "";
}
else {
ajaxData.requestUrl = input;
}
if (init && init.method) {
ajaxData.method = init.method;
}
else if (input && input instanceof Request) {
ajaxData.method = input.method;
}
else {
ajaxData.method = "GET";
}
return ajaxData;
};
FetchMonitor.prototype.includeCorrelationHeaders = function (ajaxData, input, init) {
if (ApplicationInsights.CorrelationIdHelper.canIncludeCorrelationHeader(this.appInsights.config, ajaxData.getAbsoluteUrl(), this.currentWindowHost)) {
if (!init) {
init = {};
}
// init headers override original request headers
// so, if they exist use only them, otherwise use request's because they should have been applied in the first place
// not using original request headers will result in them being lost
init.headers = new Headers(init.headers || (input instanceof Request ? (input.headers || {}) : {}));
init.headers.set(ApplicationInsights.RequestHeaders.requestIdHeader, ajaxData.id);
var appId = this.appInsights.context ? this.appInsights.context.appId() : null;
if (appId) {
init.headers.set(ApplicationInsights.RequestHeaders.requestContextHeader, ApplicationInsights.RequestHeaders.requestContextAppIdFormat + appId);
}
}
return init;
};
FetchMonitor.getFailedFetchDiagnosticsMessage = function (input) {
var result = "";
try {
if (!ApplicationInsights.extensions.IsNullOrUndefined(input)) {
if (typeof (input) === "string") {
result += "(url: '" + input + "')";
}
else {
result += "(url: '" + input.url + "')";
}
}
// tslint:disable-next-line:no-empty
}
catch (e) { }
return result;
};
FetchMonitor.prototype.onFetchComplete = function (response, ajaxData) {
if (!ajaxData) {
return;
}
try {
ajaxData.responseFinishedTime = ApplicationInsights.dateTime.Now();
ajaxData.CalculateMetrics();
if (ajaxData.ajaxTotalDuration < 0) {
ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.WARNING, ApplicationInsights._InternalMessageId.FailedMonitorAjaxDur, "Failed to calculate the duration of the fetch call, monitoring data for this fetch call won't be sent.", {
fetchDiagnosticsMessage: FetchMonitor.getFailedFetchDiagnosticsMessage(response),
requestSentTime: ajaxData.requestSentTime,
responseFinishedTime: ajaxData.responseFinishedTime
});
}
else {
var dependency = new ApplicationInsights.Telemetry.RemoteDependencyData(ajaxData.id, ajaxData.getAbsoluteUrl(), ajaxData.getPathName(), ajaxData.ajaxTotalDuration, response.status >= 200 && response.status < 400, response.status, ajaxData.method);
// enrich dependency target with correlation context from the server
var correlationContext = this.getCorrelationContext(response);
if (correlationContext) {
dependency.target = dependency.target + " | " + correlationContext;
}
this.appInsights.trackDependencyData(dependency);
}
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.WARNING, ApplicationInsights._InternalMessageId.FailedMonitorAjaxGetCorrelationHeader, "Failed to calculate the duration of the fetch call, monitoring data for this fetch call won't be sent.", {
fetchDiagnosticsMessage: FetchMonitor.getFailedFetchDiagnosticsMessage(response),
exception: Microsoft.ApplicationInsights.Util.dump(e)
});
}
};
FetchMonitor.prototype.onFetchFailed = function (input, ajaxData, reason) {
if (!ajaxData) {
return;
}
try {
ajaxData.responseFinishedTime = ApplicationInsights.dateTime.Now();
ajaxData.CalculateMetrics();
if (ajaxData.ajaxTotalDuration < 0) {
ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.WARNING, ApplicationInsights._InternalMessageId.FailedMonitorAjaxDur, "Failed to calculate the duration of the failed fetch call, monitoring data for this fetch call won't be sent.", {
fetchDiagnosticsMessage: FetchMonitor.getFailedFetchDiagnosticsMessage(input),
requestSentTime: ajaxData.requestSentTime,
responseFinishedTime: ajaxData.responseFinishedTime
});
}
else {
var dependency = new ApplicationInsights.Telemetry.RemoteDependencyData(ajaxData.id, ajaxData.getAbsoluteUrl(), ajaxData.getPathName(), ajaxData.ajaxTotalDuration, false, 0, ajaxData.method);
dependency.properties = { error: reason.message };
this.appInsights.trackDependencyData(dependency);
}
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.WARNING, ApplicationInsights._InternalMessageId.FailedMonitorAjaxGetCorrelationHeader, "Failed to calculate the duration of the failed fetch call, monitoring data for this fetch call won't be sent.", {
fetchDiagnosticsMessage: FetchMonitor.getFailedFetchDiagnosticsMessage(input),
exception: Microsoft.ApplicationInsights.Util.dump(e)
});
}
};
FetchMonitor.prototype.getCorrelationContext = function (response) {
try {
var responseHeader = response.headers.get(ApplicationInsights.RequestHeaders.requestContextHeader);
return ApplicationInsights.CorrelationIdHelper.getCorrelationContext(responseHeader);
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.WARNING, ApplicationInsights._InternalMessageId.FailedMonitorAjaxGetCorrelationHeader, "Failed to get Request-Context correlation header as it may be not included in the response or not accessible.", {
fetchDiagnosticsMessage: FetchMonitor.getFailedFetchDiagnosticsMessage(response),
exception: Microsoft.ApplicationInsights.Util.dump(e)
});
}
};
FetchMonitor.instrumentedByAppInsightsName = "InstrumentedByAppInsights";
FetchMonitor.DisabledPropertyName = "Microsoft_ApplicationInsights_BypassFetchInstrumentation";
return FetchMonitor;
}());
ApplicationInsights.FetchMonitor = FetchMonitor;
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
/// <reference path="./HashCodeScoreGenerator.ts" />
var Microsoft;
(function (Microsoft) {
@ -4661,7 +4459,6 @@ var Microsoft;
/// <reference path="./Telemetry/PageVisitTimeManager.ts"/>
/// <reference path="./Telemetry/RemoteDependencyData.ts"/>
/// <reference path="./ajax/ajax.ts"/>
/// <reference path="./ajax/fetch.ts"/>
/// <reference path="./SplitTest.ts"/>
/// <reference path="../JavaScriptSDK.Interfaces/IAppInsights.ts"/>
var Microsoft;
@ -4669,7 +4466,7 @@ var Microsoft;
var ApplicationInsights;
(function (ApplicationInsights) {
"use strict";
ApplicationInsights.Version = "1.0.19";
ApplicationInsights.Version = "1.0.20";
/**
* The main API that sends telemetry to Application Insights.
* Learn more: http://go.microsoft.com/fwlink/?LinkID=401493
@ -4755,9 +4552,6 @@ var Microsoft;
if (!this.config.disableAjaxTracking) {
this._ajaxMonitor = new Microsoft.ApplicationInsights.AjaxMonitor(this);
}
if (!this.config.disableFetchTracking) {
this._fetchMonitor = new Microsoft.ApplicationInsights.FetchMonitor(this);
}
}
AppInsights.prototype.sendPageViewInternal = function (name, url, duration, properties, measurements) {
var pageView = new ApplicationInsights.Telemetry.PageView(name, url, duration, properties, measurements, this.context.operation.id);
@ -5344,7 +5138,6 @@ var Microsoft;
config.samplingPercentage = 100;
}
config.disableAjaxTracking = ApplicationInsights.Util.stringToBoolOrDefault(config.disableAjaxTracking);
config.disableFetchTracking = ApplicationInsights.Util.stringToBoolOrDefault(config.disableFetchTracking, true);
config.maxAjaxCallsPerView = !isNaN(config.maxAjaxCallsPerView) ? config.maxAjaxCallsPerView : 500;
config.isBeaconApiDisabled = ApplicationInsights.Util.stringToBoolOrDefault(config.isBeaconApiDisabled, true);
config.disableCorrelationHeaders = ApplicationInsights.Util.stringToBoolOrDefault(config.disableCorrelationHeaders);

2
dist/ai.js.map поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны