@microsoft/applicationinsights-channel-js 2.8.0-beta.2203-16 → 2.8.0-nightly.2204-05

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.
Files changed (32) hide show
  1. package/browser/applicationinsights-channel-js.integrity.json +9 -9
  2. package/browser/applicationinsights-channel-js.js +555 -680
  3. package/browser/applicationinsights-channel-js.js.map +1 -1
  4. package/browser/applicationinsights-channel-js.min.js +2 -2
  5. package/browser/applicationinsights-channel-js.min.js.map +1 -1
  6. package/dist/applicationinsights-channel-js.api.json +56 -29
  7. package/dist/applicationinsights-channel-js.d.ts +1 -1
  8. package/dist/applicationinsights-channel-js.js +555 -680
  9. package/dist/applicationinsights-channel-js.js.map +1 -1
  10. package/dist/applicationinsights-channel-js.min.js +2 -2
  11. package/dist/applicationinsights-channel-js.min.js.map +1 -1
  12. package/dist/applicationinsights-channel-js.rollup.d.ts +1 -1
  13. package/dist-esm/EnvelopeCreator.js +5 -5
  14. package/dist-esm/EnvelopeCreator.js.map +1 -1
  15. package/dist-esm/Interfaces.js +1 -1
  16. package/dist-esm/Offline.js +1 -1
  17. package/dist-esm/SendBuffer.js +7 -7
  18. package/dist-esm/SendBuffer.js.map +1 -1
  19. package/dist-esm/Sender.js +24 -24
  20. package/dist-esm/Sender.js.map +1 -1
  21. package/dist-esm/Serializer.js +10 -10
  22. package/dist-esm/Serializer.js.map +1 -1
  23. package/dist-esm/TelemetryProcessors/Sample.js +1 -1
  24. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
  25. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
  26. package/dist-esm/applicationinsights-channel-js.js +1 -1
  27. package/package.json +4 -4
  28. package/src/EnvelopeCreator.ts +7 -7
  29. package/src/SendBuffer.ts +14 -14
  30. package/src/Sender.ts +36 -36
  31. package/src/Serializer.ts +13 -13
  32. package/types/tsdoc-metadata.json +1 -1
package/src/Sender.ts CHANGED
@@ -15,11 +15,11 @@ import {
15
15
  } from "@microsoft/applicationinsights-common";
16
16
  import {
17
17
  ITelemetryItem, IProcessTelemetryContext, IConfiguration,
18
- _InternalMessageId, LoggingSeverity, IDiagnosticLogger, IAppInsightsCore, IPlugin,
18
+ _eInternalMessageId, eLoggingSeverity, IDiagnosticLogger, IAppInsightsCore, IPlugin,
19
19
  getWindow, getNavigator, getJSON, BaseTelemetryPlugin, ITelemetryPluginChain, INotificationManager,
20
20
  SendRequestReason, objForEachKey, isNullOrUndefined, arrForEach, dateNow, dumpObj, getExceptionName, getIEVersion, objKeys,
21
21
  isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, isArray, createUniqueNamespace, mergeEvtNamespace,
22
- IProcessTelemetryUnloadContext, ITelemetryUnloadState, _throwInternal, throwError
22
+ IProcessTelemetryUnloadContext, ITelemetryUnloadState, _throwInternal, _warnToConsole
23
23
  } from "@microsoft/applicationinsights-core-js";
24
24
  import { createOfflineListener, IOfflineListener } from "./Offline";
25
25
  import { Sample } from "./TelemetryProcessors/Sample"
