@microsoft/applicationinsights-channel-js 2.7.5-nightly.2204-03 → 2.7.6
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-channel-js.integrity.json +9 -9
- package/browser/applicationinsights-channel-js.js +446 -1218
- package/browser/applicationinsights-channel-js.js.map +1 -1
- package/browser/applicationinsights-channel-js.min.js +2 -2
- package/browser/applicationinsights-channel-js.min.js.map +1 -1
- package/dist/applicationinsights-channel-js.api.json +89 -32
- package/dist/applicationinsights-channel-js.api.md +2 -0
- package/dist/applicationinsights-channel-js.d.ts +2 -1
- package/dist/applicationinsights-channel-js.js +446 -1218
- package/dist/applicationinsights-channel-js.js.map +1 -1
- package/dist/applicationinsights-channel-js.min.js +2 -2
- package/dist/applicationinsights-channel-js.min.js.map +1 -1
- package/dist/applicationinsights-channel-js.rollup.d.ts +2 -1
- package/dist-esm/EnvelopeCreator.js +2 -2
- package/dist-esm/EnvelopeCreator.js.map +1 -1
- package/dist-esm/Interfaces.js +1 -1
- package/dist-esm/Offline.js +65 -77
- package/dist-esm/Offline.js.map +1 -1
- package/dist-esm/SendBuffer.js +1 -1
- package/dist-esm/Sender.js +62 -72
- package/dist-esm/Sender.js.map +1 -1
- package/dist-esm/Serializer.js +1 -1
- package/dist-esm/TelemetryProcessors/Sample.js +3 -3
- package/dist-esm/TelemetryProcessors/Sample.js.map +1 -1
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
- package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
- package/dist-esm/applicationinsights-channel-js.js +1 -1
- package/package.json +54 -57
- package/src/EnvelopeCreator.ts +2 -2
- package/src/Offline.ts +76 -88
- package/src/Sender.ts +90 -83
- package/src/Serializer.ts +8 -4
- package/src/TelemetryProcessors/Sample.ts +1 -1
- package/src/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.ts +1 -3
- package/types/Offline.d.ts +11 -8
- package/types/Sender.d.ts +1 -0
- package/types/TelemetryProcessors/Sample.d.ts +2 -2
- package/types/tsdoc-metadata.json +1 -1
package/src/Sender.ts
CHANGED
|
@@ -17,11 +17,10 @@ import {
|
|
|
17
17
|
ITelemetryItem, IProcessTelemetryContext, IConfiguration,
|
|
18
18
|
_InternalMessageId, LoggingSeverity, IDiagnosticLogger, IAppInsightsCore, IPlugin,
|
|
19
19
|
getWindow, getNavigator, getJSON, BaseTelemetryPlugin, ITelemetryPluginChain, INotificationManager,
|
|
20
|
-
SendRequestReason, objForEachKey, isNullOrUndefined, arrForEach, dateNow, dumpObj, getExceptionName, getIEVersion, objKeys,
|
|
21
|
-
isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, isArray
|
|
22
|
-
IProcessTelemetryUnloadContext, ITelemetryUnloadState, _throwInternal, throwError
|
|
20
|
+
SendRequestReason, objForEachKey, isNullOrUndefined, arrForEach, dateNow, dumpObj, getExceptionName, getIEVersion, throwError, objKeys,
|
|
21
|
+
isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, isArray
|
|
23
22
|
} from "@microsoft/applicationinsights-core-js";
|
|
24
|
-
import {
|
|
23
|
+
import { Offline } from "./Offline";
|
|
25
24
|
import { Sample } from "./TelemetryProcessors/Sample"
|
|
26
25
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
27
26
|
|
|
@@ -104,7 +103,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
104
103
|
/**
|
|
105
104
|
* The configuration for this sender instance
|
|
106
105
|
*/
|
|
107
|
-
public readonly _senderConfig: ISenderConfig
|
|
106
|
+
public readonly _senderConfig: ISenderConfig;
|
|
108
107
|
|
|
109
108
|
/**
|
|
110
109
|
* A method which will cause data to be send to the url
|
|
@@ -126,24 +125,57 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
126
125
|
constructor() {
|
|
127
126
|
super();
|
|
128
127
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
let
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
/**
|
|
129
|
+
* How many times in a row a retryable error condition has occurred.
|
|
130
|
+
*/
|
|
131
|
+
let _consecutiveErrors: number;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The time to retry at in milliseconds from 1970/01/01 (this makes the timer calculation easy).
|
|
135
|
+
*/
|
|
136
|
+
let _retryAt: number;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The time of the last send operation.
|
|
140
|
+
*/
|
|
141
|
+
let _lastSend: number;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Flag indicating that the sending should be paused
|
|
145
|
+
*/
|
|
146
|
+
let _paused = false;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Handle to the timer for delayed sending of batches of data.
|
|
150
|
+
*/
|
|
151
|
+
let _timeoutHandle: any;
|
|
152
|
+
|
|
135
153
|
let _serializer: Serializer;
|
|
154
|
+
|
|
136
155
|
let _stamp_specific_redirects: number;
|
|
137
|
-
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let
|
|
142
|
-
|
|
156
|
+
|
|
157
|
+
let _headers: { [name: string]: string } = {};
|
|
158
|
+
|
|
159
|
+
// Keep track of the outstanding sync fetch payload total (as sync fetch has limits)
|
|
160
|
+
let _syncFetchPayload = 0;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The sender to use if the payload size is too large
|
|
164
|
+
*/
|
|
165
|
+
let _fallbackSender: SenderFunction;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The identified sender to use for the synchronous unload stage
|
|
169
|
+
*/
|
|
170
|
+
let _syncUnloadSender: SenderFunction;
|
|
171
|
+
|
|
172
|
+
this._senderConfig = _getDefaultAppInsightsChannelConfig();
|
|
143
173
|
|
|
144
174
|
dynamicProto(Sender, this, (_self, _base) => {
|
|
145
175
|
|
|
146
|
-
|
|
176
|
+
function _notImplemented() {
|
|
177
|
+
throwError("Method not implemented.");
|
|
178
|
+
}
|
|
147
179
|
|
|
148
180
|
_self.pause = () => {
|
|
149
181
|
_clearScheduledTimer();
|
|
@@ -164,15 +196,15 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
164
196
|
}
|
|
165
197
|
};
|
|
166
198
|
|
|
167
|
-
_self.flush = (
|
|
199
|
+
_self.flush = () => {
|
|
168
200
|
if (!_paused) {
|
|
169
201
|
// Clear the normal schedule timer as we are going to try and flush ASAP
|
|
170
202
|
_clearScheduledTimer();
|
|
171
203
|
|
|
172
204
|
try {
|
|
173
|
-
_self.triggerSend(
|
|
205
|
+
_self.triggerSend(true, null, SendRequestReason.ManualFlush);
|
|
174
206
|
} catch (e) {
|
|
175
|
-
|
|
207
|
+
_self.diagLog().throwInternal(LoggingSeverity.CRITICAL,
|
|
176
208
|
_InternalMessageId.FlushFailed,
|
|
177
209
|
"flush failed, telemetry will not be collected: " + getExceptionName(e),
|
|
178
210
|
{ exception: dumpObj(e) });
|
|
@@ -186,7 +218,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
186
218
|
try {
|
|
187
219
|
_self.triggerSend(true, _doUnloadSend, SendRequestReason.Unload);
|
|
188
220
|
} catch (e) {
|
|
189
|
-
|
|
221
|
+
_self.diagLog().throwInternal(LoggingSeverity.CRITICAL,
|
|
190
222
|
_InternalMessageId.FailedToSendQueuedTelemetry,
|
|
191
223
|
"failed to flush with beacon sender on page unload, telemetry will not be collected: " + getExceptionName(e),
|
|
192
224
|
{ exception: dumpObj(e) });
|
|
@@ -197,15 +229,13 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
197
229
|
}
|
|
198
230
|
};
|
|
199
231
|
|
|
232
|
+
_self.teardown = _notImplemented;
|
|
233
|
+
|
|
200
234
|
_self.addHeader = (name: string, value: string) => {
|
|
201
235
|
_headers[name] = value;
|
|
202
236
|
};
|
|
203
237
|
|
|
204
238
|
_self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void => {
|
|
205
|
-
if (_self.isInitialized()) {
|
|
206
|
-
_throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender is already initialized");
|
|
207
|
-
}
|
|
208
|
-
|
|
209
239
|
_base.initialize(config, core, extensions, pluginChain);
|
|
210
240
|
let ctx = _self._getTelCtx();
|
|
211
241
|
let identifier = _self.identifier;
|
|
@@ -216,8 +246,6 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
216
246
|
_self._sender = null;
|
|
217
247
|
_stamp_specific_redirects = 0;
|
|
218
248
|
let diagLog = _self.diagLog();
|
|
219
|
-
_evtNamespace = mergeEvtNamespace(createUniqueNamespace("Sender"), core.evtNamespace && core.evtNamespace());
|
|
220
|
-
_offlineListener = createOfflineListener(_evtNamespace);
|
|
221
249
|
|
|
222
250
|
const defaultConfig = _getDefaultAppInsightsChannelConfig();
|
|
223
251
|
objForEachKey(defaultConfig, (field, value) => {
|
|
@@ -229,7 +257,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
229
257
|
_self._sample = new Sample(_self._senderConfig.samplingPercentage(), diagLog);
|
|
230
258
|
|
|
231
259
|
if(!_validateInstrumentationKey(config)) {
|
|
232
|
-
|
|
260
|
+
diagLog.throwInternal(
|
|
233
261
|
LoggingSeverity.CRITICAL,
|
|
234
262
|
_InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key "+config.instrumentationKey);
|
|
235
263
|
}
|
|
@@ -289,13 +317,13 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
289
317
|
|
|
290
318
|
// validate input
|
|
291
319
|
if (!telemetryItem) {
|
|
292
|
-
|
|
320
|
+
itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
|
|
293
321
|
return;
|
|
294
322
|
}
|
|
295
323
|
|
|
296
324
|
// validate event
|
|
297
325
|
if (telemetryItem.baseData && !telemetryItem.baseType) {
|
|
298
|
-
|
|
326
|
+
itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
|
|
299
327
|
return;
|
|
300
328
|
}
|
|
301
329
|
|
|
@@ -306,14 +334,14 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
306
334
|
|
|
307
335
|
// ensure a sender was constructed
|
|
308
336
|
if (!_self._sender) {
|
|
309
|
-
|
|
337
|
+
itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender was not initialized");
|
|
310
338
|
return;
|
|
311
339
|
}
|
|
312
340
|
|
|
313
341
|
// check if this item should be sampled in, else add sampleRate tag
|
|
314
342
|
if (!_isSampledIn(telemetryItem)) {
|
|
315
343
|
// Item is sampled out, do not send it
|
|
316
|
-
|
|
344
|
+
itemCtx.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TelemetrySampledAndNotSent,
|
|
317
345
|
"Telemetry item was sampled out and not sent", { SampleRate: _self._sample.sampleRate });
|
|
318
346
|
return;
|
|
319
347
|
} else {
|
|
@@ -326,7 +354,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
326
354
|
let defaultEnvelopeIkey = telemetryItem.iKey || _self._senderConfig.instrumentationKey();
|
|
327
355
|
let aiEnvelope = Sender.constructEnvelope(telemetryItem, defaultEnvelopeIkey, itemCtx.diagLog(), convertUndefined);
|
|
328
356
|
if (!aiEnvelope) {
|
|
329
|
-
|
|
357
|
+
itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
|
|
330
358
|
return;
|
|
331
359
|
}
|
|
332
360
|
|
|
@@ -342,7 +370,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
342
370
|
} catch (e) {
|
|
343
371
|
// log error but dont stop executing rest of the telemetry initializers
|
|
344
372
|
// doNotSendItem = true;
|
|
345
|
-
|
|
373
|
+
itemCtx.diagLog().throwInternal(
|
|
346
374
|
LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e),
|
|
347
375
|
{ exception: dumpObj(e) }, true);
|
|
348
376
|
}
|
|
@@ -372,7 +400,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
372
400
|
_setupTimer();
|
|
373
401
|
|
|
374
402
|
} catch (e) {
|
|
375
|
-
|
|
403
|
+
itemCtx.diagLog().throwInternal(
|
|
376
404
|
LoggingSeverity.WARNING,
|
|
377
405
|
_InternalMessageId.FailedAddingTelemetryToBuffer,
|
|
378
406
|
"Failed adding telemetry to the sender's buffer, some telemetry will be lost: " + getExceptionName(e),
|
|
@@ -429,7 +457,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
429
457
|
/* Ignore this error for IE under v10 */
|
|
430
458
|
let ieVer = getIEVersion();
|
|
431
459
|
if (!ieVer || ieVer > 9) {
|
|
432
|
-
|
|
460
|
+
_self.diagLog().throwInternal(
|
|
433
461
|
LoggingSeverity.CRITICAL,
|
|
434
462
|
_InternalMessageId.TransmissionFailed,
|
|
435
463
|
"Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e),
|
|
@@ -439,17 +467,11 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
439
467
|
}
|
|
440
468
|
};
|
|
441
469
|
|
|
442
|
-
_self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => {
|
|
443
|
-
_self.onunloadFlush();
|
|
444
|
-
_offlineListener.unload();
|
|
445
|
-
_initDefaults();
|
|
446
|
-
};
|
|
447
|
-
|
|
448
470
|
/**
|
|
449
471
|
* error handler
|
|
450
472
|
*/
|
|
451
473
|
_self._onError = (payload: string[], message: string, event?: ErrorEvent) => {
|
|
452
|
-
|
|
474
|
+
_self.diagLog().throwInternal(
|
|
453
475
|
LoggingSeverity.WARNING,
|
|
454
476
|
_InternalMessageId.OnError,
|
|
455
477
|
"Failed to send telemetry.",
|
|
@@ -488,7 +510,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
488
510
|
if (retry.length > 0) {
|
|
489
511
|
_resendPayload(retry);
|
|
490
512
|
|
|
491
|
-
|
|
513
|
+
_self.diagLog().throwInternal(
|
|
492
514
|
LoggingSeverity.WARNING,
|
|
493
515
|
_InternalMessageId.TransmissionFailed, "Partial success. " +
|
|
494
516
|
"Delivered: " + payload.length + ", Failed: " + failed.length +
|
|
@@ -550,22 +572,22 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
550
572
|
|
|
551
573
|
if (!_self._senderConfig.isRetryDisabled() && _isRetriable(status)) {
|
|
552
574
|
_resendPayload(payload);
|
|
553
|
-
|
|
575
|
+
_self.diagLog().throwInternal(
|
|
554
576
|
LoggingSeverity.WARNING,
|
|
555
577
|
_InternalMessageId.TransmissionFailed, ". " +
|
|
556
578
|
"Response code " + status + ". Will retry to send " + payload.length + " items.");
|
|
557
579
|
} else {
|
|
558
580
|
_self._onError(payload, errorMessage);
|
|
559
581
|
}
|
|
560
|
-
} else if (
|
|
582
|
+
} else if (Offline.isOffline()) { // offline
|
|
561
583
|
// Note: Don't check for status == 0, since adblock gives this code
|
|
562
584
|
if (!_self._senderConfig.isRetryDisabled()) {
|
|
563
585
|
const offlineBackOffMultiplier = 10; // arbritrary number
|
|
564
586
|
_resendPayload(payload, offlineBackOffMultiplier);
|
|
565
587
|
|
|
566
|
-
|
|
588
|
+
_self.diagLog().throwInternal(
|
|
567
589
|
LoggingSeverity.WARNING,
|
|
568
|
-
_InternalMessageId.TransmissionFailed, `. Offline - Response Code: ${status}. Offline status: ${
|
|
590
|
+
_InternalMessageId.TransmissionFailed, `. Offline - Response Code: ${status}. Offline status: ${Offline.isOffline()}. Will retry to send ${payload.length} items.`);
|
|
569
591
|
}
|
|
570
592
|
} else {
|
|
571
593
|
|
|
@@ -592,9 +614,9 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
592
614
|
|
|
593
615
|
function _checkAndUpdateEndPointUrl(responseUrl: string) {
|
|
594
616
|
// Maximum stamp specific redirects allowed(uncomment this when breeze is ready with not allowing redirects feature)
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
617
|
+
if(_stamp_specific_redirects >= 10) {
|
|
618
|
+
// _self._senderConfig.endpointUrl = () => Sender._getDefaultAppInsightsChannelConfig().endpointUrl()+"/?redirect=false";
|
|
619
|
+
// _stamp_specific_redirects = 0;
|
|
598
620
|
return false;
|
|
599
621
|
}
|
|
600
622
|
if(!isNullOrUndefined(responseUrl) && responseUrl !== "") {
|
|
@@ -660,8 +682,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
660
682
|
}
|
|
661
683
|
|
|
662
684
|
if (droppedPayload.length > 0) {
|
|
663
|
-
_fallbackSender
|
|
664
|
-
|
|
685
|
+
_fallbackSender(droppedPayload, true);
|
|
686
|
+
_self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
|
|
665
687
|
}
|
|
666
688
|
}
|
|
667
689
|
}
|
|
@@ -718,7 +740,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
718
740
|
} else {
|
|
719
741
|
// Payload is going to be too big so just try and send via XHR
|
|
720
742
|
_fallbackSender && _fallbackSender(payload, true);
|
|
721
|
-
|
|
743
|
+
_self.diagLog().throwInternal(LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
|
|
722
744
|
}
|
|
723
745
|
}
|
|
724
746
|
}
|
|
@@ -728,16 +750,16 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
728
750
|
* @param payload {string} - The data payload to be sent.
|
|
729
751
|
* @param isAsync {boolean} - not used
|
|
730
752
|
*/
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
753
|
+
function _fetchSender(payload: string[], isAsync: boolean) {
|
|
754
|
+
_doFetchSender(payload, true);
|
|
755
|
+
}
|
|
734
756
|
|
|
735
757
|
/**
|
|
736
758
|
* Send fetch API request
|
|
737
759
|
* @param payload {string} - The data payload to be sent.
|
|
738
760
|
* @param isAsync {boolean} - For fetch this identifies whether we are "unloading" (false) or a normal request
|
|
739
761
|
*/
|
|
740
|
-
|
|
762
|
+
function _doFetchSender(payload: string[], isAsync: boolean) {
|
|
741
763
|
const endPointUrl = _self._senderConfig.endpointUrl();
|
|
742
764
|
const batch = _self._buffer.batchPayloads(payload);
|
|
743
765
|
const plainTextBatch = new Blob([batch], { type: "application/json" });
|
|
@@ -843,7 +865,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
843
865
|
}
|
|
844
866
|
}
|
|
845
867
|
} catch (e) {
|
|
846
|
-
|
|
868
|
+
_self.diagLog().throwInternal(
|
|
847
869
|
LoggingSeverity.CRITICAL,
|
|
848
870
|
_InternalMessageId.InvalidBackendResponse,
|
|
849
871
|
"Cannot parse the response. " + getExceptionName(e),
|
|
@@ -963,12 +985,12 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
963
985
|
// If the protocol doesn't match, we can't send the telemetry :(.
|
|
964
986
|
const hostingProtocol = _window && _window.location && _window.location.protocol || "";
|
|
965
987
|
if (_self._senderConfig.endpointUrl().lastIndexOf(hostingProtocol, 0) !== 0) {
|
|
966
|
-
|
|
988
|
+
_self.diagLog().throwInternal(
|
|
967
989
|
LoggingSeverity.WARNING,
|
|
968
990
|
_InternalMessageId.TransmissionFailed, ". " +
|
|
969
991
|
"Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");
|
|
970
992
|
|
|
971
|
-
|
|
993
|
+
buffer.clear();
|
|
972
994
|
return;
|
|
973
995
|
}
|
|
974
996
|
|
|
@@ -1007,7 +1029,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
1007
1029
|
try {
|
|
1008
1030
|
manager.eventsSendRequest(sendRequest, isAsync);
|
|
1009
1031
|
} catch (e) {
|
|
1010
|
-
|
|
1032
|
+
_self.diagLog().throwInternal(LoggingSeverity.CRITICAL,
|
|
1011
1033
|
_InternalMessageId.NotificationException,
|
|
1012
1034
|
"send request notification failed: " + getExceptionName(e),
|
|
1013
1035
|
{ exception: dumpObj(e) });
|
|
@@ -1029,25 +1051,6 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
1029
1051
|
return regexp.test(config.instrumentationKey);
|
|
1030
1052
|
}
|
|
1031
1053
|
|
|
1032
|
-
function _initDefaults() {
|
|
1033
|
-
_self._sender = null;
|
|
1034
|
-
_self._buffer = null;
|
|
1035
|
-
_self._appId = null;
|
|
1036
|
-
_self._sample = null;
|
|
1037
|
-
_headers = {};
|
|
1038
|
-
_offlineListener = null;
|
|
1039
|
-
_consecutiveErrors = 0;
|
|
1040
|
-
_retryAt = null;
|
|
1041
|
-
_lastSend = null;
|
|
1042
|
-
_paused = false;
|
|
1043
|
-
_timeoutHandle = null;
|
|
1044
|
-
_serializer = null;
|
|
1045
|
-
_stamp_specific_redirects = 0;
|
|
1046
|
-
_syncFetchPayload = 0;
|
|
1047
|
-
_fallbackSender = null;
|
|
1048
|
-
_syncUnloadSender = null;
|
|
1049
|
-
_evtNamespace = null;
|
|
1050
|
-
}
|
|
1051
1054
|
});
|
|
1052
1055
|
}
|
|
1053
1056
|
|
|
@@ -1085,6 +1088,10 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
1085
1088
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1086
1089
|
}
|
|
1087
1090
|
|
|
1091
|
+
public teardown(): void {
|
|
1092
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1088
1095
|
public initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void {
|
|
1089
1096
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
1090
1097
|
}
|
|
@@ -1142,7 +1149,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
|
|
|
1142
1149
|
* @param name - Header name.
|
|
1143
1150
|
* @param value - Header value.
|
|
1144
1151
|
*/
|
|
1145
|
-
|
|
1152
|
+
public addHeader(name: string, value: string) {
|
|
1146
1153
|
// @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
|
|
1147
1154
|
}
|
|
1148
1155
|
}
|
package/src/Serializer.ts
CHANGED
|
@@ -139,10 +139,12 @@ export class Serializer {
|
|
|
139
139
|
output[field] = "null";
|
|
140
140
|
} else if (!value.toString) {
|
|
141
141
|
output[field] = "invalid field: toString() is not defined.";
|
|
142
|
-
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
143
144
|
output[field] = value.toString();
|
|
144
145
|
}
|
|
145
|
-
}
|
|
146
|
+
}
|
|
147
|
+
else if (expectedType === "number") {
|
|
146
148
|
if (value === undefined) {
|
|
147
149
|
output[field] = "undefined";
|
|
148
150
|
} else if (value === null) {
|
|
@@ -151,11 +153,13 @@ export class Serializer {
|
|
|
151
153
|
const num = parseFloat(value);
|
|
152
154
|
if (isNaN(num)) {
|
|
153
155
|
output[field] = "NaN";
|
|
154
|
-
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
155
158
|
output[field] = num;
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
|
-
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
159
163
|
output[field] = "invalid field: " + name + " is of unknown type.";
|
|
160
164
|
logger.throwInternal(LoggingSeverity.CRITICAL, output[field], null, true);
|
|
161
165
|
}
|
|
@@ -27,7 +27,7 @@ export class Sample implements ISample {
|
|
|
27
27
|
this.samplingScoreGenerator = new SamplingScoreGenerator();
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
31
|
* Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).
|
|
32
32
|
*/
|
|
33
33
|
public isSampledIn(envelope: ITelemetryItem): boolean {
|
package/types/Offline.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export interface IOfflineListener {
|
|
2
|
-
isOnline: () => boolean;
|
|
3
|
-
isListening: () => boolean;
|
|
4
|
-
unload: () => void;
|
|
5
|
-
}
|
|
6
1
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
2
|
+
* @description Monitors browser for offline events
|
|
3
|
+
* @export default - Offline: Static instance of OfflineListener
|
|
4
|
+
* @class OfflineListener
|
|
9
5
|
*/
|
|
10
|
-
export declare
|
|
6
|
+
export declare class OfflineListener {
|
|
7
|
+
static Offline: OfflineListener;
|
|
8
|
+
isListening: boolean;
|
|
9
|
+
constructor();
|
|
10
|
+
isOnline(): boolean;
|
|
11
|
+
isOffline(): boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const Offline: OfflineListener;
|
package/types/Sender.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare class Sender extends BaseTelemetryPlugin implements IChannelContr
|
|
|
47
47
|
* Will not flush if the Send has been paused.
|
|
48
48
|
*/
|
|
49
49
|
onunloadFlush(): void;
|
|
50
|
+
teardown(): void;
|
|
50
51
|
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
51
52
|
processTelemetry(telemetryItem: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
52
53
|
/**
|
|
@@ -6,7 +6,7 @@ export declare class Sample implements ISample {
|
|
|
6
6
|
private samplingScoreGenerator;
|
|
7
7
|
constructor(sampleRate: number, logger?: IDiagnosticLogger);
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
* Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).
|
|
10
|
+
*/
|
|
11
11
|
isSampledIn(envelope: ITelemetryItem): boolean;
|
|
12
12
|
}
|