@microsoft/applicationinsights-dependencies-js 3.0.0-beta.2303-11 → 3.0.0-beta.2304-07
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/es5/applicationinsights-dependencies-js.cjs.js +4892 -0
- package/browser/es5/applicationinsights-dependencies-js.cjs.js.map +1 -0
- package/browser/es5/applicationinsights-dependencies-js.cjs.min.js +6 -0
- package/browser/es5/applicationinsights-dependencies-js.cjs.min.js.map +1 -0
- package/browser/es5/applicationinsights-dependencies-js.gbl.js +4896 -0
- package/browser/es5/applicationinsights-dependencies-js.gbl.js.map +1 -0
- package/browser/es5/applicationinsights-dependencies-js.gbl.min.js +6 -0
- package/browser/es5/applicationinsights-dependencies-js.gbl.min.js.map +1 -0
- package/browser/es5/applicationinsights-dependencies-js.integrity.json +66 -0
- package/browser/{applicationinsights-dependencies-js.js → es5/applicationinsights-dependencies-js.js} +864 -839
- package/browser/es5/applicationinsights-dependencies-js.js.map +1 -0
- package/browser/es5/applicationinsights-dependencies-js.min.js +6 -0
- package/browser/es5/applicationinsights-dependencies-js.min.js.map +1 -0
- package/dist/{applicationinsights-dependencies-js.js → es5/applicationinsights-dependencies-js.js} +864 -839
- package/dist/es5/applicationinsights-dependencies-js.js.map +1 -0
- package/dist/es5/applicationinsights-dependencies-js.min.js +6 -0
- package/dist/es5/applicationinsights-dependencies-js.min.js.map +1 -0
- package/{dist-esm → dist-es5}/DependencyInitializer.js +1 -1
- package/{dist-esm → dist-es5}/DependencyListener.js +1 -1
- package/{dist-esm → dist-es5}/InternalConstants.js +1 -1
- package/{dist-esm → dist-es5}/__DynamicConstants.js +1 -1
- package/{dist-esm → dist-es5}/ajax.js +5 -5
- package/dist-es5/ajax.js.map +1 -0
- package/{dist-esm → dist-es5}/ajaxRecord.js +1 -1
- package/{dist-esm → dist-es5}/ajaxUtils.js +1 -1
- package/{dist-esm → dist-es5}/applicationinsights-dependencies-js.js +1 -1
- package/package.json +18 -17
- package/tsconfig.json +5 -4
- package/types/applicationinsights-dependencies-js.d.ts +284 -4
- package/{dist/applicationinsights-dependencies-js.d.ts → types/applicationinsights-dependencies-js.namespaced.d.ts} +1 -1
- package/browser/applicationinsights-dependencies-js.integrity.json +0 -26
- package/browser/applicationinsights-dependencies-js.js.map +0 -1
- package/browser/applicationinsights-dependencies-js.min.js +0 -6
- package/browser/applicationinsights-dependencies-js.min.js.map +0 -1
- package/dist/applicationinsights-dependencies-js.api.json +0 -2904
- package/dist/applicationinsights-dependencies-js.api.md +0 -197
- package/dist/applicationinsights-dependencies-js.js.map +0 -1
- package/dist/applicationinsights-dependencies-js.min.js +0 -6
- package/dist/applicationinsights-dependencies-js.min.js.map +0 -1
- package/dist/applicationinsights-dependencies-js.rollup.d.ts +0 -285
- package/dist-esm/ajax.js.map +0 -1
- package/src/DependencyInitializer.ts +0 -49
- package/src/DependencyListener.ts +0 -82
- package/src/InternalConstants.ts +0 -13
- package/src/__DynamicConstants.ts +0 -68
- package/src/ajax.ts +0 -1290
- package/src/ajaxRecord.ts +0 -436
- package/src/ajaxUtils.ts +0 -23
- package/src/applicationinsights-dependencies-js.ts +0 -9
- package/types/DependencyInitializer.d.ts +0 -45
- package/types/DependencyListener.d.ts +0 -69
- package/types/InternalConstants.d.ts +0 -2
- package/types/__DynamicConstants.d.ts +0 -56
- package/types/ajax.d.ts +0 -63
- package/types/ajaxRecord.d.ts +0 -80
- package/types/ajaxUtils.d.ts +0 -3
- package/types/tsdoc-metadata.json +0 -11
- /package/{dist-esm → dist-es5}/DependencyInitializer.js.map +0 -0
- /package/{dist-esm → dist-es5}/DependencyListener.js.map +0 -0
- /package/{dist-esm → dist-es5}/InternalConstants.js.map +0 -0
- /package/{dist-esm → dist-es5}/__DynamicConstants.js.map +0 -0
- /package/{dist-esm → dist-es5}/ajaxRecord.js.map +0 -0
- /package/{dist-esm → dist-es5}/ajaxUtils.js.map +0 -0
- /package/{dist-esm → dist-es5}/applicationinsights-dependencies-js.js.map +0 -0
package/src/ajaxRecord.ts
DELETED
|
@@ -1,436 +0,0 @@
|
|
|
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
|
-
export interface IAjaxRecordResponse {
|
|
14
|
-
statusText: string,
|
|
15
|
-
headerMap: Object,
|
|
16
|
-
correlationContext: string,
|
|
17
|
-
type?: string,
|
|
18
|
-
responseText?: string,
|
|
19
|
-
response?: Object
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface ITraceCtx {
|
|
23
|
-
traceId: string;
|
|
24
|
-
spanId: string;
|
|
25
|
-
traceFlags: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** @ignore */
|
|
29
|
-
function _calcPerfDuration(resourceEntry:PerformanceResourceTiming, start:string, end:string) {
|
|
30
|
-
let result = 0;
|
|
31
|
-
let from = resourceEntry[start];
|
|
32
|
-
let to = resourceEntry[end];
|
|
33
|
-
if (from && to) {
|
|
34
|
-
result = dateTimeUtilsDuration(from, to);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** @ignore */
|
|
41
|
-
function _setPerfDuration(props:any, name:string, resourceEntry:PerformanceResourceTiming, start:string, end:string): number {
|
|
42
|
-
let result = 0;
|
|
43
|
-
let value = _calcPerfDuration(resourceEntry, start, end);
|
|
44
|
-
if (value) {
|
|
45
|
-
result = _setPerfValue(props, name, msToTimeSpan(value));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** @ignore */
|
|
52
|
-
function _setPerfValue(props:any, name:string, value:any): number {
|
|
53
|
-
let strPerf = "ajaxPerf";
|
|
54
|
-
let result = 0;
|
|
55
|
-
if (props && name && value) {
|
|
56
|
-
let perfData = props[strPerf] = (props[strPerf] || {});
|
|
57
|
-
perfData[name] = value;
|
|
58
|
-
result = 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** @ignore */
|
|
65
|
-
function _populatePerfData(ajaxData:ajaxRecord, dependency:IDependencyTelemetry) {
|
|
66
|
-
/*
|
|
67
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Resource_Timing_API/Using_the_Resource_Timing_API
|
|
68
|
-
* | -startTime
|
|
69
|
-
* | -redirectStart
|
|
70
|
-
* | | -redirectEnd
|
|
71
|
-
* | | | -fetchStart
|
|
72
|
-
* | | | | -domainLookupStart
|
|
73
|
-
* | | | | |- domainLookupEnd
|
|
74
|
-
* | | | | | | -connectStart
|
|
75
|
-
* | | | | | | | -secureConnectionStart
|
|
76
|
-
* | | | | | | | | -connectEnd
|
|
77
|
-
* | | | | | | | | | -requestStart
|
|
78
|
-
* | | | | | | | | | | | -responseStart
|
|
79
|
-
* | | | | | | | | | | | | | -responseEnd
|
|
80
|
-
* +------------+-+---+----------------+-+--+--------+-+-----------+-+------------+-+
|
|
81
|
-
* |--redirect--| |---|--domainLookup--| |--connect--| |--request--| |--response--| |
|
|
82
|
-
* |-------------------networkConnect----------------|
|
|
83
|
-
* | |---------sentRequest--------|
|
|
84
|
-
* |------------------------------------perfTotal-----------------------------------|
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
let resourceEntry = ajaxData.perfTiming;
|
|
88
|
-
let props = dependency.properties || {};
|
|
89
|
-
let propsSet = 0;
|
|
90
|
-
let strName = "name";
|
|
91
|
-
let strStart = "Start";
|
|
92
|
-
let strEnd = "End";
|
|
93
|
-
let strDomainLookup = "domainLookup";
|
|
94
|
-
let strConnect = "connect";
|
|
95
|
-
let strRedirect = "redirect";
|
|
96
|
-
let strRequest = "request";
|
|
97
|
-
let strResponse = "response";
|
|
98
|
-
let strStartTime = "startTime";
|
|
99
|
-
let strDomainLookupStart = strDomainLookup + strStart;
|
|
100
|
-
let strDomainLookupEnd = strDomainLookup + strEnd;
|
|
101
|
-
let strConnectStart = strConnect + strStart;
|
|
102
|
-
let strConnectEnd = strConnect + strEnd;
|
|
103
|
-
let strRequestStart = strRequest + strStart;
|
|
104
|
-
let strRequestEnd = strRequest + strEnd;
|
|
105
|
-
let strResponseStart = strResponse + strStart;
|
|
106
|
-
let strResponseEnd = strResponse + strEnd;
|
|
107
|
-
let strRedirectStart = strRedirect + strStart;
|
|
108
|
-
let strRedirectEnd = strRedirect = strEnd;
|
|
109
|
-
|
|
110
|
-
let strTransferSize = "transferSize";
|
|
111
|
-
let strEncodedBodySize = "encodedBodySize";
|
|
112
|
-
let strDecodedBodySize = "decodedBodySize";
|
|
113
|
-
let strServerTiming = "serverTiming";
|
|
114
|
-
|
|
115
|
-
if (resourceEntry) {
|
|
116
|
-
// redirect
|
|
117
|
-
propsSet |= _setPerfDuration(props, strRedirect, resourceEntry, strRedirectStart, strRedirectEnd);
|
|
118
|
-
|
|
119
|
-
// domainLookup
|
|
120
|
-
propsSet |= _setPerfDuration(props, strDomainLookup, resourceEntry, strDomainLookupStart, strDomainLookupEnd);
|
|
121
|
-
|
|
122
|
-
// connect
|
|
123
|
-
propsSet |= _setPerfDuration(props, strConnect, resourceEntry, strConnectStart, strConnectEnd);
|
|
124
|
-
|
|
125
|
-
// request
|
|
126
|
-
propsSet |= _setPerfDuration(props, strRequest, resourceEntry, strRequestStart, strRequestEnd);
|
|
127
|
-
|
|
128
|
-
// response
|
|
129
|
-
propsSet |= _setPerfDuration(props, strResponse, resourceEntry, strResponseStart, strResponseEnd);
|
|
130
|
-
|
|
131
|
-
// Network connection time
|
|
132
|
-
propsSet |= _setPerfDuration(props, "networkConnect", resourceEntry, strStartTime, strConnectEnd);
|
|
133
|
-
|
|
134
|
-
// Sent Request
|
|
135
|
-
propsSet |= _setPerfDuration(props, "sentRequest", resourceEntry, strRequestStart, strResponseEnd);
|
|
136
|
-
|
|
137
|
-
// PerfTotal / Duration
|
|
138
|
-
let duration = resourceEntry.duration;
|
|
139
|
-
if (!duration) {
|
|
140
|
-
duration = _calcPerfDuration(resourceEntry, strStartTime, strResponseEnd) || 0;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
propsSet |= _setPerfValue(props, STR_DURATION, duration);
|
|
144
|
-
propsSet |= _setPerfValue(props, "perfTotal", duration);
|
|
145
|
-
|
|
146
|
-
var serverTiming = resourceEntry[strServerTiming];
|
|
147
|
-
if (serverTiming) {
|
|
148
|
-
let server = {};
|
|
149
|
-
arrForEach(serverTiming, (value, idx) => {
|
|
150
|
-
let name = normalizeJsName(value[strName] || "" + idx);
|
|
151
|
-
let newValue = server[name] || {};
|
|
152
|
-
objForEachKey(value, (key, val: any) => {
|
|
153
|
-
if (key !== strName && isString(val) || isNumber(val)) {
|
|
154
|
-
if (newValue[key]) {
|
|
155
|
-
val = newValue[key] + ";" + val;
|
|
156
|
-
}
|
|
157
|
-
if (val || !isString(val)) {
|
|
158
|
-
// Only set the value if it has a value and it's not an empty string
|
|
159
|
-
newValue[key] = val;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
server[name] = newValue;
|
|
164
|
-
});
|
|
165
|
-
propsSet |= _setPerfValue(props, strServerTiming, server);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
propsSet |= _setPerfValue(props, strTransferSize, resourceEntry[strTransferSize]);
|
|
169
|
-
propsSet |= _setPerfValue(props, strEncodedBodySize, resourceEntry[strEncodedBodySize]);
|
|
170
|
-
propsSet |= _setPerfValue(props, strDecodedBodySize, resourceEntry[strDecodedBodySize]);
|
|
171
|
-
} else {
|
|
172
|
-
if (ajaxData.perfMark) {
|
|
173
|
-
propsSet |= _setPerfValue(props, "missing", ajaxData.perfAttempts);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (propsSet) {
|
|
178
|
-
dependency.properties = props;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export class XHRMonitoringState {
|
|
183
|
-
public openDone: boolean;
|
|
184
|
-
public setRequestHeaderDone: boolean;
|
|
185
|
-
public sendDone: boolean;
|
|
186
|
-
public abortDone: boolean;
|
|
187
|
-
|
|
188
|
-
// <summary>True, if onreadyStateChangeCallback function attached to xhr, otherwise false</summary>
|
|
189
|
-
public stateChangeAttached: boolean;
|
|
190
|
-
|
|
191
|
-
constructor() {
|
|
192
|
-
let self = this;
|
|
193
|
-
self.openDone = false;
|
|
194
|
-
self.setRequestHeaderDone = false;
|
|
195
|
-
self.sendDone = false;
|
|
196
|
-
self.abortDone = false;
|
|
197
|
-
|
|
198
|
-
// <summary>True, if onreadyStateChangeCallback function attached to xhr, otherwise false</summary>
|
|
199
|
-
self.stateChangeAttached = false;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export class ajaxRecord {
|
|
204
|
-
public completed:boolean;
|
|
205
|
-
public requestHeadersSize:number;
|
|
206
|
-
public requestHeaders:any;
|
|
207
|
-
public responseReceivingDuration:number;
|
|
208
|
-
public callbackDuration:number;
|
|
209
|
-
public ajaxTotalDuration:number;
|
|
210
|
-
public aborted:number;
|
|
211
|
-
public pageUrl:string;
|
|
212
|
-
public requestUrl:string;
|
|
213
|
-
public requestSize:number;
|
|
214
|
-
public method:string;
|
|
215
|
-
public perfMark:PerformanceMark;
|
|
216
|
-
public perfTiming:PerformanceResourceTiming;
|
|
217
|
-
public perfAttempts?:number;
|
|
218
|
-
public async?:boolean;
|
|
219
|
-
|
|
220
|
-
/// <summary>Should the Error Status text be included in the response</summary>
|
|
221
|
-
public errorStatusText?:boolean;
|
|
222
|
-
|
|
223
|
-
/// <summary>Returns the HTTP status code.</summary>
|
|
224
|
-
public status:string|number;
|
|
225
|
-
|
|
226
|
-
// <summary>The timestamp when open method was invoked</summary>
|
|
227
|
-
public requestSentTime: number;
|
|
228
|
-
|
|
229
|
-
// <summary>The timestamps when first byte was received</summary>
|
|
230
|
-
public responseStartedTime: number;
|
|
231
|
-
|
|
232
|
-
// <summary>The timestamp when last byte was received</summary>
|
|
233
|
-
public responseFinishedTime: number;
|
|
234
|
-
|
|
235
|
-
// <summary>The timestamp when onreadystatechange callback in readyState 4 finished</summary>
|
|
236
|
-
public callbackFinishedTime: number;
|
|
237
|
-
|
|
238
|
-
// <summary>The timestamp at which ajax was ended</summary>
|
|
239
|
-
public endTime: number;
|
|
240
|
-
|
|
241
|
-
public xhrMonitoringState: XHRMonitoringState;
|
|
242
|
-
|
|
243
|
-
// <summary>Determines whether or not JavaScript exception occurred in xhr.onreadystatechange code. 1 if occurred, otherwise 0.</summary>
|
|
244
|
-
public clientFailure: number;
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* The traceId to use for the dependency call
|
|
248
|
-
*/
|
|
249
|
-
public traceID: string;
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* The spanId to use for the dependency call
|
|
253
|
-
*/
|
|
254
|
-
public spanID: string;
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* The traceFlags to use for the dependency call
|
|
258
|
-
*/
|
|
259
|
-
public traceFlags?: number;
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* The trace context to use for reporting the remote dependency call
|
|
263
|
-
*/
|
|
264
|
-
public eventTraceCtx: ITraceCtx;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* The listener assigned context values that will be passed to any dependency initializer
|
|
268
|
-
*/
|
|
269
|
-
public context?: { [key: string]: any };
|
|
270
|
-
|
|
271
|
-
constructor(traceId: string, spanId: string, logger: IDiagnosticLogger, traceCtx?: IDistributedTraceContext) {
|
|
272
|
-
let self = this;
|
|
273
|
-
let _logger: IDiagnosticLogger = logger;
|
|
274
|
-
let strResponseText = "responseText";
|
|
275
|
-
|
|
276
|
-
// Assigning the initial/default values within the constructor to avoid typescript from creating a bunch of
|
|
277
|
-
// this.XXXX = null
|
|
278
|
-
self.perfMark = null;
|
|
279
|
-
self.completed = false;
|
|
280
|
-
self.requestHeadersSize = null;
|
|
281
|
-
self.requestHeaders = null;
|
|
282
|
-
self.responseReceivingDuration = null;
|
|
283
|
-
self.callbackDuration = null;
|
|
284
|
-
self.ajaxTotalDuration = null;
|
|
285
|
-
self.aborted = 0;
|
|
286
|
-
self.pageUrl = null;
|
|
287
|
-
self.requestUrl = null;
|
|
288
|
-
self.requestSize = 0;
|
|
289
|
-
self.method = null;
|
|
290
|
-
self.status = null;
|
|
291
|
-
self.requestSentTime = null;
|
|
292
|
-
self.responseStartedTime = null;
|
|
293
|
-
self.responseFinishedTime = null;
|
|
294
|
-
self.callbackFinishedTime = null;
|
|
295
|
-
self.endTime = null;
|
|
296
|
-
self.xhrMonitoringState = new XHRMonitoringState();
|
|
297
|
-
self.clientFailure = 0;
|
|
298
|
-
|
|
299
|
-
self.traceID = traceId;
|
|
300
|
-
self.spanID = spanId;
|
|
301
|
-
self.traceFlags = traceCtx?.getTraceFlags();
|
|
302
|
-
|
|
303
|
-
if (traceCtx) {
|
|
304
|
-
self.eventTraceCtx = {
|
|
305
|
-
traceId: traceCtx.getTraceId(),
|
|
306
|
-
spanId: traceCtx.getSpanId(),
|
|
307
|
-
traceFlags: traceCtx.getTraceFlags()
|
|
308
|
-
};
|
|
309
|
-
} else {
|
|
310
|
-
self.eventTraceCtx = null;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
dynamicProto(ajaxRecord, self, (self) => {
|
|
314
|
-
self.getAbsoluteUrl= () => {
|
|
315
|
-
return self.requestUrl ? urlGetAbsoluteUrl(self.requestUrl) : null;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
self.getPathName = () => {
|
|
319
|
-
return self.requestUrl ? dataSanitizeUrl(_logger, urlGetCompleteUrl(self.method, self.requestUrl)) : null;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
self.CreateTrackItem = (ajaxType:string, enableRequestHeaderTracking:boolean, getResponse:() => IAjaxRecordResponse):IDependencyTelemetry => {
|
|
323
|
-
// round to 3 decimal points
|
|
324
|
-
self.ajaxTotalDuration = Math.round(dateTimeUtilsDuration(self.requestSentTime, self.responseFinishedTime) * 1000) / 1000;
|
|
325
|
-
if (self.ajaxTotalDuration < 0) {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
let dependency = {
|
|
330
|
-
id: "|" + self.traceID + "." + self.spanID,
|
|
331
|
-
target: self.getAbsoluteUrl(),
|
|
332
|
-
name: self.getPathName(),
|
|
333
|
-
type: ajaxType,
|
|
334
|
-
startTime: null,
|
|
335
|
-
duration: self.ajaxTotalDuration,
|
|
336
|
-
success: (+(self.status)) >= 200 && (+(self.status)) < 400,
|
|
337
|
-
responseCode: (+(self.status)),
|
|
338
|
-
[STR_PROPERTIES]: { HttpMethod: self.method }
|
|
339
|
-
} as IDependencyTelemetry;
|
|
340
|
-
|
|
341
|
-
let props = dependency[STR_PROPERTIES];
|
|
342
|
-
if (self.aborted) {
|
|
343
|
-
props.aborted = true;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (self.requestSentTime) {
|
|
347
|
-
// Set the correct dependency start time
|
|
348
|
-
dependency.startTime = new Date();
|
|
349
|
-
dependency.startTime.setTime(self.requestSentTime);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Add Ajax perf details if available
|
|
353
|
-
_populatePerfData(self, dependency);
|
|
354
|
-
|
|
355
|
-
if (enableRequestHeaderTracking) {
|
|
356
|
-
if (objKeys(self.requestHeaders).length > 0) {
|
|
357
|
-
props.requestHeaders = self.requestHeaders;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
if (getResponse) {
|
|
362
|
-
let response:IAjaxRecordResponse = getResponse();
|
|
363
|
-
if (response) {
|
|
364
|
-
|
|
365
|
-
// enrich dependency target with correlation context from the server
|
|
366
|
-
const correlationContext = response.correlationContext;
|
|
367
|
-
if (correlationContext) {
|
|
368
|
-
dependency.correlationContext = /* dependency.target + " | " + */ correlationContext;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (response.headerMap) {
|
|
372
|
-
if (objKeys(response.headerMap).length > 0) {
|
|
373
|
-
props.responseHeaders = response.headerMap;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (self.errorStatusText) {
|
|
378
|
-
if (self.status >= 400) {
|
|
379
|
-
const responseType = response.type;
|
|
380
|
-
if (responseType === "" || responseType === "text") {
|
|
381
|
-
props.responseText = response.responseText ? response.statusText + " - " + response[strResponseText] : response.statusText;
|
|
382
|
-
}
|
|
383
|
-
if (responseType === "json") {
|
|
384
|
-
props.responseText = response.response ? response.statusText + " - " + JSON.stringify(response.response) : response.statusText;
|
|
385
|
-
}
|
|
386
|
-
} else if (self.status === 0) {
|
|
387
|
-
props.responseText = response.statusText || "";
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return dependency;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
self.getPartAProps = () => {
|
|
397
|
-
let partA: { [key: string]: any } = null;
|
|
398
|
-
|
|
399
|
-
let traceCtx = self.eventTraceCtx;
|
|
400
|
-
if (traceCtx && (traceCtx.traceId || traceCtx.spanId)) {
|
|
401
|
-
partA = {};
|
|
402
|
-
let traceExt = partA[Extensions.TraceExt] = {
|
|
403
|
-
traceID: traceCtx.traceId,
|
|
404
|
-
parentID: traceCtx.spanId
|
|
405
|
-
} as { [key: string]: any };
|
|
406
|
-
|
|
407
|
-
if (!isNullOrUndefined(traceCtx.traceFlags)) {
|
|
408
|
-
traceExt.traceFlags = traceCtx.traceFlags;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
return partA
|
|
413
|
-
};
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
public getAbsoluteUrl(): string {
|
|
418
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
419
|
-
return null;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
public getPathName(): string {
|
|
423
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
424
|
-
return null;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
public CreateTrackItem(ajaxType:string, enableRequestHeaderTracking:boolean, getResponse:() => IAjaxRecordResponse):IDependencyTelemetry {
|
|
428
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
public getPartAProps(): { [key: string]: any } {
|
|
433
|
-
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
434
|
-
return null;
|
|
435
|
-
}
|
|
436
|
-
}
|
package/src/ajaxUtils.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
export class stringUtils {
|
|
7
|
-
public static GetLength(strObject: any) {
|
|
8
|
-
let res = 0;
|
|
9
|
-
if (!isNullOrUndefined(strObject)) {
|
|
10
|
-
let stringified = "";
|
|
11
|
-
try {
|
|
12
|
-
stringified = strObject.toString();
|
|
13
|
-
} catch (ex) {
|
|
14
|
-
// some troubles with complex object
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
res = stringified.length;
|
|
18
|
-
res = isNaN(res) ? 0 : res;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return res;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
AjaxMonitor as AjaxPlugin, IDependenciesPlugin, XMLHttpRequestInstrumented, IInstrumentationRequirements, DfltAjaxCorrelationHeaderExDomains
|
|
6
|
-
} from "./ajax";
|
|
7
|
-
export { ajaxRecord } from "./ajaxRecord";
|
|
8
|
-
export { IDependencyHandler, IDependencyListenerHandler, IDependencyListenerDetails, DependencyListenerFunction } from "./DependencyListener";
|
|
9
|
-
export { IDependencyInitializerHandler, IDependencyInitializerDetails, DependencyInitializerFunction } from "./DependencyInitializer";
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { IDependencyTelemetry } from "@microsoft/applicationinsights-common";
|
|
2
|
-
import { IDependencyHandler } from "./DependencyListener";
|
|
3
|
-
export interface IDependencyInitializerDetails {
|
|
4
|
-
/**
|
|
5
|
-
* The DependencyTelemetry event that will be passed to the `trackDependencyDataInternal` function.
|
|
6
|
-
*/
|
|
7
|
-
item: IDependencyTelemetry;
|
|
8
|
-
/**
|
|
9
|
-
* Additional properties to be added to the event
|
|
10
|
-
*/
|
|
11
|
-
properties?: {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Additional system properties to be added to the event.
|
|
16
|
-
*/
|
|
17
|
-
sysProperties?: {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The context that the application can assigned via the dependency listener(s)
|
|
22
|
-
*/
|
|
23
|
-
context?: {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* [Optional] A flag that indicates whether the client request was manually aborted by the `abort()`
|
|
28
|
-
*/
|
|
29
|
-
aborted?: boolean;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The initializer function that will be called, if it returns false the event will be dropped and not reported
|
|
33
|
-
* or counted against the `maxAjaxCallsPerView`.
|
|
34
|
-
*/
|
|
35
|
-
export declare type DependencyInitializerFunction = (item: IDependencyInitializerDetails) => boolean | void;
|
|
36
|
-
export interface IDependencyInitializerHandler extends IDependencyHandler {
|
|
37
|
-
}
|
|
38
|
-
export interface IDependencyInitializerContainer {
|
|
39
|
-
/**
|
|
40
|
-
* Add a dependency telemetry processor to decorate or drop telemetry events.
|
|
41
|
-
* @param dependencyInitializer - The Telemetry Initializer function
|
|
42
|
-
* @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
|
|
43
|
-
*/
|
|
44
|
-
addDependencyInitializer(dependencyInitializer: DependencyInitializerFunction): IDependencyInitializerHandler | void;
|
|
45
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { IAppInsightsCore } from "@microsoft/applicationinsights-core-js";
|
|
2
|
-
export interface IDependencyListenerDetails {
|
|
3
|
-
/**
|
|
4
|
-
* The current core instance
|
|
5
|
-
*/
|
|
6
|
-
core: IAppInsightsCore;
|
|
7
|
-
/**
|
|
8
|
-
* Provided only if the dependency request is an XHR call
|
|
9
|
-
*/
|
|
10
|
-
xhr?: XMLHttpRequest;
|
|
11
|
-
/**
|
|
12
|
-
* Provided only if the dependency request is a fetch call, this is the input argument being used,
|
|
13
|
-
* re-assigning this value has not affect on the value used for the request, however, when this is a Request
|
|
14
|
-
* object changing the value of the Request will be used for the outbound request.
|
|
15
|
-
*/
|
|
16
|
-
input?: Request | string;
|
|
17
|
-
/**
|
|
18
|
-
* Provided only if the dependency request is a fetch call, this is the init argument being used,
|
|
19
|
-
* re-assigning this value does not change the value used for the request, however, changing properties
|
|
20
|
-
* of this object will be used.
|
|
21
|
-
*/
|
|
22
|
-
init?: RequestInit;
|
|
23
|
-
/**
|
|
24
|
-
* Returns the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
|
|
25
|
-
* Must be read from incoming headers or generated according to the W3C TraceContext specification,
|
|
26
|
-
* in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID
|
|
27
|
-
*/
|
|
28
|
-
traceId?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
|
|
31
|
-
* Also know as the parentId, used to link requests together
|
|
32
|
-
*/
|
|
33
|
-
spanId?: string;
|
|
34
|
-
/**
|
|
35
|
-
* An integer representation of the W3C TraceContext trace-flags.
|
|
36
|
-
* https://www.w3.org/TR/trace-context/#trace-flags
|
|
37
|
-
*/
|
|
38
|
-
traceFlags?: number;
|
|
39
|
-
/**
|
|
40
|
-
* [Optional] Context that the application can assign that will also be passed to any dependency initializer
|
|
41
|
-
*/
|
|
42
|
-
context?: {
|
|
43
|
-
[key: string]: any;
|
|
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;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The function that will get called when the ajax request is about to occur.
|
|
54
|
-
*/
|
|
55
|
-
export declare type DependencyListenerFunction = (dependencyDetails: IDependencyListenerDetails) => void;
|
|
56
|
-
export interface IDependencyHandler {
|
|
57
|
-
remove(): void;
|
|
58
|
-
}
|
|
59
|
-
export interface IDependencyListenerHandler extends IDependencyHandler {
|
|
60
|
-
}
|
|
61
|
-
export interface IDependencyListenerContainer {
|
|
62
|
-
/**
|
|
63
|
-
* Add an ajax listener which is called just prior to the request being sent and before the correlation headers are added, to allow you
|
|
64
|
-
* to access the headers and modify the values used to generate the distributed tracing correlation headers. (added in v2.8.4)
|
|
65
|
-
* @param dependencyListener - The Telemetry Initializer function
|
|
66
|
-
* @returns - A IDependencyListenerHandler to enable the initializer to be removed
|
|
67
|
-
*/
|
|
68
|
-
addDependencyListener(dependencyListener: DependencyListenerFunction): IDependencyListenerHandler;
|
|
69
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export declare const _DYN_REQUEST_URL = "requestUrl";
|
|
2
|
-
export declare const _DYN_INST = "inst";
|
|
3
|
-
export declare const _DYN_LENGTH = "length";
|
|
4
|
-
export declare const _DYN_TRACE_ID = "traceID";
|
|
5
|
-
export declare const _DYN_SPAN_ID = "spanID";
|
|
6
|
-
export declare const _DYN_TRACE_FLAGS = "traceFlags";
|
|
7
|
-
export declare const _DYN_CONTEXT = "context";
|
|
8
|
-
export declare const _DYN_ABORTED = "aborted";
|
|
9
|
-
export declare const _DYN_TRACE_ID0 = "traceId";
|
|
10
|
-
export declare const _DYN_SPAN_ID1 = "spanId";
|
|
11
|
-
export declare const _DYN__ADD_HOOK = "_addHook";
|
|
12
|
-
export declare const _DYN_CORE = "core";
|
|
13
|
-
export declare const _DYN_INCLUDE_CORRELATION_2 = "includeCorrelationHeaders";
|
|
14
|
-
export declare const _DYN_GET_ABSOLUTE_URL = "getAbsoluteUrl";
|
|
15
|
-
export declare const _DYN_HEADERS = "headers";
|
|
16
|
-
export declare const _DYN_REQUEST_HEADERS = "requestHeaders";
|
|
17
|
-
export declare const _DYN_SET_REQUEST_HEADER = "setRequestHeader";
|
|
18
|
-
export declare const _DYN_TRACK_DEPENDENCY_DAT3 = "trackDependencyDataInternal";
|
|
19
|
-
export declare const _DYN_START_TIME = "startTime";
|
|
20
|
-
export declare const _DYN_TO_LOWER_CASE = "toLowerCase";
|
|
21
|
-
export declare const _DYN_ENABLE_REQUEST_HEADE4 = "enableRequestHeaderTracking";
|
|
22
|
-
export declare const _DYN_ENABLE_AJAX_ERROR_ST5 = "enableAjaxErrorStatusText";
|
|
23
|
-
export declare const _DYN_ENABLE_AJAX_PERF_TRA6 = "enableAjaxPerfTracking";
|
|
24
|
-
export declare const _DYN_MAX_AJAX_CALLS_PER_V7 = "maxAjaxCallsPerView";
|
|
25
|
-
export declare const _DYN_EXCLUDE_REQUEST_FROM8 = "excludeRequestFromAutoTrackingPatterns";
|
|
26
|
-
export declare const _DYN_ADD_REQUEST_CONTEXT = "addRequestContext";
|
|
27
|
-
export declare const _DYN_DISABLE_AJAX_TRACKIN9 = "disableAjaxTracking";
|
|
28
|
-
export declare const _DYN_AJAX_PERF_LOOKUP_DEL10 = "ajaxPerfLookupDelay";
|
|
29
|
-
export declare const _DYN_DISABLE_FETCH_TRACKI11 = "disableFetchTracking";
|
|
30
|
-
export declare const _DYN_ENABLE_RESPONSE_HEAD12 = "enableResponseHeaderTracking";
|
|
31
|
-
export declare const _DYN_STATUS = "status";
|
|
32
|
-
export declare const _DYN_STATUS_TEXT = "statusText";
|
|
33
|
-
export declare const _DYN_HEADER_MAP = "headerMap";
|
|
34
|
-
export declare const _DYN_OPEN_DONE = "openDone";
|
|
35
|
-
export declare const _DYN_SEND_DONE = "sendDone";
|
|
36
|
-
export declare const _DYN_REQUEST_SENT_TIME = "requestSentTime";
|
|
37
|
-
export declare const _DYN_ABORT_DONE = "abortDone";
|
|
38
|
-
export declare const _DYN_GET_TRACE_ID = "getTraceId";
|
|
39
|
-
export declare const _DYN_GET_TRACE_FLAGS = "getTraceFlags";
|
|
40
|
-
export declare const _DYN_METHOD = "method";
|
|
41
|
-
export declare const _DYN_ERROR_STATUS_TEXT = "errorStatusText";
|
|
42
|
-
export declare const _DYN_STATE_CHANGE_ATTACHE13 = "stateChangeAttached";
|
|
43
|
-
export declare const _DYN_RESPONSE_TEXT = "responseText";
|
|
44
|
-
export declare const _DYN_RESPONSE_FINISHED_TI14 = "responseFinishedTime";
|
|
45
|
-
export declare const _DYN__CREATE_TRACK_ITEM = "CreateTrackItem";
|
|
46
|
-
export declare const _DYN_RESPONSE = "response";
|
|
47
|
-
export declare const _DYN_GET_ALL_RESPONSE_HEA15 = "getAllResponseHeaders";
|
|
48
|
-
export declare const _DYN_GET_PART_APROPS = "getPartAProps";
|
|
49
|
-
export declare const _DYN_PERF_MARK = "perfMark";
|
|
50
|
-
export declare const _DYN_NAME = "name";
|
|
51
|
-
export declare const _DYN_PERF_TIMING = "perfTiming";
|
|
52
|
-
export declare const _DYN_EXCEPTION = "exception";
|
|
53
|
-
export declare const _DYN_AJAX_DIAGNOSTICS_MES16 = "ajaxDiagnosticsMessage";
|
|
54
|
-
export declare const _DYN_CORRELATION_CONTEXT = "correlationContext";
|
|
55
|
-
export declare const _DYN_AJAX_TOTAL_DURATION = "ajaxTotalDuration";
|
|
56
|
-
export declare const _DYN_EVENT_TRACE_CTX = "eventTraceCtx";
|