@@ -172,8 +172,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
172
172
  try {
173
173
  _self.triggerSend(isAsync, null, sendReason || SendRequestReason.ManualFlush);
174
174
  } catch (e) {
175
- _throwInternal(_self.diagLog(),LoggingSeverity.CRITICAL,
176
- _InternalMessageId.FlushFailed,
175
+ _throwInternal(_self.diagLog(), eLoggingSeverity.CRITICAL,
176
+ _eInternalMessageId.FlushFailed,
177
177
  "flush failed, telemetry will not be collected: " + getExceptionName(e),
178
178
  { exception: dumpObj(e) });
179
179
  }
@@ -186,8 +186,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
186
186
  try {
187
187
  _self.triggerSend(true, _doUnloadSend, SendRequestReason.Unload);
188
188
  } catch (e) {
189
- _throwInternal(_self.diagLog(),LoggingSeverity.CRITICAL,
190
- _InternalMessageId.FailedToSendQueuedTelemetry,
189
+ _throwInternal(_self.diagLog(), eLoggingSeverity.CRITICAL,
190
+ _eInternalMessageId.FailedToSendQueuedTelemetry,
191
191
  "failed to flush with beacon sender on page unload, telemetry will not be collected: " + getExceptionName(e),
192
192
  { exception: dumpObj(e) });
193
193
  }
@@ -203,7 +203,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
203
203
 
204
204
  _self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void => {
205
205
  if (_self.isInitialized()) {
206
- _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender is already initialized");
206
+ _throwInternal(_self.diagLog(), eLoggingSeverity.CRITICAL, _eInternalMessageId.SenderNotInitialized, "Sender is already initialized");
207
207
  }
208
208
 
209
209
  _base.initialize(config, core, extensions, pluginChain);
@@ -230,8 +230,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
230
230
 
231
231
  if(!_validateInstrumentationKey(config)) {
232
232
  _throwInternal(diagLog,
233
- LoggingSeverity.CRITICAL,
234
- _InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key "+config.instrumentationKey);
233
+ eLoggingSeverity.CRITICAL,
234
+ _eInternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key "+config.instrumentationKey);
235
235
  }
236
236
 
237
237
  if (!isInternalApplicationInsightsEndpoint(_self._senderConfig.endpointUrl()) && _self._senderConfig.customHeaders() && _self._senderConfig.customHeaders().length > 0) {
@@ -289,13 +289,13 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
289
289
 
290
290
  // validate input
291
291
  if (!telemetryItem) {
292
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
292
+ _throwInternal(itemCtx.diagLog(), eLoggingSeverity.CRITICAL, _eInternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
293
293
  return;
294
294
  }
295
295
 
296
296
  // validate event
297
297
  if (telemetryItem.baseData && !telemetryItem.baseType) {
298
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
298
+ _throwInternal(itemCtx.diagLog(), eLoggingSeverity.CRITICAL, _eInternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
299
299
  return;
300
300
  }
301
301
 
@@ -306,14 +306,14 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
306
306
 
307
307
  // ensure a sender was constructed
308
308
  if (!_self._sender) {
309
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender was not initialized");
309
+ _throwInternal(itemCtx.diagLog(), eLoggingSeverity.CRITICAL, _eInternalMessageId.SenderNotInitialized, "Sender was not initialized");
310
310
  return;
311
311
  }
312
312
 
313
313
  // check if this item should be sampled in, else add sampleRate tag
314
314
  if (!_isSampledIn(telemetryItem)) {
315
315
  // Item is sampled out, do not send it
316
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TelemetrySampledAndNotSent,
316
+ _throwInternal(itemCtx.diagLog(), eLoggingSeverity.WARNING, _eInternalMessageId.TelemetrySampledAndNotSent,
317
317
  "Telemetry item was sampled out and not sent", { SampleRate: _self._sample.sampleRate });
318
318
  return;
319
319
  } else {
@@ -326,7 +326,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
326
326
  let defaultEnvelopeIkey = telemetryItem.iKey || _self._senderConfig.instrumentationKey();
327
327
  let aiEnvelope = Sender.constructEnvelope(telemetryItem, defaultEnvelopeIkey, itemCtx.diagLog(), convertUndefined);
328
328
  if (!aiEnvelope) {
329
- _throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
329
+ _throwInternal(itemCtx.diagLog(), eLoggingSeverity.CRITICAL, _eInternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
330
330
  return;
331
331
  }
332
332
 
@@ -337,13 +337,13 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
337
337
  try {
338
338
  if (callBack && callBack(aiEnvelope) === false) {
339
339
  doNotSendItem = true;
340
- itemCtx.diagLog().warnToConsole("Telemetry processor check returns false");
340
+ _warnToConsole(itemCtx.diagLog(), "Telemetry processor check returns false");
341
341
  }
342
342
  } catch (e) {
343
343
  // log error but dont stop executing rest of the telemetry initializers
344
344
  // doNotSendItem = true;
345
345
  _throwInternal(itemCtx.diagLog(),
346
- LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e),
346
+ eLoggingSeverity.CRITICAL, _eInternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e),
347
347
  { exception: dumpObj(e) }, true);
348
348
  }
349
349
  });
@@ -373,8 +373,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
373
373
 
374
374
  } catch (e) {
375
375
  _throwInternal(itemCtx.diagLog(),
376
- LoggingSeverity.WARNING,
377
- _InternalMessageId.FailedAddingTelemetryToBuffer,
376
+ eLoggingSeverity.WARNING,
377
+ _eInternalMessageId.FailedAddingTelemetryToBuffer,
378
378
  "Failed adding telemetry to the sender's buffer, some telemetry will be lost: " + getExceptionName(e),
379
379
  { exception: dumpObj(e) });
380
380
  }
@@ -430,8 +430,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
430
430
  let ieVer = getIEVersion();
431
431
  if (!ieVer || ieVer > 9) {
432
432
  _throwInternal(_self.diagLog(),
433
- LoggingSeverity.CRITICAL,
434
- _InternalMessageId.TransmissionFailed,
433
+ eLoggingSeverity.CRITICAL,
434
+ _eInternalMessageId.TransmissionFailed,
435
435
  "Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e),
436
436
  { exception: dumpObj(e) });
437
437
  }
@@ -450,8 +450,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
450
450
  */
451
451
  _self._onError = (payload: string[], message: string, event?: ErrorEvent) => {
452
452
  _throwInternal(_self.diagLog(),
453
- LoggingSeverity.WARNING,
454
- _InternalMessageId.OnError,
453
+ eLoggingSeverity.WARNING,
454
+ _eInternalMessageId.OnError,
455
455
  "Failed to send telemetry.",
456
456
  { message });
457
457
 
@@ -489,8 +489,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
489
489
  _resendPayload(retry);
490
490
 
491
491
  _throwInternal(_self.diagLog(),
492
- LoggingSeverity.WARNING,
493
- _InternalMessageId.TransmissionFailed, "Partial success. " +
492
+ eLoggingSeverity.WARNING,
493
+ _eInternalMessageId.TransmissionFailed, "Partial success. " +
494
494
  "Delivered: " + payload.length + ", Failed: " + failed.length +
495
495
  ". Will retry to send " + retry.length + " our of " + results.itemsReceived + " items");
496
496
  }
@@ -551,8 +551,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
551
551
  if (!_self._senderConfig.isRetryDisabled() && _isRetriable(status)) {
552
552
  _resendPayload(payload);
553
553
  _throwInternal(_self.diagLog(),
554
- LoggingSeverity.WARNING,
555
- _InternalMessageId.TransmissionFailed, ". " +
554
+ eLoggingSeverity.WARNING,
555
+ _eInternalMessageId.TransmissionFailed, ". " +
556
556
  "Response code " + status + ". Will retry to send " + payload.length + " items.");
557
557
  } else {
558
558
  _self._onError(payload, errorMessage);
@@ -564,8 +564,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
564
564
  _resendPayload(payload, offlineBackOffMultiplier);
565
565
 
566
566
  _throwInternal(_self.diagLog(),
567
- LoggingSeverity.WARNING,
568
- _InternalMessageId.TransmissionFailed, `. Offline - Response Code: ${status}. Offline status: ${!_offlineListener.isOnline()}. Will retry to send ${payload.length} items.`);
567
+ eLoggingSeverity.WARNING,
568
+ _eInternalMessageId.TransmissionFailed, `. Offline - Response Code: ${status}. Offline status: ${!_offlineListener.isOnline()}. Will retry to send ${payload.length} items.`);
569
569
  }
570
570
  } else {
571
571
 
@@ -661,7 +661,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
661
661
 
662
662
  if (droppedPayload.length > 0) {
663
663
  _fallbackSender && _fallbackSender(droppedPayload, true);
664
- _throwInternal(_self.diagLog(),LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
664
+ _throwInternal(_self.diagLog(), eLoggingSeverity.WARNING, _eInternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
665
665
  }
666
666
  }
667
667
  }
@@ -718,7 +718,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
718
718
  } else {
719
719
  // Payload is going to be too big so just try and send via XHR
720
720
  _fallbackSender && _fallbackSender(payload, true);
721
- _throwInternal(_self.diagLog(),LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
721
+ _throwInternal(_self.diagLog(), eLoggingSeverity.WARNING, _eInternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
722
722
  }
723
723
  }
724
724
  }
@@ -844,8 +844,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
844
844
  }
845
845
  } catch (e) {
846
846
  _throwInternal(_self.diagLog(),
847
- LoggingSeverity.CRITICAL,
848
- _InternalMessageId.InvalidBackendResponse,
847
+ eLoggingSeverity.CRITICAL,
848
+ _eInternalMessageId.InvalidBackendResponse,
849
849
  "Cannot parse the response. " + getExceptionName(e),
850
850
  {
851
851
  response
@@ -964,8 +964,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
964
964
  const hostingProtocol = _window && _window.location && _window.location.protocol || "";
965
965
  if (_self._senderConfig.endpointUrl().lastIndexOf(hostingProtocol, 0) !== 0) {
966
966
  _throwInternal(_self.diagLog(),
967
- LoggingSeverity.WARNING,
968
- _InternalMessageId.TransmissionFailed, ". " +
967
+ eLoggingSeverity.WARNING,
968
+ _eInternalMessageId.TransmissionFailed, ". " +
969
969
  "Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");
970
970
 
971
971
  buffer.clear();
@@ -1007,8 +1007,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
1007
1007
  try {
1008
1008
  manager.eventsSendRequest(sendRequest, isAsync);
1009
1009
  } catch (e) {
1010
- _throwInternal(_self.diagLog(),LoggingSeverity.CRITICAL,
1011
- _InternalMessageId.NotificationException,
1010
+ _throwInternal(_self.diagLog(), eLoggingSeverity.CRITICAL,
1011
+ _eInternalMessageId.NotificationException,
1012
1012
  "send request notification failed: " + getExceptionName(e),
1013
1013
  { exception: dumpObj(e) });
1014
1014
  }
package/src/Serializer.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ISerializable, FieldType } from "@microsoft/applicationinsights-common";
2
2
  import {
3
- IDiagnosticLogger, LoggingSeverity, _InternalMessageId, getJSON, objForEachKey, isFunction, isObject, isArray
3
+ IDiagnosticLogger, eLoggingSeverity, _eInternalMessageId, getJSON, objForEachKey, isFunction, isObject, isArray, _throwInternal
4
4
  } from "@microsoft/applicationinsights-core-js";
5
5
  import dynamicProto from "@microsoft/dynamicproto-js"
6
6
 
@@ -17,7 +17,7 @@ export class Serializer {
17
17
  return getJSON().stringify(output);
18
18
  } catch (e) {
19
19
  // if serialization fails return an empty string
20
- logger.throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CannotSerializeObject, (e && isFunction(e.toString)) ? e.toString() : "Error serializing object", null, true);
20
+ _throwInternal(logger, eLoggingSeverity.CRITICAL, _eInternalMessageId.CannotSerializeObject, (e && isFunction(e.toString)) ? e.toString() : "Error serializing object", null, true);
21
21
  }
22
22
  }
23
23
 
@@ -26,12 +26,12 @@ export class Serializer {
26
26
  let output = {};
27
27
 
28
28
  if (!source) {
29
- logger.throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CannotSerializeObject, "cannot serialize object because it is null or undefined", { name }, true);
29
+ _throwInternal(logger, eLoggingSeverity.CRITICAL, _eInternalMessageId.CannotSerializeObject, "cannot serialize object because it is null or undefined", { name }, true);
30
30
  return output;
31
31
  }
32
32
 
33
33
  if (source[circularReferenceCheck]) {
34
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CircularReferenceDetected, "Circular reference detected while serializing object", { name }, true);
34
+ _throwInternal(logger, eLoggingSeverity.WARNING, _eInternalMessageId.CircularReferenceDetected, "Circular reference detected while serializing object", { name }, true);
35
35
  return output;
36
36
  }
37
37
 
@@ -46,7 +46,7 @@ export class Serializer {
46
46
  } else if (isArray(source)) {
47
47
  output = _serializeArray(source as any, name);
48
48
  } else {
49
- logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotSerializeObjectNonSerializable, "Attempting to serialize an object which does not implement ISerializable", { name }, true);
49
+ _throwInternal(logger, eLoggingSeverity.WARNING, _eInternalMessageId.CannotSerializeObjectNonSerializable, "Attempting to serialize an object which does not implement ISerializable", { name }, true);
50
50
 
51
51
  try {
52
52
  // verify that the object can be stringified
@@ -54,7 +54,7 @@ export class Serializer {
54
54
  output = source;
55
55
  } catch (e) {
56
56
  // if serialization fails return an empty string
57
- logger.throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.CannotSerializeObject, (e && isFunction(e.toString)) ? e.toString() : "Error serializing object", null, true);
57
+ _throwInternal(logger, eLoggingSeverity.CRITICAL, _eInternalMessageId.CannotSerializeObject, (e && isFunction(e.toString)) ? e.toString() : "Error serializing object", null, true);
58
58
  }
59
59
  }
