@microsoft/applicationinsights-dependencies-js 2.8.0-beta.2202-06 → 2.8.0-beta.2203-02
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 +579 -296
- 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 +0 -29
- package/dist/applicationinsights-dependencies-js.api.md +0 -2
- package/dist/applicationinsights-dependencies-js.d.ts +1 -2
- package/dist/applicationinsights-dependencies-js.js +579 -296
- 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 +1 -2
- package/dist-esm/TraceParent.js +1 -1
- package/dist-esm/ajax.js +19 -24
- package/dist-esm/ajax.js.map +1 -1
- package/dist-esm/ajaxRecord.js +1 -1
- package/dist-esm/ajaxUtils.js +1 -1
- package/dist-esm/applicationinsights-dependencies-js.js +1 -1
- package/package.json +3 -3
- package/src/ajax.ts +21 -27
- package/src/ajaxRecord.ts +1 -1
- package/types/ajax.d.ts +0 -1
package/src/ajax.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
import {
|
|
5
5
|
RequestHeaders, CorrelationIdHelper, TelemetryItemCreator, ICorrelationConfig,
|
|
6
6
|
RemoteDependencyData, dateTimeUtilsNow, DisabledPropertyName, IDependencyTelemetry,
|
|
7
|
-
IConfig, ITelemetryContext, PropertiesPluginIdentifier,
|
|
7
|
+
IConfig, ITelemetryContext, PropertiesPluginIdentifier, eDistributedTracingModes, IRequestContext, isInternalApplicationInsightsEndpoint
|
|
8
8
|
} from "@microsoft/applicationinsights-common";
|
|
9
9
|
import {
|
|
10
10
|
isNullOrUndefined, arrForEach, isString, strTrim, isFunction, LoggingSeverity, _InternalMessageId,
|
|
11
11
|
IAppInsightsCore, BaseTelemetryPlugin, ITelemetryPluginChain, IConfiguration, IPlugin, ITelemetryItem, IProcessTelemetryContext,
|
|
12
12
|
getLocation, getGlobal, strPrototype, IInstrumentCallDetails, InstrumentFunc, InstrumentProto, getPerformance,
|
|
13
|
-
IInstrumentHooksCallbacks,
|
|
13
|
+
IInstrumentHooksCallbacks, objForEachKey, generateW3CId, getIEVersion, dumpObj, ICustomProperties, isXhrSupported, eventOn, mergeEvtNamespace, createUniqueNamespace
|
|
14
14
|
} from "@microsoft/applicationinsights-core-js";
|
|
15
15
|
import { ajaxRecord, IAjaxRecordResponse } from "./ajaxRecord";
|
|
16
16
|
import { Traceparent } from "./TraceParent";
|
|
@@ -158,7 +158,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
158
158
|
disableFetchTracking: true,
|
|
159
159
|
excludeRequestFromAutoTrackingPatterns: undefined,
|
|
160
160
|
disableCorrelationHeaders: false,
|
|
161
|
-
distributedTracingMode:
|
|
161
|
+
distributedTracingMode: eDistributedTracingModes.AI_AND_W3C,
|
|
162
162
|
correlationHeaderExcludedDomains: [
|
|
163
163
|
"*.blob.core.windows.net",
|
|
164
164
|
"*.blob.core.chinacloudapi.cn",
|
|
@@ -214,21 +214,25 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
214
214
|
let _enableAjaxPerfTracking:boolean = false;
|
|
215
215
|
let _maxAjaxCallsPerView:number = 0;
|
|
216
216
|
let _enableResponseHeaderTracking:boolean = false;
|
|
217
|
-
let _hooks:IInstrumentHook[] = [];
|
|
218
217
|
let _disabledUrls:any = {};
|
|
219
218
|
let _excludeRequestFromAutoTrackingPatterns: string[] | RegExp[];
|
|
220
219
|
let _addRequestContext: (requestContext?: IRequestContext) => ICustomProperties;
|
|
220
|
+
let _evtNamespace: string | string[];
|
|
221
|
+
|
|
222
|
+
dynamicProto(AjaxMonitor, this, (_self, _base) => {
|
|
223
|
+
let _addHook = _base._addHook;
|
|
221
224
|
|
|
222
|
-
dynamicProto(AjaxMonitor, this, (_self, base) => {
|
|
223
225
|
_self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => {
|
|
224
226
|
if (!_self.isInitialized()) {
|
|
225
|
-
|
|
227
|
+
_base.initialize(config, core, extensions, pluginChain);
|
|
226
228
|
let ctx = _self._getTelCtx();
|
|
227
229
|
const defaultConfig = AjaxMonitor.getDefaultConfig();
|
|
228
230
|
objForEachKey(defaultConfig, (field, value) => {
|
|
229
231
|
_config[field] = ctx.getConfig(AjaxMonitor.identifier, field, value);
|
|
230
232
|
});
|
|
231
233
|
|
|
234
|
+
_evtNamespace = mergeEvtNamespace(createUniqueNamespace("ajax"), core && core.evtNamespace && core.evtNamespace());
|
|
235
|
+
|
|
232
236
|
let distributedTracingMode = _config.distributedTracingMode;
|
|
233
237
|
_enableRequestHeaderTracking = _config.enableRequestHeaderTracking;
|
|
234
238
|
_enableAjaxErrorStatusText = _config.enableAjaxErrorStatusText;
|
|
@@ -238,8 +242,8 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
238
242
|
_excludeRequestFromAutoTrackingPatterns = _config.excludeRequestFromAutoTrackingPatterns;
|
|
239
243
|
_addRequestContext = _config.addRequestContext;
|
|
240
244
|
|
|
241
|
-
_isUsingAIHeaders = distributedTracingMode ===
|
|
242
|
-
_isUsingW3CHeaders = distributedTracingMode ===
|
|
245
|
+
_isUsingAIHeaders = distributedTracingMode === eDistributedTracingModes.AI || distributedTracingMode === eDistributedTracingModes.AI_AND_W3C;
|
|
246
|
+
_isUsingW3CHeaders = distributedTracingMode === eDistributedTracingModes.AI_AND_W3C || distributedTracingMode === eDistributedTracingModes.W3C;
|
|
243
247
|
if (_enableAjaxPerfTracking) {
|
|
244
248
|
let iKey = config.instrumentationKey || "unkwn";
|
|
245
249
|
if (iKey.length > 5) {
|
|
@@ -272,16 +276,10 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
272
276
|
}
|
|
273
277
|
};
|
|
274
278
|
|
|
275
|
-
_self.
|
|
276
|
-
// Remove all instrumentation hooks
|
|
277
|
-
arrForEach(_hooks, (fn) => {
|
|
278
|
-
fn.rm();
|
|
279
|
-
});
|
|
280
|
-
_hooks = [];
|
|
279
|
+
_self._doTeardown = () => {
|
|
281
280
|
_fetchInitialized = false;
|
|
282
281
|
_xhrInitialized = false;
|
|
283
|
-
|
|
284
|
-
}
|
|
282
|
+
};
|
|
285
283
|
|
|
286
284
|
_self.trackDependencyData = (dependency: IDependencyTelemetry, properties?: { [key: string]: any }) => {
|
|
287
285
|
_self[strTrackDependencyDataInternal](dependency, properties);
|
|
@@ -359,8 +357,8 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
359
357
|
// Hack since expected format in w3c mode is |abc.def.
|
|
360
358
|
// Non-w3c format is |abc.def
|
|
361
359
|
// @todo Remove if better solution is available, e.g. handle in portal
|
|
362
|
-
if ((_config.distributedTracingMode ===
|
|
363
|
-
|| _config.distributedTracingMode ===
|
|
360
|
+
if ((_config.distributedTracingMode === eDistributedTracingModes.W3C
|
|
361
|
+
|| _config.distributedTracingMode === eDistributedTracingModes.AI_AND_W3C)
|
|
364
362
|
&& typeof dependency.id === "string" && dependency.id[dependency.id.length - 1] !== "."
|
|
365
363
|
) {
|
|
366
364
|
dependency.id += ".";
|
|
@@ -411,7 +409,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
411
409
|
let global = getGlobal();
|
|
412
410
|
let isPolyfill = (fetch as any).polyfill;
|
|
413
411
|
if (_config.disableFetchTracking === false) {
|
|
414
|
-
|
|
412
|
+
_addHook(InstrumentFunc(global, strFetch, {
|
|
415
413
|
// Add request hook
|
|
416
414
|
req: (callDetails: IInstrumentCallDetails, input, init) => {
|
|
417
415
|
let fetchData: ajaxRecord;
|
|
@@ -473,7 +471,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
473
471
|
// Note: Polyfill implementations that don't support the "poyyfill" tag are not supported
|
|
474
472
|
// the workaround is to add a polyfill property to your fetch implementation before initializing
|
|
475
473
|
// App Insights
|
|
476
|
-
|
|
474
|
+
_addHook(InstrumentFunc(global, strFetch, {
|
|
477
475
|
req: (callDetails: IInstrumentCallDetails, input, init) => {
|
|
478
476
|
// Just call so that we record any disabled URL
|
|
479
477
|
_isDisabledRequest(null, input, init);
|
|
@@ -489,7 +487,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
489
487
|
}
|
|
490
488
|
|
|
491
489
|
function _hookProto(target: any, funcName: string, callbacks: IInstrumentHooksCallbacks) {
|
|
492
|
-
|
|
490
|
+
_addHook(InstrumentProto(target, funcName, callbacks));
|
|
493
491
|
}
|
|
494
492
|
|
|
495
493
|
function _instrumentXhr():void {
|
|
@@ -653,7 +651,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
653
651
|
}
|
|
654
652
|
|
|
655
653
|
function _attachToOnReadyStateChange(xhr: XMLHttpRequestInstrumented) {
|
|
656
|
-
xhr[strAjaxData].xhrMonitoringState.stateChangeAttached =
|
|
654
|
+
xhr[strAjaxData].xhrMonitoringState.stateChangeAttached = eventOn(xhr, "readystatechange", () => {
|
|
657
655
|
try {
|
|
658
656
|
if (xhr && xhr.readyState === 4 && _isMonitoredXhrInstance(xhr)) {
|
|
659
657
|
_onAjaxComplete(xhr);
|
|
@@ -672,7 +670,7 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
672
670
|
});
|
|
673
671
|
}
|
|
674
672
|
}
|
|
675
|
-
});
|
|
673
|
+
}, _evtNamespace);
|
|
676
674
|
}
|
|
677
675
|
|
|
678
676
|
function _getResponseText(xhr: XMLHttpRequestInstrumented) {
|
|
@@ -1007,10 +1005,6 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
|
|
|
1007
1005
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1008
1006
|
}
|
|
1009
1007
|
|
|
1010
|
-
public teardown():void {
|
|
1011
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
1008
|
public processTelemetry(item: ITelemetryItem, itemCtx?: IProcessTelemetryContext) {
|
|
1015
1009
|
this.processNext(item, itemCtx);
|
|
1016
1010
|
}
|
package/src/ajaxRecord.ts
CHANGED
|
@@ -141,7 +141,7 @@ function _populatePerfData(ajaxData:ajaxRecord, dependency:IDependencyTelemetry)
|
|
|
141
141
|
arrForEach(serverTiming, (value, idx) => {
|
|
142
142
|
let name = normalizeJsName(value[strName] || "" + idx);
|
|
143
143
|
let newValue = server[name] || {};
|
|
144
|
-
objForEachKey(value, (key, val) => {
|
|
144
|
+
objForEachKey(value, (key, val: any) => {
|
|
145
145
|
if (key !== strName && isString(val) || isNumber(val)) {
|
|
146
146
|
if (newValue[key]) {
|
|
147
147
|
val = newValue[key] + ";" + val;
|
package/types/ajax.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export declare class AjaxMonitor extends BaseTelemetryPlugin implements IDepende
|
|
|
22
22
|
priority: number;
|
|
23
23
|
constructor();
|
|
24
24
|
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
25
|
-
teardown(): void;
|
|
26
25
|
processTelemetry(item: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
27
26
|
/**
|
|
28
27
|
* Logs dependency call
|