@microsoft/applicationinsights-dependencies-js 3.0.0-beta.2302-01 → 3.0.0-beta.2302-03
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/applicationinsights-dependencies-js.integrity.json +9 -9
- package/browser/applicationinsights-dependencies-js.js +88 -37
- package/browser/applicationinsights-dependencies-js.js.map +1 -1
- package/browser/applicationinsights-dependencies-js.min.js +2 -2
- package/browser/applicationinsights-dependencies-js.min.js.map +1 -1
- package/dist/applicationinsights-dependencies-js.api.json +54 -0
- package/dist/applicationinsights-dependencies-js.api.md +2 -0
- package/dist/applicationinsights-dependencies-js.d.ts +11 -1
- package/dist/applicationinsights-dependencies-js.js +88 -37
- package/dist/applicationinsights-dependencies-js.js.map +1 -1
- package/dist/applicationinsights-dependencies-js.min.js +2 -2
- package/dist/applicationinsights-dependencies-js.min.js.map +1 -1
- package/dist/applicationinsights-dependencies-js.rollup.d.ts +11 -1
- package/dist-esm/DependencyInitializer.js +1 -1
- package/dist-esm/DependencyListener.js +1 -1
- package/dist-esm/InternalConstants.js +1 -1
- package/dist-esm/__DynamicConstants.js +8 -7
- package/dist-esm/__DynamicConstants.js.map +1 -1
- package/dist-esm/ajax.js +16 -14
- package/dist-esm/ajax.js.map +1 -1
- package/dist-esm/ajaxRecord.js +18 -12
- package/dist-esm/ajaxRecord.js.map +1 -1
- package/dist-esm/ajaxUtils.js +1 -1
- package/dist-esm/applicationinsights-dependencies-js.js +1 -1
- package/package.json +7 -6
- package/src/DependencyInitializer.ts +5 -0
- package/src/DependencyListener.ts +7 -0
- package/src/__DynamicConstants.ts +67 -66
- package/src/ajax.ts +40 -38
- package/src/ajaxRecord.ts +30 -24
- package/src/ajaxUtils.ts +6 -6
- package/types/DependencyInitializer.d.ts +4 -0
- package/types/DependencyListener.d.ts +6 -0
- package/types/__DynamicConstants.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-dependencies-js",
|
|
3
|
-
"version": "3.0.0-beta.2302-
|
|
3
|
+
"version": "3.0.0-beta.2302-03",
|
|
4
4
|
"description": "Microsoft Application Insights XHR dependencies plugin",
|
|
5
5
|
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
6
|
"author": "Microsoft Application Insights Team",
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
"ai-restore": "grunt deps-restore"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
+
"@nevware21/ts-async": "^0.1.0",
|
|
29
30
|
"@microsoft/ai-test-framework": "0.0.1",
|
|
30
31
|
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
|
|
31
32
|
"@microsoft/applicationinsights-rollup-es5": "1.0.0",
|
|
32
33
|
"@microsoft/api-extractor": "^7.18.1",
|
|
33
|
-
"typescript": "^4.3
|
|
34
|
+
"typescript": "^4.9.3",
|
|
34
35
|
"tslib": "^2.0.0",
|
|
35
36
|
"grunt": "^1.5.3",
|
|
36
37
|
"grunt-cli": "^1.4.3",
|
|
37
|
-
"grunt-contrib-qunit": "^
|
|
38
|
+
"grunt-contrib-qunit": "^6.2.1",
|
|
38
39
|
"@nevware21/grunt-ts-plugin": "^0.4.3",
|
|
39
40
|
"@nevware21/grunt-eslint-ts": "^0.2.2",
|
|
40
41
|
"globby": "^11.0.0",
|
|
@@ -53,9 +54,9 @@
|
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"@microsoft/dynamicproto-js": "^1.1.7",
|
|
55
56
|
"@microsoft/applicationinsights-shims": "2.0.2",
|
|
56
|
-
"@microsoft/applicationinsights-core-js": "3.0.0-beta.2302-
|
|
57
|
-
"@microsoft/applicationinsights-common": "3.0.0-beta.2302-
|
|
58
|
-
"@nevware21/ts-utils": "^0.
|
|
57
|
+
"@microsoft/applicationinsights-core-js": "3.0.0-beta.2302-03",
|
|
58
|
+
"@microsoft/applicationinsights-common": "3.0.0-beta.2302-03",
|
|
59
|
+
"@nevware21/ts-utils": "^0.7.0"
|
|
59
60
|
},
|
|
60
61
|
"license": "MIT",
|
|
61
62
|
"publishConfig": {
|
|
@@ -23,6 +23,11 @@ export interface IDependencyInitializerDetails {
|
|
|
23
23
|
* The context that the application can assigned via the dependency listener(s)
|
|
24
24
|
*/
|
|
25
25
|
context?: { [key: string]: any };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* [Optional] A flag that indicates whether the client request was manually aborted by the `abort()`
|
|
29
|
+
*/
|
|
30
|
+
aborted?: boolean;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
/**
|
|
@@ -51,6 +51,13 @@ export interface IDependencyListenerDetails {
|
|
|
51
51
|
* [Optional] Context that the application can assign that will also be passed to any dependency initializer
|
|
52
52
|
*/
|
|
53
53
|
context?: { [key: string]: any };
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* [Optional] A flag that indicates whether the client request was manually aborted by the `abort()`,
|
|
57
|
+
* as listeners are called just before the request is sent it is unlikely that an application would have
|
|
58
|
+
* called `abort` before `send` this is also available in the dependency initializer.
|
|
59
|
+
*/
|
|
60
|
+
aborted?: boolean;
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
@@ -1,66 +1,67 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
// @skip-file-minify
|
|
4
|
-
|
|
5
|
-
// ##############################################################
|
|
6
|
-
// AUTO GENERATED FILE: This file is Auto Generated during build.
|
|
7
|
-
// ##############################################################
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
// Note: DON'T Export these const from the package as we are still targeting
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
export const _DYN_REQUEST_URL = "requestUrl"; // Count: 12
|
|
14
|
-
export const _DYN_INST = "inst"; // Count: 5
|
|
15
|
-
export const _DYN_LENGTH = "length"; // Count: 10
|
|
16
|
-
export const _DYN_TRACE_ID = "traceID"; // Count: 9
|
|
17
|
-
export const _DYN_SPAN_ID = "spanID"; // Count: 8
|
|
18
|
-
export const _DYN_TRACE_FLAGS = "traceFlags"; // Count: 13
|
|
19
|
-
export const _DYN_CONTEXT = "context"; // Count: 7
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
28
|
-
export const
|
|
29
|
-
export const
|
|
30
|
-
export const
|
|
31
|
-
export const
|
|
32
|
-
export const
|
|
33
|
-
export const
|
|
34
|
-
export const
|
|
35
|
-
export const
|
|
36
|
-
export const
|
|
37
|
-
export const
|
|
38
|
-
export const
|
|
39
|
-
export const
|
|
40
|
-
export const
|
|
41
|
-
export const
|
|
42
|
-
export const
|
|
43
|
-
export const
|
|
44
|
-
export const
|
|
45
|
-
export const
|
|
46
|
-
export const
|
|
47
|
-
export const
|
|
48
|
-
export const
|
|
49
|
-
export const
|
|
50
|
-
export const
|
|
51
|
-
export const
|
|
52
|
-
export const
|
|
53
|
-
export const
|
|
54
|
-
export const
|
|
55
|
-
export const
|
|
56
|
-
export const
|
|
57
|
-
export const
|
|
58
|
-
export const
|
|
59
|
-
export const
|
|
60
|
-
export const
|
|
61
|
-
export const
|
|
62
|
-
export const
|
|
63
|
-
export const
|
|
64
|
-
export const
|
|
65
|
-
export const
|
|
66
|
-
export const
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
// @skip-file-minify
|
|
4
|
+
|
|
5
|
+
// ##############################################################
|
|
6
|
+
// AUTO GENERATED FILE: This file is Auto Generated during build.
|
|
7
|
+
// ##############################################################
|
|
8
|
+
|
|
9
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
10
|
+
// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!
|
|
11
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
12
|
+
|
|
13
|
+
export const _DYN_REQUEST_URL = "requestUrl"; // Count: 12
|
|
14
|
+
export const _DYN_INST = "inst"; // Count: 5
|
|
15
|
+
export const _DYN_LENGTH = "length"; // Count: 10
|
|
16
|
+
export const _DYN_TRACE_ID = "traceID"; // Count: 9
|
|
17
|
+
export const _DYN_SPAN_ID = "spanID"; // Count: 8
|
|
18
|
+
export const _DYN_TRACE_FLAGS = "traceFlags"; // Count: 13
|
|
19
|
+
export const _DYN_CONTEXT = "context"; // Count: 7
|
|
20
|
+
export const _DYN_ABORTED = "aborted"; // Count: 7
|
|
21
|
+
export const _DYN_TRACE_ID0 = "traceId"; // Count: 5
|
|
22
|
+
export const _DYN_SPAN_ID1 = "spanId"; // Count: 5
|
|
23
|
+
export const _DYN__ADD_HOOK = "_addHook"; // Count: 4
|
|
24
|
+
export const _DYN_CORE = "core"; // Count: 8
|
|
25
|
+
export const _DYN_INCLUDE_CORRELATION_2 = "includeCorrelationHeaders"; // Count: 4
|
|
26
|
+
export const _DYN_GET_ABSOLUTE_URL = "getAbsoluteUrl"; // Count: 3
|
|
27
|
+
export const _DYN_HEADERS = "headers"; // Count: 6
|
|
28
|
+
export const _DYN_REQUEST_HEADERS = "requestHeaders"; // Count: 13
|
|
29
|
+
export const _DYN_SET_REQUEST_HEADER = "setRequestHeader"; // Count: 3
|
|
30
|
+
export const _DYN_TRACK_DEPENDENCY_DAT3 = "trackDependencyDataInternal"; // Count: 2
|
|
31
|
+
export const _DYN_START_TIME = "startTime"; // Count: 6
|
|
32
|
+
export const _DYN_TO_LOWER_CASE = "toLowerCase"; // Count: 6
|
|
33
|
+
export const _DYN_ENABLE_REQUEST_HEADE4 = "enableRequestHeaderTracking"; // Count: 3
|
|
34
|
+
export const _DYN_ENABLE_AJAX_ERROR_ST5 = "enableAjaxErrorStatusText"; // Count: 2
|
|
35
|
+
export const _DYN_ENABLE_AJAX_PERF_TRA6 = "enableAjaxPerfTracking"; // Count: 2
|
|
36
|
+
export const _DYN_MAX_AJAX_CALLS_PER_V7 = "maxAjaxCallsPerView"; // Count: 2
|
|
37
|
+
export const _DYN_EXCLUDE_REQUEST_FROM8 = "excludeRequestFromAutoTrackingPatterns"; // Count: 2
|
|
38
|
+
export const _DYN_ADD_REQUEST_CONTEXT = "addRequestContext"; // Count: 2
|
|
39
|
+
export const _DYN_DISABLE_AJAX_TRACKIN9 = "disableAjaxTracking"; // Count: 3
|
|
40
|
+
export const _DYN_AJAX_PERF_LOOKUP_DEL10 = "ajaxPerfLookupDelay"; // Count: 2
|
|
41
|
+
export const _DYN_DISABLE_FETCH_TRACKI11 = "disableFetchTracking"; // Count: 2
|
|
42
|
+
export const _DYN_ENABLE_RESPONSE_HEAD12 = "enableResponseHeaderTracking"; // Count: 2
|
|
43
|
+
export const _DYN_STATUS = "status"; // Count: 11
|
|
44
|
+
export const _DYN_STATUS_TEXT = "statusText"; // Count: 9
|
|
45
|
+
export const _DYN_HEADER_MAP = "headerMap"; // Count: 8
|
|
46
|
+
export const _DYN_OPEN_DONE = "openDone"; // Count: 3
|
|
47
|
+
export const _DYN_SEND_DONE = "sendDone"; // Count: 3
|
|
48
|
+
export const _DYN_REQUEST_SENT_TIME = "requestSentTime"; // Count: 9
|
|
49
|
+
export const _DYN_ABORT_DONE = "abortDone"; // Count: 3
|
|
50
|
+
export const _DYN_GET_TRACE_ID = "getTraceId"; // Count: 3
|
|
51
|
+
export const _DYN_GET_TRACE_FLAGS = "getTraceFlags"; // Count: 3
|
|
52
|
+
export const _DYN_METHOD = "method"; // Count: 10
|
|
53
|
+
export const _DYN_ERROR_STATUS_TEXT = "errorStatusText"; // Count: 3
|
|
54
|
+
export const _DYN_STATE_CHANGE_ATTACHE13 = "stateChangeAttached"; // Count: 2
|
|
55
|
+
export const _DYN_RESPONSE_TEXT = "responseText"; // Count: 6
|
|
56
|
+
export const _DYN_RESPONSE_FINISHED_TI14 = "responseFinishedTime"; // Count: 7
|
|
57
|
+
export const _DYN__CREATE_TRACK_ITEM = "CreateTrackItem"; // Count: 3
|
|
58
|
+
export const _DYN_RESPONSE = "response"; // Count: 4
|
|
59
|
+
export const _DYN_GET_ALL_RESPONSE_HEA15 = "getAllResponseHeaders"; // Count: 2
|
|
60
|
+
export const _DYN_GET_PART_APROPS = "getPartAProps"; // Count: 3
|
|
61
|
+
export const _DYN_PERF_MARK = "perfMark"; // Count: 4
|
|
62
|
+
export const _DYN_NAME = "name"; // Count: 6
|
|
63
|
+
export const _DYN_PERF_TIMING = "perfTiming"; // Count: 3
|
|
64
|
+
export const _DYN_AJAX_DIAGNOSTICS_MES16 = "ajaxDiagnosticsMessage"; // Count: 3
|
|
65
|
+
export const _DYN_CORRELATION_CONTEXT = "correlationContext"; // Count: 3
|
|
66
|
+
export const _DYN_AJAX_TOTAL_DURATION = "ajaxTotalDuration"; // Count: 3
|
|
67
|
+
export const _DYN_EVENT_TRACE_CTX = "eventTraceCtx"; // Count: 3
|
package/src/ajax.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
5
|
-
import {
|
|
6
|
-
DisabledPropertyName, IConfig, ICorrelationConfig, IDependencyTelemetry, IRequestContext, ITelemetryContext, PropertiesPluginIdentifier,
|
|
7
|
-
RemoteDependencyData, RequestHeaders, correlationIdCanIncludeCorrelationHeader, correlationIdGetCorrelationContext,
|
|
8
|
-
createDistributedTraceContextFromTrace, createTelemetryItem, createTraceParent, dateTimeUtilsNow, eDistributedTracingModes,
|
|
9
|
-
eRequestHeaders, formatTraceParent, isInternalApplicationInsightsEndpoint
|
|
10
|
-
} from "@microsoft/applicationinsights-common";
|
|
11
|
-
import {
|
|
12
|
-
BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, ICustomProperties, IDistributedTraceContext,
|
|
13
|
-
IInstrumentCallDetails, IInstrumentHooksCallbacks, IPlugin, IProcessTelemetryContext, ITelemetryItem, ITelemetryPluginChain,
|
|
14
|
-
InstrumentFunc, InstrumentProto, _eInternalMessageId, _throwInternal, arrForEach, createProcessTelemetryContext, createUniqueNamespace,
|
|
15
|
-
dumpObj, eLoggingSeverity, eventOn, generateW3CId, getExceptionName, getGlobal, getIEVersion, getLocation, getPerformance, isFunction,
|
|
16
|
-
isNullOrUndefined, isString, isXhrSupported, mergeEvtNamespace, onConfigChange, strPrototype, strTrim
|
|
17
|
-
} from "@microsoft/applicationinsights-core-js";
|
|
18
|
-
import { objFreeze, scheduleTimeout, strIndexOf } from "@nevware21/ts-utils";
|
|
19
|
-
import { DependencyInitializerFunction, IDependencyInitializerDetails, IDependencyInitializerHandler } from "./DependencyInitializer";
|
|
20
|
-
import {
|
|
21
|
-
DependencyListenerFunction, IDependencyHandler, IDependencyListenerContainer, IDependencyListenerDetails, IDependencyListenerHandler
|
|
22
|
-
} from "./DependencyListener";
|
|
23
|
-
import { IAjaxRecordResponse, ajaxRecord } from "./ajaxRecord";
|
|
24
|
-
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
5
|
+
import {
|
|
6
|
+
DisabledPropertyName, IConfig, ICorrelationConfig, IDependencyTelemetry, IRequestContext, ITelemetryContext, PropertiesPluginIdentifier,
|
|
7
|
+
RemoteDependencyData, RequestHeaders, correlationIdCanIncludeCorrelationHeader, correlationIdGetCorrelationContext,
|
|
8
|
+
createDistributedTraceContextFromTrace, createTelemetryItem, createTraceParent, dateTimeUtilsNow, eDistributedTracingModes,
|
|
9
|
+
eRequestHeaders, formatTraceParent, isInternalApplicationInsightsEndpoint
|
|
10
|
+
} from "@microsoft/applicationinsights-common";
|
|
11
|
+
import {
|
|
12
|
+
BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, ICustomProperties, IDistributedTraceContext,
|
|
13
|
+
IInstrumentCallDetails, IInstrumentHooksCallbacks, IPlugin, IProcessTelemetryContext, ITelemetryItem, ITelemetryPluginChain,
|
|
14
|
+
InstrumentFunc, InstrumentProto, _eInternalMessageId, _throwInternal, arrForEach, createProcessTelemetryContext, createUniqueNamespace,
|
|
15
|
+
dumpObj, eLoggingSeverity, eventOn, generateW3CId, getExceptionName, getGlobal, getIEVersion, getLocation, getPerformance, isFunction,
|
|
16
|
+
isNullOrUndefined, isString, isXhrSupported, mergeEvtNamespace, onConfigChange, strPrototype, strTrim
|
|
17
|
+
} from "@microsoft/applicationinsights-core-js";
|
|
18
|
+
import { objFreeze, scheduleTimeout, strIndexOf } from "@nevware21/ts-utils";
|
|
19
|
+
import { DependencyInitializerFunction, IDependencyInitializerDetails, IDependencyInitializerHandler } from "./DependencyInitializer";
|
|
20
|
+
import {
|
|
21
|
+
DependencyListenerFunction, IDependencyHandler, IDependencyListenerContainer, IDependencyListenerDetails, IDependencyListenerHandler
|
|
22
|
+
} from "./DependencyListener";
|
|
23
|
+
import { IAjaxRecordResponse, ajaxRecord } from "./ajaxRecord";
|
|
24
|
+
|
|
25
25
|
const AJAX_MONITOR_PREFIX = "ai.ajxmn.";
|
|
26
26
|
const strDiagLog = "diagLog";
|
|
27
27
|
const strAjaxData = "ajaxData";
|
|
28
|
-
const
|
|
28
|
+
const STR_FETCH = "fetch";
|
|
29
29
|
|
|
30
30
|
const ERROR_HEADER = "Failed to monitor XMLHttpRequest";
|
|
31
31
|
const ERROR_PREFIX = ", monitoring data for this ajax call ";
|
|
@@ -49,11 +49,11 @@ function _supportsFetch(): (input: RequestInfo, init?: RequestInit) => Promise<R
|
|
|
49
49
|
if (!_global ||
|
|
50
50
|
isNullOrUndefined((_global as any).Request) ||
|
|
51
51
|
isNullOrUndefined((_global as any).Request[strPrototype]) ||
|
|
52
|
-
isNullOrUndefined(_global[
|
|
52
|
+
isNullOrUndefined(_global[STR_FETCH])) {
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
return _global[
|
|
56
|
+
return _global[STR_FETCH];
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -198,7 +198,8 @@ function _processDependencyListeners(listeners: _IInternalDependencyHandler<Depe
|
|
|
198
198
|
traceId: ajaxData.traceID,
|
|
199
199
|
spanId: ajaxData.spanID,
|
|
200
200
|
traceFlags: ajaxData.traceFlags,
|
|
201
|
-
context: ajaxData.context || {}
|
|
201
|
+
context: ajaxData.context || {},
|
|
202
|
+
aborted: !!ajaxData.aborted
|
|
202
203
|
};
|
|
203
204
|
|
|
204
205
|
_processDependencyContainer(core, listeners, details, "listener");
|
|
@@ -559,7 +560,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
559
560
|
_enableResponseHeaderTracking = _extensionConfig.enableResponseHeaderTracking;
|
|
560
561
|
|
|
561
562
|
if (!_disableFetchTracking && !_fetchInitialized) {
|
|
562
|
-
_addHook(InstrumentFunc(global,
|
|
563
|
+
_addHook(InstrumentFunc(global, STR_FETCH, {
|
|
563
564
|
ns: _evtNamespace,
|
|
564
565
|
// Add request hook
|
|
565
566
|
req: (callDetails: IInstrumentCallDetails, input, init) => {
|
|
@@ -585,12 +586,12 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
585
586
|
callDetails.rslt = callDetails.rslt.then((response: any) => {
|
|
586
587
|
_reportFetchMetrics(callDetails, (response||{}).status, input, response, fetchData, () => {
|
|
587
588
|
let ajaxResponse:IAjaxRecordResponse = {
|
|
588
|
-
statusText: response.statusText,
|
|
589
|
+
statusText: (response||{}).statusText,
|
|
589
590
|
headerMap: null,
|
|
590
591
|
correlationContext: _getFetchCorrelationContext(response)
|
|
591
592
|
};
|
|
592
593
|
|
|
593
|
-
if (_enableResponseHeaderTracking) {
|
|
594
|
+
if (_enableResponseHeaderTracking && response) {
|
|
594
595
|
const responseHeaderMap = {};
|
|
595
596
|
response.headers.forEach((value: string, name: string) => { // @skip-minify
|
|
596
597
|
if (_canIncludeHeaders(name)) {
|
|
@@ -607,7 +608,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
607
608
|
return response;
|
|
608
609
|
})
|
|
609
610
|
.catch((reason: any) => {
|
|
610
|
-
_reportFetchMetrics(callDetails, 0, input, null, fetchData, null, { error: reason.message });
|
|
611
|
+
_reportFetchMetrics(callDetails, 0, input, null, fetchData, null, { error: reason.message || dumpObj(reason) });
|
|
611
612
|
throw reason;
|
|
612
613
|
});
|
|
613
614
|
}
|
|
@@ -626,7 +627,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
626
627
|
// Note: Polyfill implementations that don't support the "polyfill" tag are not supported
|
|
627
628
|
// the workaround is to add a polyfill property to your fetch implementation before initializing
|
|
628
629
|
// App Insights
|
|
629
|
-
_addHook(InstrumentFunc(global,
|
|
630
|
+
_addHook(InstrumentFunc(global, STR_FETCH, {
|
|
630
631
|
ns: _evtNamespace,
|
|
631
632
|
req: (callDetails: IInstrumentCallDetails, input, init) => {
|
|
632
633
|
// Just call so that we record any disabled URL
|
|
@@ -640,7 +641,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
640
641
|
if (isPolyfill) {
|
|
641
642
|
// retag the instrumented fetch with the same polyfill settings this is mostly for testing
|
|
642
643
|
// But also supports multiple App Insights usages
|
|
643
|
-
(global[
|
|
644
|
+
(global[STR_FETCH] as any).polyfill = isPolyfill;
|
|
644
645
|
}
|
|
645
646
|
}
|
|
646
647
|
|
|
@@ -1107,7 +1108,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
1107
1108
|
|
|
1108
1109
|
ajaxData.requestHeaders = requestHeaders;
|
|
1109
1110
|
|
|
1110
|
-
_createMarkId(
|
|
1111
|
+
_createMarkId(STR_FETCH, ajaxData);
|
|
1111
1112
|
|
|
1112
1113
|
return ajaxData;
|
|
1113
1114
|
}
|
|
@@ -1153,7 +1154,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
1153
1154
|
ajaxData.responseFinishedTime = dateTimeUtilsNow();
|
|
1154
1155
|
ajaxData.status = status;
|
|
1155
1156
|
|
|
1156
|
-
_findPerfResourceEntry(
|
|
1157
|
+
_findPerfResourceEntry(STR_FETCH, ajaxData, () => {
|
|
1157
1158
|
const dependency = ajaxData.CreateTrackItem("Fetch", _enableRequestHeaderTracking, getResponse);
|
|
1158
1159
|
|
|
1159
1160
|
let properties;
|
|
@@ -1219,7 +1220,8 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
1219
1220
|
item: dependency,
|
|
1220
1221
|
properties: properties,
|
|
1221
1222
|
sysProperties: systemProperties,
|
|
1222
|
-
context: ajaxData ? ajaxData.context : null
|
|
1223
|
+
context: ajaxData ? ajaxData.context : null,
|
|
1224
|
+
aborted: ajaxData ? !!ajaxData.aborted : false
|
|
1223
1225
|
};
|
|
1224
1226
|
|
|
1225
1227
|
result = _processDependencyContainer(core, initializers, details, "initializer");
|
|
@@ -1284,4 +1286,4 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
1284
1286
|
protected trackDependencyDataInternal(dependency: IDependencyTelemetry, properties?: { [key: string]: any }, systemProperties?: { [key: string]: any }) {
|
|
1285
1287
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1286
1288
|
}
|
|
1287
|
-
}
|
|
1289
|
+
}
|
package/src/ajaxRecord.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
5
|
-
import {
|
|
6
|
-
Extensions, IDependencyTelemetry, dataSanitizeUrl, dateTimeUtilsDuration, msToTimeSpan, urlGetAbsoluteUrl, urlGetCompleteUrl
|
|
7
|
-
} from "@microsoft/applicationinsights-common";
|
|
8
|
-
import {
|
|
9
|
-
IDiagnosticLogger, IDistributedTraceContext, arrForEach, isNullOrUndefined, isNumber, isString, normalizeJsName, objForEachKey, objKeys
|
|
10
|
-
} from "@microsoft/applicationinsights-core-js";
|
|
11
|
-
import { STR_DURATION, STR_PROPERTIES } from "./InternalConstants";
|
|
12
|
-
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
5
|
+
import {
|
|
6
|
+
Extensions, IDependencyTelemetry, dataSanitizeUrl, dateTimeUtilsDuration, msToTimeSpan, urlGetAbsoluteUrl, urlGetCompleteUrl
|
|
7
|
+
} from "@microsoft/applicationinsights-common";
|
|
8
|
+
import {
|
|
9
|
+
IDiagnosticLogger, IDistributedTraceContext, arrForEach, isNullOrUndefined, isNumber, isString, normalizeJsName, objForEachKey, objKeys
|
|
10
|
+
} from "@microsoft/applicationinsights-core-js";
|
|
11
|
+
import { STR_DURATION, STR_PROPERTIES } from "./InternalConstants";
|
|
12
|
+
|
|
13
13
|
export interface IAjaxRecordResponse {
|
|
14
14
|
statusText: string,
|
|
15
15
|
headerMap: Object,
|
|
@@ -240,7 +240,7 @@ export class ajaxRecord {
|
|
|
240
240
|
|
|
241
241
|
public xhrMonitoringState: XHRMonitoringState;
|
|
242
242
|
|
|
243
|
-
// <summary>Determines whether or not JavaScript exception
|
|
243
|
+
// <summary>Determines whether or not JavaScript exception occurred in xhr.onreadystatechange code. 1 if occurred, otherwise 0.</summary>
|
|
244
244
|
public clientFailure: number;
|
|
245
245
|
|
|
246
246
|
/**
|
|
@@ -339,6 +339,11 @@ export class ajaxRecord {
|
|
|
339
339
|
[STR_PROPERTIES]: { HttpMethod: self.method }
|
|
340
340
|
} as IDependencyTelemetry;
|
|
341
341
|
|
|
342
|
+
let props = dependency[STR_PROPERTIES];
|
|
343
|
+
if (self.aborted) {
|
|
344
|
+
props.aborted = true;
|
|
345
|
+
}
|
|
346
|
+
|
|
342
347
|
if (self.requestSentTime) {
|
|
343
348
|
// Set the correct dependency start time
|
|
344
349
|
dependency.startTime = new Date();
|
|
@@ -350,7 +355,6 @@ export class ajaxRecord {
|
|
|
350
355
|
|
|
351
356
|
if (enableRequestHeaderTracking) {
|
|
352
357
|
if (objKeys(self.requestHeaders).length > 0) {
|
|
353
|
-
let props = dependency.properties = dependency.properties || {};
|
|
354
358
|
props.requestHeaders = self.requestHeaders;
|
|
355
359
|
}
|
|
356
360
|
}
|
|
@@ -367,19 +371,21 @@ export class ajaxRecord {
|
|
|
367
371
|
|
|
368
372
|
if (response.headerMap) {
|
|
369
373
|
if (objKeys(response.headerMap).length > 0) {
|
|
370
|
-
let props = dependency.properties = dependency.properties || {};
|
|
371
374
|
props.responseHeaders = response.headerMap;
|
|
372
375
|
}
|
|
373
376
|
}
|
|
374
377
|
|
|
375
|
-
if (self.errorStatusText
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
if (self.errorStatusText) {
|
|
379
|
+
if (self.status >= 400) {
|
|
380
|
+
const responseType = response.type;
|
|
381
|
+
if (responseType === "" || responseType === "text") {
|
|
382
|
+
props.responseText = response.responseText ? response.statusText + " - " + response[strResponseText] : response.statusText;
|
|
383
|
+
}
|
|
384
|
+
if (responseType === "json") {
|
|
385
|
+
props.responseText = response.response ? response.statusText + " - " + JSON.stringify(response.response) : response.statusText;
|
|
386
|
+
}
|
|
387
|
+
} else if (self.status === 0) {
|
|
388
|
+
props.responseText = response.statusText || "";
|
|
383
389
|
}
|
|
384
390
|
}
|
|
385
391
|
}
|
|
@@ -428,4 +434,4 @@ export class ajaxRecord {
|
|
|
428
434
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
429
435
|
return null;
|
|
430
436
|
}
|
|
431
|
-
}
|
|
437
|
+
}
|
package/src/ajaxUtils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
import { isNullOrUndefined } from "@microsoft/applicationinsights-core-js";
|
|
5
|
-
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { isNullOrUndefined } from "@microsoft/applicationinsights-core-js";
|
|
5
|
+
|
|
6
6
|
export class stringUtils {
|
|
7
7
|
public static GetLength(strObject: any) {
|
|
8
8
|
let res = 0;
|
|
@@ -20,4 +20,4 @@ export class stringUtils {
|
|
|
20
20
|
|
|
21
21
|
return res;
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
}
|
|
@@ -23,6 +23,10 @@ export interface IDependencyInitializerDetails {
|
|
|
23
23
|
context?: {
|
|
24
24
|
[key: string]: any;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* [Optional] A flag that indicates whether the client request was manually aborted by the `abort()`
|
|
28
|
+
*/
|
|
29
|
+
aborted?: boolean;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* The initializer function that will be called, if it returns false the event will be dropped and not reported
|
|
@@ -42,6 +42,12 @@ export interface IDependencyListenerDetails {
|
|
|
42
42
|
context?: {
|
|
43
43
|
[key: string]: any;
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* [Optional] A flag that indicates whether the client request was manually aborted by the `abort()`,
|
|
47
|
+
* as listeners are called just before the request is sent it is unlikely that an application would have
|
|
48
|
+
* called `abort` before `send` this is also available in the dependency initializer.
|
|
49
|
+
*/
|
|
50
|
+
aborted?: boolean;
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* The function that will get called when the ajax request is about to occur.
|
|
@@ -5,6 +5,7 @@ export declare const _DYN_TRACE_ID = "traceID";
|
|
|
5
5
|
export declare const _DYN_SPAN_ID = "spanID";
|
|
6
6
|
export declare const _DYN_TRACE_FLAGS = "traceFlags";
|
|
7
7
|
export declare const _DYN_CONTEXT = "context";
|
|
8
|
+
export declare const _DYN_ABORTED = "aborted";
|
|
8
9
|
export declare const _DYN_TRACE_ID0 = "traceId";
|
|
9
10
|
export declare const _DYN_SPAN_ID1 = "spanId";
|
|
10
11
|
export declare const _DYN__ADD_HOOK = "_addHook";
|