60
60
 
@@ -71,9 +71,9 @@ export class Serializer {
71
71
  const isObj = isObject(source[field]) && source[field] !== null;
72
72
 
73
73
  if (isRequired && !isPresent && !isArray) {
74
- logger.throwInternal(
75
- LoggingSeverity.CRITICAL,
76
- _InternalMessageId.MissingRequiredFieldSpecification,
74
+ _throwInternal(logger,
75
+ eLoggingSeverity.CRITICAL,
76
+ _eInternalMessageId.MissingRequiredFieldSpecification,
77
77
  "Missing required field specification. The field is required but not present on source",
78
78
  { field, name });
79
79
 
@@ -109,9 +109,9 @@ export class Serializer {
109
109
 
110
110
  if (!!sources) {
111
111
  if (!isArray(sources)) {
112
- logger.throwInternal(
113
- LoggingSeverity.CRITICAL,
114
- _InternalMessageId.ItemNotInArray,
112
+ _throwInternal(logger,
113
+ eLoggingSeverity.CRITICAL,
114
+ _eInternalMessageId.ItemNotInArray,
115
115
  "This field was specified as an array in the contract but the item is not an array.\r\n",
116
116
  { name }, true);
117
117
  } else {
@@ -157,7 +157,7 @@ export class Serializer {
157
157
  }
158
158
  } else {
159
159
  output[field] = "invalid field: " + name + " is of unknown type.";
160
- logger.throwInternal(LoggingSeverity.CRITICAL, output[field], null, true);
160
+ _throwInternal(logger, eLoggingSeverity.CRITICAL, output[field], null, true);
161
161
  }
162
162
  });
163
163
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.19.5"
8
+ "packageVersion": "7.20.0"
9
9
  }
10
10
  ]
11
11
  }