@microsoft/applicationinsights-channel-js 3.0.1-nightly3.2304-38 → 3.0.1-nightly3.2304-44

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 (56) hide show
  1. package/browser/es5/{applicationinsights-channel-js.3.0.1-nightly3.2304-38.cjs.js → applicationinsights-channel-js.3.0.1-nightly3.2304-44.cjs.js} +432 -52
  2. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.cjs.js.map +1 -0
  3. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.cjs.min.js +6 -0
  4. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.cjs.min.js.map +1 -0
  5. package/browser/es5/{applicationinsights-channel-js.3.0.1-nightly3.2304-38.gbl.js → applicationinsights-channel-js.3.0.1-nightly3.2304-44.gbl.js} +432 -52
  6. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.gbl.js.map +1 -0
  7. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.gbl.min.js +6 -0
  8. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.gbl.min.js.map +1 -0
  9. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.integrity.json +66 -0
  10. package/browser/es5/{applicationinsights-channel-js.3.0.1-nightly3.2304-38.js → applicationinsights-channel-js.3.0.1-nightly3.2304-44.js} +432 -52
  11. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.js.map +1 -0
  12. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.min.js +6 -0
  13. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-44.min.js.map +1 -0
  14. package/browser/es5/applicationinsights-channel-js.3.cjs.js +431 -51
  15. package/browser/es5/applicationinsights-channel-js.3.cjs.js.map +1 -1
  16. package/browser/es5/applicationinsights-channel-js.3.cjs.min.js +2 -2
  17. package/browser/es5/applicationinsights-channel-js.3.cjs.min.js.map +1 -1
  18. package/browser/es5/applicationinsights-channel-js.3.gbl.js +431 -51
  19. package/browser/es5/applicationinsights-channel-js.3.gbl.js.map +1 -1
  20. package/browser/es5/applicationinsights-channel-js.3.gbl.min.js +2 -2
  21. package/browser/es5/applicationinsights-channel-js.3.gbl.min.js.map +1 -1
  22. package/browser/es5/applicationinsights-channel-js.3.js +431 -51
  23. package/browser/es5/applicationinsights-channel-js.3.js.map +1 -1
  24. package/browser/es5/applicationinsights-channel-js.3.min.js +2 -2
  25. package/browser/es5/applicationinsights-channel-js.3.min.js.map +1 -1
  26. package/dist/es5/applicationinsights-channel-js.js +431 -51
  27. package/dist/es5/applicationinsights-channel-js.js.map +1 -1
  28. package/dist/es5/applicationinsights-channel-js.min.js +2 -2
  29. package/dist/es5/applicationinsights-channel-js.min.js.map +1 -1
  30. package/dist-es5/EnvelopeCreator.js +2 -2
  31. package/dist-es5/EnvelopeCreator.js.map +1 -1
  32. package/dist-es5/Interfaces.js +1 -1
  33. package/dist-es5/InternalConstants.js +1 -1
  34. package/dist-es5/Offline.js +1 -1
  35. package/dist-es5/SendBuffer.js +1 -1
  36. package/dist-es5/Sender.js +66 -31
  37. package/dist-es5/Sender.js.map +1 -1
  38. package/dist-es5/Serializer.js +1 -1
  39. package/dist-es5/TelemetryProcessors/Sample.js +1 -1
  40. package/dist-es5/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
  41. package/dist-es5/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
  42. package/dist-es5/__DynamicConstants.js +1 -1
  43. package/dist-es5/applicationinsights-channel-js.js +1 -1
  44. package/package.json +5 -4
  45. package/types/applicationinsights-channel-js.d.ts +35 -9
  46. package/types/applicationinsights-channel-js.namespaced.d.ts +35 -9
  47. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.cjs.js.map +0 -1
  48. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.cjs.min.js +0 -6
  49. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.cjs.min.js.map +0 -1
  50. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.gbl.js.map +0 -1
  51. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.gbl.min.js +0 -6
  52. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.gbl.min.js.map +0 -1
  53. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.integrity.json +0 -66
  54. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.js.map +0 -1
  55. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.min.js +0 -6
  56. package/browser/es5/applicationinsights-channel-js.3.0.1-nightly3.2304-38.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Channel, 3.0.1-nightly3.2304-38
2
+ * Application Insights JavaScript SDK - Channel, 3.0.1-nightly3.2304-44
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  this.Microsoft = this.Microsoft || {};
@@ -39,7 +39,7 @@ this.Microsoft = this.Microsoft || {};
39
39
  var ArrCls = Array;
40
40
  var ArrProto = ArrCls[PROTOTYPE];
41
41
 
42
- function _safeGet(cb, defValue) {
42
+ function safeGet(cb, defValue) {
43
43
  var result = defValue;
44
44
  try {
45
45
  result = cb();
@@ -87,8 +87,11 @@ this.Microsoft = this.Microsoft || {};
87
87
  var isNumber = _createIs(NUMBER);
88
88
  var isBoolean = _createIs(BOOLEAN);
89
89
  var isError = _createObjIs("Error");
90
+ function isPromiseLike(value) {
91
+ return !!value && isFunction(value.then);
92
+ }
90
93
  function isTruthy(value) {
91
- return !(!value || _safeGet(function () { return !(value && (0 + value)); }, !value));
94
+ return !(!value || safeGet(function () { return !(value && (0 + value)); }, !value));
92
95
  }
93
96
 
94
97
  var objGetOwnPropertyDescriptor = ObjClass.getOwnPropertyDescriptor;
@@ -356,8 +359,8 @@ this.Microsoft = this.Microsoft || {};
356
359
  return lazyValue;
357
360
  }
358
361
 
359
- function _lazySafeGet(cb, defValue) {
360
- return getLazy(function () { return _safeGet(cb, defValue); });
362
+ function safeGetLazy(cb, defValue) {
363
+ return getLazy(function () { return safeGet(cb, defValue); });
361
364
  }
362
365
 
363
366
  var WINDOW = "window";
@@ -365,11 +368,12 @@ this.Microsoft = this.Microsoft || {};
365
368
  var _cachedWindow;
366
369
  var _cachedDocument;
367
370
  var _cachedNavigator;
368
- function _lazySafeGetInst(name) {
369
- return _lazySafeGet(function () { return getInst(name) || UNDEF_VALUE; }, UNDEF_VALUE);
371
+ var _isNode;
372
+ function lazySafeGetInst(name) {
373
+ return safeGetLazy(function () { return getInst(name) || UNDEF_VALUE; }, UNDEF_VALUE);
370
374
  }
371
375
  function getGlobal(useCached) {
372
- (!_cachedGlobal || useCached === false || (_globalLazyTestHooks.lzy && !_cachedGlobal.b)) && (_cachedGlobal = _lazySafeGet(_getGlobalValue, null));
376
+ (!_cachedGlobal || useCached === false || (_globalLazyTestHooks.lzy && !_cachedGlobal.b)) && (_cachedGlobal = safeGetLazy(_getGlobalValue, null));
373
377
  return _cachedGlobal.v;
374
378
  }
375
379
  function getInst(name, useCached) {
@@ -383,35 +387,42 @@ this.Microsoft = this.Microsoft || {};
383
387
  return null;
384
388
  }
385
389
  function getDocument() {
386
- (!_cachedDocument || (_globalLazyTestHooks.lzy && !_cachedDocument.b)) && (_cachedDocument = _lazySafeGetInst("document"));
390
+ (!_cachedDocument || (_globalLazyTestHooks.lzy && !_cachedDocument.b)) && (_cachedDocument = lazySafeGetInst("document"));
387
391
  return _cachedDocument.v;
388
392
  }
389
393
  function hasWindow() {
390
394
  return !!getWindow();
391
395
  }
392
396
  function getWindow() {
393
- (!_cachedWindow || (_globalLazyTestHooks.lzy && !_cachedWindow.b)) && (_cachedWindow = _lazySafeGetInst(WINDOW));
397
+ (!_cachedWindow || (_globalLazyTestHooks.lzy && !_cachedWindow.b)) && (_cachedWindow = lazySafeGetInst(WINDOW));
394
398
  return _cachedWindow.v;
395
399
  }
396
400
  function hasNavigator() {
397
401
  return !!getNavigator();
398
402
  }
399
403
  function getNavigator() {
400
- (!_cachedNavigator || (_globalLazyTestHooks.lzy && !_cachedNavigator.b)) && (_cachedNavigator = _lazySafeGetInst("navigator"));
404
+ (!_cachedNavigator || (_globalLazyTestHooks.lzy && !_cachedNavigator.b)) && (_cachedNavigator = lazySafeGetInst("navigator"));
401
405
  return _cachedNavigator.v;
402
406
  }
407
+ function isNode() {
408
+ !_isNode && (_isNode = safeGetLazy(function () { return !!(process && (process.versions || {}).node); }, false));
409
+ return _isNode.v;
410
+ }
403
411
 
404
412
  var _symbol;
405
413
  var _symbolFor;
406
414
  var _symbolKeyFor;
407
415
  function _getSymbolValue(name) {
408
- return _lazySafeGet(function () {
416
+ return safeGetLazy(function () {
409
417
  return (_symbol.v ? _symbol[name] : UNDEF_VALUE);
410
418
  }, UNDEF_VALUE);
411
419
  }
420
+ function hasSymbol() {
421
+ return !!getSymbol();
422
+ }
412
423
  function getSymbol() {
413
424
  var resetCache = !_symbol || (_globalLazyTestHooks && _globalLazyTestHooks.lzy && !_symbol.b);
414
- resetCache && (_symbol = _lazySafeGetInst(SYMBOL));
425
+ resetCache && (_symbol = lazySafeGetInst(SYMBOL));
415
426
  (!_symbolFor || resetCache) && (_symbolFor = _getSymbolValue("for"));
416
427
  (!_symbolKeyFor || resetCache) && (_symbolKeyFor = _getSymbolValue("keyFor"));
417
428
  return _symbol.v;
@@ -1015,6 +1026,7 @@ this.Microsoft = this.Microsoft || {};
1015
1026
  var _DYN_TIME = "time";
1016
1027
  var _DYN_PROCESS_NEXT = "processNext";
1017
1028
  var _DYN_GET_PROCESS_TEL_CONT0 = "getProcessTelContext";
1029
+ var _DYN_UNLOAD = "unload";
1018
1030
  var _DYN_LOGGING_LEVEL_CONSOL4 = "loggingLevelConsole";
1019
1031
  var _DYN_CREATE_NEW$1 = "createNew";
1020
1032
  var _DYN_TEARDOWN = "teardown";
@@ -1054,6 +1066,330 @@ this.Microsoft = this.Microsoft || {};
1054
1066
  throw new aggregationErrorType(theMessage, sourceErrors || []);
1055
1067
  }
1056
1068
 
1069
+ function doAwaitResponse(value, cb) {
1070
+ return doAwait(value, function (value) {
1071
+ cb && cb({
1072
+ value: value,
1073
+ rejected: false
1074
+ });
1075
+ }, function (reason) {
1076
+ cb && cb({
1077
+ rejected: true,
1078
+ reason: reason
1079
+ });
1080
+ });
1081
+ }
1082
+ function doAwait(value, resolveFn, rejectFn, finallyFn) {
1083
+ var result = value;
1084
+ if (isPromiseLike(value)) {
1085
+ if (resolveFn || rejectFn) {
1086
+ result = value.then(resolveFn, rejectFn);
1087
+ }
1088
+ }
1089
+ else {
1090
+ resolveFn && resolveFn(value);
1091
+ }
1092
+ if (finallyFn) {
1093
+ result = doFinally(result, finallyFn);
1094
+ }
1095
+ return result;
1096
+ }
1097
+ function doFinally(value, finallyFn) {
1098
+ var result = value;
1099
+ if (finallyFn) {
1100
+ if (isPromiseLike(value)) {
1101
+ if (value.finally) {
1102
+ result = value.finally(finallyFn);
1103
+ }
1104
+ else {
1105
+ result = value.then(function (value) {
1106
+ finallyFn();
1107
+ return value;
1108
+ }, function (reason) {
1109
+ finallyFn();
1110
+ throw reason;
1111
+ });
1112
+ }
1113
+ }
1114
+ else {
1115
+ finallyFn();
1116
+ }
1117
+ }
1118
+ return result;
1119
+ }
1120
+
1121
+ var _theLogger = null;
1122
+ function _debugLog(id, message) {
1123
+ if (_theLogger) {
1124
+ _theLogger(id, message);
1125
+ }
1126
+ }
1127
+
1128
+ var STRING_STATES = [
1129
+ "pending", "resolving", "resolved", "rejected"
1130
+ ];
1131
+
1132
+ var DISPATCH_EVENT = "dispatchEvent";
1133
+ var _hasInitEvent;
1134
+ function emitEvent(target, evtName, populateEvent, useNewEvent) {
1135
+ var doc = getDocument();
1136
+ !_hasInitEvent && (_hasInitEvent = safeGetLazy(function () {
1137
+ var evt;
1138
+ if (doc && doc.createEvent) {
1139
+ evt = doc.createEvent("Event");
1140
+ }
1141
+ return (!!evt && evt.initEvent);
1142
+ }, null));
1143
+ var theEvt = _hasInitEvent.v ? doc.createEvent("Event") : (useNewEvent ? new Event(evtName) : {});
1144
+ populateEvent && populateEvent(theEvt);
1145
+ if (_hasInitEvent.v) {
1146
+ theEvt.initEvent(evtName, false, true);
1147
+ }
1148
+ if (theEvt && target[DISPATCH_EVENT]) {
1149
+ target[DISPATCH_EVENT](theEvt);
1150
+ }
1151
+ else {
1152
+ var handler = target["on" + evtName];
1153
+ if (handler) {
1154
+ handler(theEvt);
1155
+ }
1156
+ else {
1157
+ var theConsole = getInst("console");
1158
+ theConsole && (theConsole["error"] || theConsole["log"])(evtName, dumpObj(theEvt));
1159
+ }
1160
+ }
1161
+ }
1162
+
1163
+ var STR_PROMISE = "Promise";
1164
+
1165
+ var NODE_UNHANDLED_REJECTION = "unhandledRejection";
1166
+ var UNHANDLED_REJECTION = NODE_UNHANDLED_REJECTION.toLowerCase();
1167
+ var _unhandledRejectionTimeout = 10;
1168
+ var _hasPromiseRejectionEvent;
1169
+ function dumpFnObj(value) {
1170
+ if (isFunction(value)) {
1171
+ return value.toString();
1172
+ }
1173
+ return dumpObj(value);
1174
+ }
1175
+ function _createPromise(newPromise, processor, executor) {
1176
+ var additionalArgs = arrSlice(arguments, 3);
1177
+ var _state = 0 ;
1178
+ var _hasResolved = false;
1179
+ var _settledValue;
1180
+ var _queue = [];
1181
+ var _handled = false;
1182
+ var _unHandledRejectionHandler = null;
1183
+ var _thePromise;
1184
+ !_hasPromiseRejectionEvent && (_hasPromiseRejectionEvent = lazySafeGetInst(STR_PROMISE + "RejectionEvent"));
1185
+ var _then = function (onResolved, onRejected) {
1186
+ try {
1187
+ _handled = true;
1188
+ _unHandledRejectionHandler && _unHandledRejectionHandler.cancel();
1189
+ _unHandledRejectionHandler = null;
1190
+ _debugLog(_toString(), "then(" + dumpFnObj(onResolved) + ", " + dumpFnObj(onResolved) + ")");
1191
+ var thenPromise = newPromise(function (resolve, reject) {
1192
+ _queue.push(function () {
1193
+ try {
1194
+ _debugLog(_toString(), "Handling settled value " + dumpFnObj(_settledValue));
1195
+ var handler = _state === 2 ? onResolved : onRejected;
1196
+ var value = isUndefined(handler) ? _settledValue : (isFunction(handler) ? handler(_settledValue) : handler);
1197
+ _debugLog(_toString(), "Handling Result " + dumpFnObj(value));
1198
+ if (isPromiseLike(value)) {
1199
+ value.then(resolve, reject);
1200
+ }
1201
+ else if (handler) {
1202
+ resolve(value);
1203
+ }
1204
+ else if (_state === 3 ) {
1205
+ reject(value);
1206
+ }
1207
+ else {
1208
+ resolve(value);
1209
+ }
1210
+ }
1211
+ catch (e) {
1212
+ reject(e);
1213
+ }
1214
+ });
1215
+ _debugLog(_toString(), "Added to Queue " + _queue.length);
1216
+ if (_hasResolved) {
1217
+ _processQueue();
1218
+ }
1219
+ }, additionalArgs);
1220
+ _debugLog(_toString(), "Created -> " + thenPromise.toString());
1221
+ return thenPromise;
1222
+ }
1223
+ finally {
1224
+ }
1225
+ };
1226
+ var _catch = function (onRejected) {
1227
+ return _then(undefined, onRejected);
1228
+ };
1229
+ var _finally = function (onFinally) {
1230
+ var thenFinally = onFinally;
1231
+ var catchFinally = onFinally;
1232
+ if (isFunction(onFinally)) {
1233
+ thenFinally = function (value) {
1234
+ onFinally && onFinally();
1235
+ return value;
1236
+ };
1237
+ catchFinally = function (reason) {
1238
+ onFinally && onFinally();
1239
+ throw reason;
1240
+ };
1241
+ }
1242
+ return _then(thenFinally, catchFinally);
1243
+ };
1244
+ var _strState = function () {
1245
+ return STRING_STATES[_state];
1246
+ };
1247
+ var _processQueue = function () {
1248
+ if (_queue.length > 0) {
1249
+ var pending = _queue.slice();
1250
+ _queue = [];
1251
+ _debugLog(_toString(), "Processing queue " + pending.length);
1252
+ _handled = true;
1253
+ processor(pending);
1254
+ _debugLog(_toString(), "Processing done");
1255
+ _unHandledRejectionHandler && _unHandledRejectionHandler.cancel();
1256
+ _unHandledRejectionHandler = null;
1257
+ }
1258
+ else {
1259
+ _debugLog(_toString(), "Empty Processing queue ");
1260
+ }
1261
+ };
1262
+ var _createSettleIfFn = function (newState, allowState) {
1263
+ return function (theValue) {
1264
+ if (_state === allowState) {
1265
+ if (newState === 2 && isPromiseLike(theValue)) {
1266
+ _state = 1 ;
1267
+ _debugLog(_toString(), "Resolving");
1268
+ theValue.then(_createSettleIfFn(2 , 1 ), _createSettleIfFn(3 , 1 ));
1269
+ return;
1270
+ }
1271
+ _state = newState;
1272
+ _hasResolved = true;
1273
+ _settledValue = theValue;
1274
+ _debugLog(_toString(), _strState());
1275
+ _processQueue();
1276
+ if (!_handled && newState === 3 && !_unHandledRejectionHandler) {
1277
+ _unHandledRejectionHandler = scheduleTimeout(_notifyUnhandledRejection, _unhandledRejectionTimeout);
1278
+ }
1279
+ }
1280
+ else {
1281
+ _debugLog(_toString(), "Already " + _strState());
1282
+ }
1283
+ };
1284
+ };
1285
+ var _notifyUnhandledRejection = function () {
1286
+ if (!_handled) {
1287
+ if (isNode()) {
1288
+ _debugLog(_toString(), "Emitting " + NODE_UNHANDLED_REJECTION);
1289
+ process.emit(NODE_UNHANDLED_REJECTION, _settledValue, _thePromise);
1290
+ }
1291
+ else {
1292
+ var gbl = getWindow() || getGlobal();
1293
+ _debugLog(_toString(), "Emitting " + UNHANDLED_REJECTION);
1294
+ emitEvent(gbl, UNHANDLED_REJECTION, function (theEvt) {
1295
+ objDefine(theEvt, "promise", { g: function () { return _thePromise; } });
1296
+ theEvt.reason = _settledValue;
1297
+ return theEvt;
1298
+ }, !!_hasPromiseRejectionEvent.v);
1299
+ }
1300
+ }
1301
+ };
1302
+ _thePromise = {
1303
+ then: _then,
1304
+ "catch": _catch,
1305
+ finally: _finally
1306
+ };
1307
+ objDefineProp(_thePromise, "state", {
1308
+ get: _strState
1309
+ });
1310
+ if (hasSymbol()) {
1311
+ _thePromise[getKnownSymbol(11 )] = "IPromise";
1312
+ }
1313
+ var _toString = function () {
1314
+ return "IPromise" + ("") + " " + _strState() + (_hasResolved ? (" - " + dumpFnObj(_settledValue)) : "");
1315
+ };
1316
+ _thePromise.toString = _toString;
1317
+ (function _initialize() {
1318
+ if (!isFunction(executor)) {
1319
+ throwTypeError(STR_PROMISE + ": executor is not a function - " + dumpFnObj(executor));
1320
+ }
1321
+ var _rejectFn = _createSettleIfFn(3 , 0 );
1322
+ try {
1323
+ _debugLog(_toString(), "Executing");
1324
+ executor.call(_thePromise, _createSettleIfFn(2 , 0 ), _rejectFn);
1325
+ }
1326
+ catch (e) {
1327
+ _rejectFn(e);
1328
+ }
1329
+ })();
1330
+ _debugLog(_toString(), "Returning");
1331
+ return _thePromise;
1332
+ }
1333
+
1334
+ var _processPendingItems = function (pending) {
1335
+ arrForEach(pending, function (fn) {
1336
+ try {
1337
+ fn();
1338
+ }
1339
+ catch (e) {
1340
+ }
1341
+ });
1342
+ };
1343
+ function timeoutItemProcessor(timeout) {
1344
+ var callbackTimeout = isNumber(timeout) ? timeout : 0;
1345
+ return function (pending) {
1346
+ scheduleTimeout(function () {
1347
+ _processPendingItems(pending);
1348
+ }, callbackTimeout);
1349
+ };
1350
+ }
1351
+
1352
+ function createAsyncPromise(executor, timeout) {
1353
+ return _createPromise(createAsyncPromise, timeoutItemProcessor(timeout), executor, timeout);
1354
+ }
1355
+
1356
+ var _isPromiseSupported;
1357
+ function createNativePromise(executor, timeout) {
1358
+ !_isPromiseSupported && (_isPromiseSupported = lazySafeGetInst(STR_PROMISE));
1359
+ var PrmCls = _isPromiseSupported.v;
1360
+ if (!PrmCls) {
1361
+ return createAsyncPromise(executor);
1362
+ }
1363
+ if (!isFunction(executor)) {
1364
+ throwTypeError(STR_PROMISE + ": executor is not a function - " + dumpObj(executor));
1365
+ }
1366
+ var _state = 0 ;
1367
+ function _strState() {
1368
+ return STRING_STATES[_state];
1369
+ }
1370
+ var thePromise = new PrmCls(function (resolve, reject) {
1371
+ function _resolve(value) {
1372
+ _state = 2 ;
1373
+ resolve(value);
1374
+ }
1375
+ function _reject(reason) {
1376
+ _state = 3 ;
1377
+ reject(reason);
1378
+ }
1379
+ executor(_resolve, _reject);
1380
+ });
1381
+ objDefineProp(thePromise, "state", {
1382
+ get: _strState
1383
+ });
1384
+ return thePromise;
1385
+ }
1386
+
1387
+ var _promiseCreator;
1388
+ function createPromise(executor, timeout) {
1389
+ !_promiseCreator && (_promiseCreator = getLazy(function () { return createNativePromise; }));
1390
+ return _promiseCreator.v.call(this, executor, timeout);
1391
+ }
1392
+
1057
1393
  var UNDEFINED_VALUE$1 = undefined;
1058
1394
  var STR_EMPTY = "";
1059
1395
  var STR_CORE = "core";
@@ -1396,7 +1732,7 @@ this.Microsoft = this.Microsoft || {};
1396
1732
  return result;
1397
1733
  }
1398
1734
 
1399
- var version = "3.0.1-nightly3.2304-38";
1735
+ var version = "3.0.1-nightly3.2304-44";
1400
1736
  var instanceName = "." + newId(6);
1401
1737
  var _dataUid = 0;
1402
1738
  function _canAcceptData(target) {
@@ -1991,7 +2327,13 @@ this.Microsoft = this.Microsoft || {};
1991
2327
  return handler[_DYN_WATCH ](configHandler);
1992
2328
  }
1993
2329
  _logInvalidAccess(logger, STR_NOT_DYNAMIC_ERROR + dumpObj(config));
1994
- createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
2330
+ return createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
2331
+ }
2332
+
2333
+ function runTargetUnload(target, isAsync) {
2334
+ if (target && target[_DYN_UNLOAD ]) {
2335
+ return target[_DYN_UNLOAD ](isAsync);
2336
+ }
1995
2337
  }
1996
2338
 
1997
2339
  function _stringToBoolOrDefault(theValue, defaultValue, theConfig) {
@@ -2093,8 +2435,9 @@ this.Microsoft = this.Microsoft || {};
2093
2435
  var _loggingLevelTelemetry;
2094
2436
  var _maxInternalMessageLimit;
2095
2437
  var _enableDebug;
2438
+ var _unloadHandler;
2096
2439
  dynamicProto(DiagnosticLogger, this, function (_self) {
2097
- _setDefaultsFromConfig(config || {});
2440
+ _unloadHandler = _setDefaultsFromConfig(config || {});
2098
2441
  _self.consoleLoggingLevel = function () { return _loggingLevelConsole; };
2099
2442
  _self[_DYN_THROW_INTERNAL ] = function (severity, msgId, msg, properties, isUserAct) {
2100
2443
  if (isUserAct === void 0) { isUserAct = false; }
@@ -2137,6 +2480,10 @@ this.Microsoft = this.Microsoft || {};
2137
2480
  _messageLogged = {};
2138
2481
  };
2139
2482
  _self[_DYN_LOG_INTERNAL_MESSAGE ] = _logInternalMessage;
2483
+ _self[_DYN_UNLOAD ] = function (isAsync) {
2484
+ _unloadHandler && _unloadHandler.rm();
2485
+ _unloadHandler = null;
2486
+ };
2140
2487
  function _logInternalMessage(severity, message) {
2141
2488
  if (_areInternalMessagesThrottled()) {
2142
2489
  return;
@@ -2169,8 +2516,7 @@ this.Microsoft = this.Microsoft || {};
2169
2516
  }
2170
2517
  }
2171
2518
  function _setDefaultsFromConfig(config) {
2172
- var handler = createDynamicConfig(config, defaultValues$1, _self);
2173
- handler[_DYN_WATCH ](function (details) {
2519
+ return onConfigChange(createDynamicConfig(config, defaultValues$1, _self).cfg, function (details) {
2174
2520
  var config = details.cfg;
2175
2521
  _loggingLevelConsole = config[_DYN_LOGGING_LEVEL_CONSOL4 ];
2176
2522
  _loggingLevelTelemetry = config.loggingLevelTelemetry;
@@ -2489,7 +2835,7 @@ this.Microsoft = this.Microsoft || {};
2489
2835
  var context = internalContext.ctx;
2490
2836
  function _processNext(unloadState) {
2491
2837
  var nextPlugin = internalContext._next();
2492
- nextPlugin && nextPlugin.unload(context, unloadState);
2838
+ nextPlugin && nextPlugin[_DYN_UNLOAD ](context, unloadState);
2493
2839
  return !nextPlugin;
2494
2840
  }
2495
2841
  function _createNew(plugins, startAt) {
@@ -3390,7 +3736,7 @@ this.Microsoft = this.Microsoft || {};
3390
3736
  return Envelope;
3391
3737
  }());
3392
3738
 
3393
- var Event = /** @class */ (function () {
3739
+ var Event$1 = /** @class */ (function () {
3394
3740
  function Event(logger, name, properties, measurements) {
3395
3741
  this.aiDataContract = {
3396
3742
  ver: 1 ,
@@ -4330,7 +4676,7 @@ this.Microsoft = this.Microsoft || {};
4330
4676
  }
4331
4677
  }
4332
4678
  var EnvelopeCreator = {
4333
- Version: "3.0.1-nightly3.2304-38"
4679
+ Version: "3.0.1-nightly3.2304-44"
4334
4680
  };
4335
4681
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
4336
4682
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -4354,10 +4700,10 @@ this.Microsoft = this.Microsoft || {};
4354
4700
  EnvelopeCreatorInit(logger, telemetryItem);
4355
4701
  var customProperties = {};
4356
4702
  var customMeasurements = {};
4357
- if (telemetryItem[strBaseType] !== Event[_DYN_DATA_TYPE ]) {
4703
+ if (telemetryItem[strBaseType] !== Event$1[_DYN_DATA_TYPE ]) {
4358
4704
  customProperties["baseTypeSource"] = telemetryItem[strBaseType];
4359
4705
  }
4360
- if (telemetryItem[strBaseType] === Event[_DYN_DATA_TYPE ]) {
4706
+ if (telemetryItem[strBaseType] === Event$1[_DYN_DATA_TYPE ]) {
4361
4707
  customProperties = telemetryItem[strBaseData][strProperties] || {};
4362
4708
  customMeasurements = telemetryItem[strBaseData][_DYN_MEASUREMENTS ] || {};
4363
4709
  }
@@ -4371,9 +4717,9 @@ this.Microsoft = this.Microsoft || {};
4371
4717
  _convertPropsUndefinedToCustomDefinedValue(customProperties, customUndefinedValue);
4372
4718
  }
4373
4719
  var eventName = telemetryItem[strBaseData][_DYN_NAME ];
4374
- var eventData = new Event(logger, eventName, customProperties, customMeasurements);
4375
- var data = new Data(Event[_DYN_DATA_TYPE ], eventData);
4376
- return _createEnvelope(logger, Event[_DYN_ENVELOPE_TYPE ], telemetryItem, data);
4720
+ var eventData = new Event$1(logger, eventName, customProperties, customMeasurements);
4721
+ var data = new Data(Event$1[_DYN_DATA_TYPE ], eventData);
4722
+ return _createEnvelope(logger, Event$1[_DYN_ENVELOPE_TYPE ], telemetryItem, data);
4377
4723
  }
4378
4724
  function ExceptionEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
4379
4725
  EnvelopeCreatorInit(logger, telemetryItem);
@@ -5016,7 +5362,7 @@ this.Microsoft = this.Microsoft || {};
5016
5362
  return !isNaN(value) && value > 0 && value <= 100;
5017
5363
  }
5018
5364
  var EnvelopeTypeCreator = (_b = {},
5019
- _b[Event.dataType] = EventEnvelopeCreator,
5365
+ _b[Event$1.dataType] = EventEnvelopeCreator,
5020
5366
  _b[Trace.dataType] = TraceEnvelopeCreator,
5021
5367
  _b[PageView.dataType] = PageViewEnvelopeCreator,
5022
5368
  _b[PageViewPerformance.dataType] = PageViewPerformanceEnvelopeCreator,
@@ -5055,6 +5401,7 @@ this.Microsoft = this.Microsoft || {};
5055
5401
  var _sessionStorageUsed;
5056
5402
  var _bufferOverrideUsed;
5057
5403
  var _namePrefix;
5404
+ var _enableSendPromise;
5058
5405
  dynamicProto(Sender, _this, function (_self, _base) {
5059
5406
  _initDefaults();
5060
5407
  _self.pause = function () {
@@ -5074,7 +5421,7 @@ this.Microsoft = this.Microsoft || {};
5074
5421
  if (!_paused) {
5075
5422
  _clearScheduledTimer();
5076
5423
  try {
5077
- _self[_DYN_TRIGGER_SEND ](isAsync, null, sendReason || 1 );
5424
+ return _self[_DYN_TRIGGER_SEND ](isAsync, null, sendReason || 1 );
5078
5425
  }
5079
5426
  catch (e) {
5080
5427
  _throwInternal(_self[_DYN_DIAG_LOG ](), 1 , 22 , "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
@@ -5085,14 +5432,14 @@ this.Microsoft = this.Microsoft || {};
5085
5432
  if (!_paused) {
5086
5433
  if (_beaconSupported) {
5087
5434
  try {
5088
- _self[_DYN_TRIGGER_SEND ](true, _doUnloadSend, 2 );
5435
+ return _self[_DYN_TRIGGER_SEND ](true, _doUnloadSend, 2 );
5089
5436
  }
5090
5437
  catch (e) {
5091
5438
  _throwInternal(_self[_DYN_DIAG_LOG ](), 1 , 20 , "failed to flush with beacon sender on page unload, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
5092
5439
  }
5093
5440
  }
5094
5441
  else {
5095
- _self.flush();
5442
+ _self.flush(false);
5096
5443
  }
5097
5444
  }
5098
5445
  };
@@ -5171,6 +5518,7 @@ this.Microsoft = this.Microsoft || {};
5171
5518
  else {
5172
5519
  _customHeaders = null;
5173
5520
  }
5521
+ _enableSendPromise = senderConfig.enableSendPromise;
5174
5522
  var sendPostFunc = null;
5175
5523
  if (!senderConfig[_DYN_DISABLE_XHR ] && useXDomainRequest()) {
5176
5524
  sendPostFunc = _xdrSender;
@@ -5278,6 +5626,7 @@ this.Microsoft = this.Microsoft || {};
5278
5626
  };
5279
5627
  _self[_DYN_TRIGGER_SEND ] = function (async, forcedSender, sendReason) {
5280
5628
  if (async === void 0) { async = true; }
5629
+ var result;
5281
5630
  if (!_paused) {
5282
5631
  try {
5283
5632
  var buffer = _self[_DYN__BUFFER ];
@@ -5286,10 +5635,10 @@ this.Microsoft = this.Microsoft || {};
5286
5635
  var payload = buffer.getItems();
5287
5636
  _notifySendRequest(sendReason || 0 , async);
5288
5637
  if (forcedSender) {
5289
- forcedSender.call(_this, payload, async);
5638
+ result = forcedSender.call(_this, payload, async);
5290
5639
  }
5291
5640
  else {
5292
- _self[_DYN__SENDER ](payload, async);
5641
+ result = _self[_DYN__SENDER ](payload, async);
5293
5642
  }
5294
5643
  }
5295
5644
  }
@@ -5305,10 +5654,11 @@ this.Microsoft = this.Microsoft || {};
5305
5654
  }
5306
5655
  }
5307
5656
  }
5657
+ return result;
5308
5658
  };
5309
5659
  _self._doTeardown = function (unloadCtx, unloadState) {
5310
5660
  _self.onunloadFlush();
5311
- _offlineListener.unload();
5661
+ runTargetUnload(_offlineListener, false);
5312
5662
  _initDefaults();
5313
5663
  };
5314
5664
  _self[_DYN__ON_ERROR ] = function (payload, message, event) {
@@ -5477,6 +5827,9 @@ this.Microsoft = this.Microsoft || {};
5477
5827
  }
5478
5828
  }
5479
5829
  function _xhrSender(payload, isAsync) {
5830
+ var thePromise;
5831
+ var resolveFunc;
5832
+ var rejectFunc;
5480
5833
  var xhr = new XMLHttpRequest();
5481
5834
  var endPointUrl = _endpointUrl;
5482
5835
  try {
@@ -5492,11 +5845,26 @@ this.Microsoft = this.Microsoft || {};
5492
5845
  arrForEach(objKeys(_headers), function (headerName) {
5493
5846
  xhr[_DYN_SET_REQUEST_HEADER ](headerName, _headers[headerName]);
5494
5847
  });
5495
- xhr.onreadystatechange = function () { return _self._xhrReadyStateChange(xhr, payload, payload[_DYN_LENGTH ]); };
5496
- xhr.onerror = function (event) { return _self[_DYN__ON_ERROR ](payload, _formatErrorMessageXhr(xhr), event); };
5848
+ xhr.onreadystatechange = function () {
5849
+ _self._xhrReadyStateChange(xhr, payload, payload[_DYN_LENGTH ]);
5850
+ if (xhr.readyState === 4) {
5851
+ resolveFunc && resolveFunc(true);
5852
+ }
5853
+ };
5854
+ xhr.onerror = function (event) {
5855
+ _self[_DYN__ON_ERROR ](payload, _formatErrorMessageXhr(xhr), event);
5856
+ rejectFunc && rejectFunc(event);
5857
+ };
5858
+ if (isAsync && _enableSendPromise) {
5859
+ thePromise = createPromise(function (resolve, reject) {
5860
+ resolveFunc = resolve;
5861
+ rejectFunc = reject;
5862
+ });
5863
+ }
5497
5864
  var batch = _self._buffer[_DYN_BATCH_PAYLOADS ](payload);
5498
5865
  xhr.send(batch);
5499
5866
  _self._buffer[_DYN_MARK_AS_SENT ](payload);
5867
+ return thePromise;
5500
5868
  }
5501
5869
  function _fetchKeepAliveSender(payload, isAsync) {
5502
5870
  if (isArray(payload)) {
@@ -5517,13 +5885,16 @@ this.Microsoft = this.Microsoft || {};
5517
5885
  }
5518
5886
  }
5519
5887
  function _fetchSender(payload, isAsync) {
5520
- _doFetchSender(payload, true);
5888
+ return _doFetchSender(payload, true);
5521
5889
  }
5522
5890
  function _doFetchSender(payload, isAsync) {
5523
5891
  var _a;
5524
5892
  var endPointUrl = _endpointUrl;
5525
5893
  var batch = _self._buffer[_DYN_BATCH_PAYLOADS ](payload);
5526
5894
  var plainTextBatch = new Blob([batch], { type: "application/json" });
5895
+ var thePromise;
5896
+ var resolveFunc;
5897
+ var rejectFunc;
5527
5898
  var requestHeaders = new Headers();
5528
5899
  var batchLength = batch[_DYN_LENGTH ];
5529
5900
  var ignoreResponse = false;
@@ -5554,43 +5925,52 @@ this.Microsoft = this.Microsoft || {};
5554
5925
  catch (e) {
5555
5926
  }
5556
5927
  _self._buffer[_DYN_MARK_AS_SENT ](payload);
5928
+ if (isAsync && _enableSendPromise) {
5929
+ thePromise = createPromise(function (resolve, reject) {
5930
+ resolveFunc = resolve;
5931
+ rejectFunc = reject;
5932
+ });
5933
+ }
5557
5934
  try {
5558
- fetch(request).then(function (response) {
5935
+ doAwaitResponse(fetch(request), function (result) {
5559
5936
  if (!isAsync) {
5560
5937
  _syncFetchPayload -= batchLength;
5561
5938
  batchLength = 0;
5562
5939
  }
5563
5940
  if (!responseHandled) {
5564
5941
  responseHandled = true;
5565
- if (!response.ok) {
5566
- _self[_DYN__ON_ERROR ](payload, response.statusText);
5942
+ if (!result.rejected) {
5943
+ var response_1 = result.value;
5944
+ if (!response_1.ok) {
5945
+ _self[_DYN__ON_ERROR ](payload, response_1.statusText);
5946
+ resolveFunc && resolveFunc(false);
5947
+ }
5948
+ else {
5949
+ doAwaitResponse(response_1.text(), function (resp) {
5950
+ _checkResponsStatus(response_1.status, payload, response_1.url, payload[_DYN_LENGTH ], response_1.statusText, resp.value || "");
5951
+ resolveFunc && resolveFunc(true);
5952
+ });
5953
+ }
5567
5954
  }
5568
5955
  else {
5569
- response.text().then(function (text) {
5570
- _checkResponsStatus(response.status, payload, response.url, payload[_DYN_LENGTH ], response.statusText, text);
5571
- });
5956
+ _self[_DYN__ON_ERROR ](payload, result.reason && result.reason.message);
5957
+ rejectFunc && rejectFunc(result.reason);
5572
5958
  }
5573
5959
  }
5574
- }).catch(function (error) {
5575
- if (!isAsync) {
5576
- _syncFetchPayload -= batchLength;
5577
- batchLength = 0;
5578
- }
5579
- if (!responseHandled) {
5580
- responseHandled = true;
5581
- _self[_DYN__ON_ERROR ](payload, error.message);
5582
- }
5583
5960
  });
5584
5961
  }
5585
5962
  catch (e) {
5586
5963
  if (!responseHandled) {
5587
5964
  _self[_DYN__ON_ERROR ](payload, dumpObj(e));
5965
+ rejectFunc && rejectFunc(e);
5588
5966
  }
5589
5967
  }
5590
5968
  if (ignoreResponse && !responseHandled) {
5591
5969
  responseHandled = true;
5592
5970
  _self._onSuccess(payload, payload[_DYN_LENGTH ]);
5971
+ resolveFunc && resolveFunc(true);
5593
5972
  }
5973
+ return thePromise;
5594
5974
  }
5595
5975
  function _parseResponse(response) {
5596
5976
  try {
@@ -5777,4 +6157,4 @@ this.Microsoft = this.Microsoft || {};
5777
6157
  exports.Sender = Sender;
5778
6158
 
5779
6159
  })(this.Microsoft.ApplicationInsights3 = this.Microsoft.ApplicationInsights3 || {});
5780
- //# sourceMappingURL=applicationinsights-channel-js.3.0.1-nightly3.2304-38.gbl.js.map
6160
+ //# sourceMappingURL=applicationinsights-channel-js.3.0.1-nightly3.2304-44.gbl.js.map