@microsoft/applicationinsights-react-native 2.4.5-nightly.2203-03 → 2.4.5

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - React Native Plugin, 2.4.5-nightly.2203-03
2
+ * Application Insights JavaScript SDK - React Native Plugin, 2.4.5
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -66,9 +66,7 @@
66
66
  (getGlobal() || {})["Reflect"];
67
67
  var extendStaticsFn = function (d, b) {
68
68
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
69
- ({ __proto__: [] } instanceof Array && function (d, b) {
70
- d.__proto__ = b;
71
- }) ||
69
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
72
70
  function (d, b) {
73
71
  for (var p in b) {
74
72
  if (b[strShimHasOwnProperty](p)) {
@@ -83,14 +81,12 @@
83
81
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
84
82
  }
85
83
  extendStaticsFn(d, b);
86
- function __() {
87
- this.constructor = d;
88
- }
84
+ function __() { this.constructor = d; }
89
85
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
90
86
  }
91
87
 
92
88
  /*!
93
- * Microsoft Dynamic Proto Utility, 1.1.4
89
+ * Microsoft Dynamic Proto Utility, 1.1.5
94
90
  * Copyright (c) Microsoft and contributors. All rights reserved.
95
91
  */
96
92
  var Constructor = 'constructor';
@@ -103,12 +99,13 @@
103
99
  var DynInstChkTag = '_dynInstChk';
104
100
  var DynAllowInstChkTag = DynInstChkTag;
105
101
  var DynProtoDefaultOptions = '_dfOpts';
102
+ var DynProtoPolyProto = "_dynProto";
106
103
  var UnknownValue = '_unknown_';
107
- var str__Proto$1 = "__proto__";
104
+ var str__Proto = "__proto__";
108
105
  var strUseBaseInst = 'useBaseInst';
109
106
  var strSetInstFuncs = 'setInstFuncs';
110
107
  var Obj = Object;
111
- var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
108
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
112
109
  var _dynamicNames = 0;
113
110
  function _hasOwnProperty(obj, prop) {
114
111
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -119,13 +116,16 @@
119
116
  function _isObjectArrayOrFunctionPrototype(target) {
120
117
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
121
118
  }
122
- function _getObjProto$1(target) {
119
+ function _getObjProto(target) {
123
120
  if (target) {
124
- if (_objGetPrototypeOf$1) {
125
- return _objGetPrototypeOf$1(target);
121
+ if (_objGetPrototypeOf) {
122
+ return _objGetPrototypeOf(target);
126
123
  }
127
- var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
124
+ var newProto = target[DynProtoPolyProto] || target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
128
125
  if (newProto) {
126
+ if (!target[DynProtoPolyProto]) {
127
+ target[DynProtoPolyProto] = newProto;
128
+ }
129
129
  return newProto;
130
130
  }
131
131
  }
@@ -190,16 +190,16 @@
190
190
  _forEachProp(instFuncs, function (name) {
191
191
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
192
192
  });
193
- var baseProto = _getObjProto$1(classProto);
193
+ var baseProto = _getObjProto(classProto);
194
194
  var visited = [];
195
195
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
196
196
  _forEachProp(baseProto, function (name) {
197
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
197
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
198
198
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
199
199
  }
200
200
  });
201
201
  visited.push(baseProto);
202
- baseProto = _getObjProto$1(baseProto);
202
+ baseProto = _getObjProto(baseProto);
203
203
  }
204
204
  return baseFuncs;
205
205
  }
@@ -213,7 +213,7 @@
213
213
  }
214
214
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
215
215
  var canAddInst = !_hasOwnProperty(target, funcName);
216
- var objProto = _getObjProto$1(target);
216
+ var objProto = _getObjProto(target);
217
217
  var visited = [];
218
218
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
219
219
  var protoFunc = objProto[funcName];
@@ -222,7 +222,7 @@
222
222
  break;
223
223
  }
224
224
  visited.push(objProto);
225
- objProto = _getObjProto$1(objProto);
225
+ objProto = _getObjProto(objProto);
226
226
  }
227
227
  try {
228
228
  if (canAddInst) {
@@ -240,7 +240,7 @@
240
240
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
241
241
  var protoFunc = proto[funcName];
242
242
  if (protoFunc === currentDynProtoProxy) {
243
- protoFunc = _getObjProto$1(proto)[funcName];
243
+ protoFunc = _getObjProto(proto)[funcName];
244
244
  }
245
245
  if (typeof protoFunc !== strFunction) {
246
246
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -274,18 +274,19 @@
274
274
  }
275
275
  }
276
276
  function _checkPrototype(classProto, thisTarget) {
277
- if (_objGetPrototypeOf$1) {
277
+ if (_objGetPrototypeOf) {
278
278
  var visited = [];
279
- var thisProto = _getObjProto$1(thisTarget);
279
+ var thisProto = _getObjProto(thisTarget);
280
280
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
281
281
  if (thisProto === classProto) {
282
282
  return true;
283
283
  }
284
284
  visited.push(thisProto);
285
- thisProto = _getObjProto$1(thisProto);
285
+ thisProto = _getObjProto(thisProto);
286
286
  }
287
+ return false;
287
288
  }
288
- return false;
289
+ return true;
289
290
  }
290
291
  function _getObjName(target, unknownValue) {
291
292
  if (_hasOwnProperty(target, Prototype)) {
@@ -318,7 +319,7 @@
318
319
  var instFuncs = _getInstanceFuncs(target);
319
320
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
320
321
  delegateFunc(target, baseFuncs);
321
- var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
322
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
322
323
  if (setInstanceFunc && options) {
323
324
  setInstanceFunc = !!options[strSetInstFuncs];
324
325
  }
@@ -330,40 +331,102 @@
330
331
  };
331
332
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
332
333
 
333
- var strEmpty = "";
334
- var strSetNextPlugin = "setNextPlugin";
335
- var strIsInitialized = "isInitialized";
336
- var strTeardown = "teardown";
337
- var strCore = "core";
338
- var strUpdate = "update";
339
- var strDisabled = "disabled";
340
- var strDoTeardown = "_doTeardown";
334
+ var LoggingSeverity;
335
+ (function (LoggingSeverity) {
336
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
337
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
338
+ })(LoggingSeverity || (LoggingSeverity = {}));
339
+ var _InternalMessageId = {
340
+ BrowserDoesNotSupportLocalStorage: 0,
341
+ BrowserCannotReadLocalStorage: 1,
342
+ BrowserCannotReadSessionStorage: 2,
343
+ BrowserCannotWriteLocalStorage: 3,
344
+ BrowserCannotWriteSessionStorage: 4,
345
+ BrowserFailedRemovalFromLocalStorage: 5,
346
+ BrowserFailedRemovalFromSessionStorage: 6,
347
+ CannotSendEmptyTelemetry: 7,
348
+ ClientPerformanceMathError: 8,
349
+ ErrorParsingAISessionCookie: 9,
350
+ ErrorPVCalc: 10,
351
+ ExceptionWhileLoggingError: 11,
352
+ FailedAddingTelemetryToBuffer: 12,
353
+ FailedMonitorAjaxAbort: 13,
354
+ FailedMonitorAjaxDur: 14,
355
+ FailedMonitorAjaxOpen: 15,
356
+ FailedMonitorAjaxRSC: 16,
357
+ FailedMonitorAjaxSend: 17,
358
+ FailedMonitorAjaxGetCorrelationHeader: 18,
359
+ FailedToAddHandlerForOnBeforeUnload: 19,
360
+ FailedToSendQueuedTelemetry: 20,
361
+ FailedToReportDataLoss: 21,
362
+ FlushFailed: 22,
363
+ MessageLimitPerPVExceeded: 23,
364
+ MissingRequiredFieldSpecification: 24,
365
+ NavigationTimingNotSupported: 25,
366
+ OnError: 26,
367
+ SessionRenewalDateIsZero: 27,
368
+ SenderNotInitialized: 28,
369
+ StartTrackEventFailed: 29,
370
+ StopTrackEventFailed: 30,
371
+ StartTrackFailed: 31,
372
+ StopTrackFailed: 32,
373
+ TelemetrySampledAndNotSent: 33,
374
+ TrackEventFailed: 34,
375
+ TrackExceptionFailed: 35,
376
+ TrackMetricFailed: 36,
377
+ TrackPVFailed: 37,
378
+ TrackPVFailedCalc: 38,
379
+ TrackTraceFailed: 39,
380
+ TransmissionFailed: 40,
381
+ FailedToSetStorageBuffer: 41,
382
+ FailedToRestoreStorageBuffer: 42,
383
+ InvalidBackendResponse: 43,
384
+ FailedToFixDepricatedValues: 44,
385
+ InvalidDurationValue: 45,
386
+ TelemetryEnvelopeInvalid: 46,
387
+ CreateEnvelopeError: 47,
388
+ CannotSerializeObject: 48,
389
+ CannotSerializeObjectNonSerializable: 49,
390
+ CircularReferenceDetected: 50,
391
+ ClearAuthContextFailed: 51,
392
+ ExceptionTruncated: 52,
393
+ IllegalCharsInName: 53,
394
+ ItemNotInArray: 54,
395
+ MaxAjaxPerPVExceeded: 55,
396
+ MessageTruncated: 56,
397
+ NameTooLong: 57,
398
+ SampleRateOutOfRange: 58,
399
+ SetAuthContextFailed: 59,
400
+ SetAuthContextFailedAccountName: 60,
401
+ StringValueTooLong: 61,
402
+ StartCalledMoreThanOnce: 62,
403
+ StopCalledWithoutStart: 63,
404
+ TelemetryInitializerFailed: 64,
405
+ TrackArgumentsNotSpecified: 65,
406
+ UrlTooLong: 66,
407
+ SessionStorageBufferFull: 67,
408
+ CannotAccessCookie: 68,
409
+ IdTooLong: 69,
410
+ InvalidEvent: 70,
411
+ FailedMonitorAjaxSetRequestHeader: 71,
412
+ SendBrowserInfoOnUserInit: 72,
413
+ PluginException: 73,
414
+ NotificationException: 74,
415
+ SnippetScriptLoadFailure: 99,
416
+ InvalidInstrumentationKey: 100,
417
+ CannotParseAiBlobValue: 101,
418
+ InvalidContentBlob: 102,
419
+ TrackPageActionEventFailed: 103,
420
+ FailedAddingCustomDefinedRequestContext: 104,
421
+ InMemoryStorageBufferFull: 105
422
+ };
341
423
 
342
424
  var strToString = "toString";
343
- var str__Proto = "__proto__";
344
- var strConstructor = "constructor";
345
- var _objDefineProperty$1 = ObjDefineProperty;
346
- var _objFreeze = ObjClass.freeze;
425
+ var _objDefineProperty = ObjDefineProperty;
347
426
  var _isArray = Array.isArray;
348
427
  var _objToString = ObjProto[strToString];
349
428
  var _fnToString = ObjHasOwnProperty[strToString];
350
- var _objFunctionString = _fnToString.call(ObjClass);
351
- var rCamelCase = /-([a-z])/g;
352
- var rNormalizeInvalid = /([^\w\d_$])/g;
353
- var rLeadingNumeric = /^(\d+[\w\d_$])/;
354
- var _objGetPrototypeOf = Object["getPrototypeOf"];
355
- function _getObjProto(target) {
356
- if (target) {
357
- if (_objGetPrototypeOf) {
358
- return _objGetPrototypeOf(target);
359
- }
360
- var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
361
- if (newProto) {
362
- return newProto;
363
- }
364
- }
365
- return null;
366
- }
429
+ _fnToString.call(ObjClass);
367
430
  function isUndefined(value) {
368
431
  return value === undefined || typeof value === strShimUndefined;
369
432
  }
@@ -379,34 +442,6 @@
379
442
  function isFunction(value) {
380
443
  return !!(value && typeof value === strShimFunction);
381
444
  }
382
- function normalizeJsName(name) {
383
- var value = name;
384
- if (value && isString(value)) {
385
- value = value.replace(rCamelCase, function (_all, letter) {
386
- return letter.toUpperCase();
387
- });
388
- value = value.replace(rNormalizeInvalid, "_");
389
- value = value.replace(rLeadingNumeric, function (_all, match) {
390
- return "_" + match;
391
- });
392
- }
393
- return value;
394
- }
395
- function objForEachKey$1(target, callbackfn) {
396
- if (target) {
397
- for (var prop in target) {
398
- if (ObjHasOwnProperty.call(target, prop)) {
399
- callbackfn.call(target, prop, target[prop]);
400
- }
401
- }
402
- }
403
- }
404
- function strContains(value, search) {
405
- if (value && search) {
406
- return value.indexOf(search) !== -1;
407
- }
408
- return false;
409
- }
410
445
  var isArray = _isArray || _isArrayPoly;
411
446
  function _isArrayPoly(obj) {
412
447
  return !!(obj && _objToString.call(obj) === "[object Array]");
@@ -414,28 +449,6 @@
414
449
  function isError(obj) {
415
450
  return !!(obj && _objToString.call(obj) === "[object Error]");
416
451
  }
417
- function isString(value) {
418
- return typeof value === "string";
419
- }
420
- function isBoolean(value) {
421
- return typeof value === "boolean";
422
- }
423
- function isPlainObject(value) {
424
- var result = false;
425
- if (value && typeof value === "object") {
426
- var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
427
- if (!proto) {
428
- result = true;
429
- }
430
- else {
431
- if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
432
- proto = proto[strConstructor];
433
- }
434
- result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
435
- }
436
- }
437
- return result;
438
- }
439
452
  function arrForEach(arr, callbackfn, thisArg) {
440
453
  var len = arr.length;
441
454
  try {
@@ -451,7 +464,7 @@
451
464
  }
452
465
  }
453
466
  function objDefineAccessors(target, prop, getProp, setProp) {
454
- if (_objDefineProperty$1) {
467
+ if (_objDefineProperty) {
455
468
  try {
456
469
  var descriptor = {
457
470
  enumerable: true,
@@ -463,7 +476,7 @@
463
476
  if (setProp) {
464
477
  descriptor.set = setProp;
465
478
  }
466
- _objDefineProperty$1(target, prop, descriptor);
479
+ _objDefineProperty(target, prop, descriptor);
467
480
  return true;
468
481
  }
469
482
  catch (e) {
@@ -471,10 +484,6 @@
471
484
  }
472
485
  return false;
473
486
  }
474
- function _doNothing(value) {
475
- return value;
476
- }
477
- var objFreeze = _objFreeze || _doNothing;
478
487
  function dateNow() {
479
488
  var dt = Date;
480
489
  return dt.now ? dt.now() : new dt().getTime();
@@ -483,7 +492,7 @@
483
492
  if (isError(object)) {
484
493
  return object.name;
485
494
  }
486
- return strEmpty;
495
+ return "";
487
496
  }
488
497
  function setValue(target, field, value, valChk, srcChk) {
489
498
  var theValue = value;
@@ -496,102 +505,10 @@
496
505
  }
497
506
  return theValue;
498
507
  }
499
- function throwError(message) {
500
- throw new Error(message);
501
- }
502
- function _createProxyFunction(source, funcName) {
503
- var srcFunc = null;
504
- var src = null;
505
- if (isFunction(source)) {
506
- srcFunc = source;
507
- }
508
- else {
509
- src = source;
510
- }
511
- return function () {
512
- var originalArguments = arguments;
513
- if (srcFunc) {
514
- src = srcFunc();
515
- }
516
- if (src) {
517
- return src[funcName].apply(src, originalArguments);
518
- }
519
- };
520
- }
521
- function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
522
- if (overwriteTarget === void 0) { overwriteTarget = true; }
523
- if (target && name && source) {
524
- if (overwriteTarget || isUndefined(target[name])) {
525
- target[name] = _createProxyFunction(source, theFunc);
526
- }
527
- }
528
- }
529
- function createEnumStyle(values) {
530
- var enumClass = {};
531
- objForEachKey$1(values, function (field, value) {
532
- enumClass[field] = value;
533
- if (!isUndefined(enumClass[value])) {
534
- throwError("[" + value + "] exists for " + field);
535
- }
536
- enumClass[value] = field;
537
- });
538
- return objFreeze(enumClass);
539
- }
540
- function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
541
- var theArgs = arguments;
542
- var extended = theArgs[0] || {};
543
- var argLen = theArgs.length;
544
- var deep = false;
545
- var idx = 1;
546
- if (argLen > 0 && isBoolean(extended)) {
547
- deep = extended;
548
- extended = theArgs[idx] || {};
549
- idx++;
550
- }
551
- if (!isObject(extended)) {
552
- extended = {};
553
- }
554
- for (; idx < argLen; idx++) {
555
- var arg = theArgs[idx];
556
- var isArgArray = isArray(arg);
557
- var isArgObj = isObject(arg);
558
- for (var prop in arg) {
559
- var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
560
- if (!propOk) {
561
- continue;
562
- }
563
- var newValue = arg[prop];
564
- var isNewArray = void 0;
565
- if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
566
- var clone = extended[prop];
567
- if (isNewArray) {
568
- if (!isArray(clone)) {
569
- clone = [];
570
- }
571
- }
572
- else if (!isPlainObject(clone)) {
573
- clone = {};
574
- }
575
- newValue = objExtend(deep, clone, newValue);
576
- }
577
- if (newValue !== undefined) {
578
- extended[prop] = newValue;
579
- }
580
- }
581
- }
582
- return extended;
583
- }
584
508
 
585
509
  var strWindow = "window";
586
- var strNavigator = "navigator";
587
510
  var strConsole = "console";
588
511
  var strJSON = "JSON";
589
- var strCrypto = "crypto";
590
- var strMsCrypto = "msCrypto";
591
- var strMsie = "msie";
592
- var strTrident = "trident/";
593
- var _isTrident = null;
594
- var _navUserAgentCheck = null;
595
512
  function getGlobalInst(name) {
596
513
  var gbl = getGlobal();
597
514
  if (gbl && gbl[name]) {
@@ -605,15 +522,6 @@
605
522
  function hasWindow() {
606
523
  return Boolean(typeof window === strShimObject && window);
607
524
  }
608
- function hasNavigator() {
609
- return Boolean(typeof navigator === strShimObject && navigator);
610
- }
611
- function getNavigator() {
612
- if (hasNavigator()) {
613
- return navigator;
614
- }
615
- return getGlobalInst(strNavigator);
616
- }
617
525
  function getConsole() {
618
526
  if (typeof console !== strShimUndefined) {
619
527
  return console;
@@ -629,24 +537,9 @@
629
537
  }
630
538
  return null;
631
539
  }
632
- function getCrypto() {
633
- return getGlobalInst(strCrypto);
634
- }
635
- function getMsCrypto() {
636
- return getGlobalInst(strMsCrypto);
637
- }
638
- function isIE() {
639
- var nav = getNavigator();
640
- if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
641
- _navUserAgentCheck = nav.userAgent;
642
- var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
643
- _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
644
- }
645
- return _isTrident;
646
- }
647
540
  function dumpObj(object) {
648
541
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
649
- var propertyValueDump = strEmpty;
542
+ var propertyValueDump = "";
650
543
  if (objectTypeDump === "[object Error]") {
651
544
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
652
545
  }
@@ -679,9 +572,9 @@
679
572
  var strWarnToConsole = "warnToConsole";
680
573
  function _sanitizeDiagnosticText(text) {
681
574
  if (text) {
682
- return "\"" + text.replace(/\"/g, strEmpty) + "\"";
575
+ return "\"" + text.replace(/\"/g, "") + "\"";
683
576
  }
684
- return strEmpty;
577
+ return "";
685
578
  }
686
579
  function _logToConsole(func, message) {
687
580
  var theConsole = getConsole();
@@ -703,12 +596,12 @@
703
596
  _self.message =
704
597
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
705
598
  msgId;
706
- var strProps = strEmpty;
599
+ var strProps = "";
707
600
  if (hasJSON()) {
708
601
  strProps = getJSON().stringify(properties);
709
602
  }
710
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
711
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
603
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
604
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
712
605
  _self.message += diagnosticText;
713
606
  }
714
607
  _InternalLogMessage.dataType = "MessageData";
@@ -735,10 +628,10 @@
735
628
  if (isUserAct === void 0) { isUserAct = false; }
736
629
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
737
630
  if (_self.enableDebugExceptions()) {
738
- throw message;
631
+ throw dumpObj(message);
739
632
  }
740
633
  else {
741
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
634
+ var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
742
635
  if (!isUndefined(message.message)) {
743
636
  var logLevel = _self.consoleLoggingLevel();
744
637
  if (isUserAct) {
@@ -756,7 +649,7 @@
756
649
  _self.logInternalMessage(severity, message);
757
650
  }
758
651
  else {
759
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
652
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
760
653
  }
761
654
  }
762
655
  };
@@ -788,13 +681,13 @@
788
681
  if (severity <= _self.telemetryLoggingLevel()) {
789
682
  _self.queue.push(message);
790
683
  _messageCount++;
791
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
684
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
792
685
  }
793
686
  if (_messageCount === _self.maxInternalMessageLimit()) {
794
687
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
795
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
688
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
796
689
  _self.queue.push(throttleMessage);
797
- if (severity === 1 ) {
690
+ if (severity === LoggingSeverity.CRITICAL) {
798
691
  _self.errorToConsole(throttleLimitMessage);
799
692
  }
800
693
  else {
@@ -823,10 +716,6 @@
823
716
  }
824
717
  return DiagnosticLogger;
825
718
  }());
826
- function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
827
- if (isUserAct === void 0) { isUserAct = false; }
828
- (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
829
- }
830
719
 
831
720
  var strExecutionContextKey = "ctx";
832
721
  var PerfEvent = /** @class */ (function () {
@@ -940,616 +829,207 @@
940
829
  return func();
941
830
  }
942
831
 
943
- var UInt32Mask = 0x100000000;
944
- var MaxUInt32 = 0xffffffff;
945
- var _mwcSeeded = false;
946
- var _mwcW = 123456789;
947
- var _mwcZ = 987654321;
948
- function _mwcSeed(seedValue) {
949
- if (seedValue < 0) {
950
- seedValue >>>= 0;
951
- }
952
- _mwcW = (123456789 + seedValue) & MaxUInt32;
953
- _mwcZ = (987654321 - seedValue) & MaxUInt32;
954
- _mwcSeeded = true;
955
- }
956
- function _autoSeedMwc() {
957
- try {
958
- var now = dateNow() & 0x7fffffff;
959
- _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
960
- }
961
- catch (e) {
962
- }
963
- }
964
- function random32(signed) {
965
- var value = 0;
966
- var c = getCrypto() || getMsCrypto();
967
- if (c && c.getRandomValues) {
968
- value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
969
- }
970
- if (value === 0 && isIE()) {
971
- if (!_mwcSeeded) {
972
- _autoSeedMwc();
973
- }
974
- value = mwcRandom32() & MaxUInt32;
975
- }
976
- if (value === 0) {
977
- value = Math.floor((UInt32Mask * Math.random()) | 0);
978
- }
979
- if (!signed) {
980
- value >>>= 0;
981
- }
982
- return value;
983
- }
984
- function mwcRandom32(signed) {
985
- _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
986
- _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
987
- var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
988
- if (!signed) {
989
- value >>>= 0;
990
- }
991
- return value;
992
- }
993
- function newId(maxLength) {
994
- if (maxLength === void 0) { maxLength = 22; }
995
- var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
996
- var number = random32() >>> 0;
997
- var chars = 0;
998
- var result = strEmpty;
999
- while (result.length < maxLength) {
1000
- chars++;
1001
- result += base64chars.charAt(number & 0x3F);
1002
- number >>>= 6;
1003
- if (chars === 5) {
1004
- number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1005
- chars = 0;
1006
- }
1007
- }
1008
- return result;
1009
- }
1010
-
1011
- var _objDefineProperty = ObjDefineProperty;
1012
- var version = "2.7.5-nightly.2203-03";
1013
- var instanceName = "." + newId(6);
1014
- var _dataUid = 0;
1015
- function _createAccessor(target, prop, value) {
1016
- if (_objDefineProperty) {
1017
- try {
1018
- _objDefineProperty(target, prop, {
1019
- value: value,
1020
- enumerable: false,
1021
- configurable: true
1022
- });
1023
- return true;
1024
- }
1025
- catch (e) {
1026
- }
1027
- }
1028
- return false;
1029
- }
1030
- function _canAcceptData(target) {
1031
- return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1032
- }
1033
- function _getCache(data, target) {
1034
- var theCache = target[data.id];
1035
- if (!theCache) {
1036
- theCache = {};
1037
- try {
1038
- if (_canAcceptData(target)) {
1039
- if (!_createAccessor(target, data.id, theCache)) {
1040
- target[data.id] = theCache;
1041
- }
1042
- }
1043
- }
1044
- catch (e) {
1045
- }
1046
- }
1047
- return theCache;
1048
- }
1049
- function createUniqueNamespace(name, includeVersion) {
1050
- if (includeVersion === void 0) { includeVersion = false; }
1051
- return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1052
- }
1053
- function createElmNodeData(name) {
1054
- var data = {
1055
- id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1056
- accept: function (target) {
1057
- return _canAcceptData(target);
1058
- },
1059
- get: function (target, name, defValue, addDefault) {
1060
- var theCache = target[data.id];
1061
- if (!theCache) {
1062
- if (addDefault) {
1063
- theCache = _getCache(data, target);
1064
- theCache[normalizeJsName(name)] = defValue;
1065
- }
1066
- return defValue;
1067
- }
1068
- return theCache[normalizeJsName(name)];
1069
- },
1070
- kill: function (target, name) {
1071
- if (target && target[name]) {
1072
- try {
1073
- delete target[name];
1074
- }
1075
- catch (e) {
1076
- }
832
+ var TelemetryPluginChain = /** @class */ (function () {
833
+ function TelemetryPluginChain(plugin, defItemCtx) {
834
+ var _self = this;
835
+ var _nextProxy = null;
836
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
837
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
838
+ _self._hasRun = false;
839
+ _self.getPlugin = function () {
840
+ return plugin;
841
+ };
842
+ _self.getNext = function () {
843
+ return _nextProxy;
844
+ };
845
+ _self.setNext = function (nextPlugin) {
846
+ _nextProxy = nextPlugin;
847
+ };
848
+ _self.processTelemetry = function (env, itemCtx) {
849
+ if (!itemCtx) {
850
+ itemCtx = defItemCtx;
1077
851
  }
1078
- }
1079
- };
1080
- return data;
1081
- }
1082
-
1083
- var pluginStateData = createElmNodeData("plugin");
1084
- function _getPluginState(plugin) {
1085
- return pluginStateData.get(plugin, "state", {}, true);
1086
- }
1087
-
1088
- var strTelemetryPluginChain = "TelemetryPluginChain";
1089
- var strHasRunFlags = "_hasRun";
1090
- var strGetTelCtx = "_getTelCtx";
1091
- var _chainId = 0;
1092
- function _getNextProxyStart(proxy, config, core, startAt) {
1093
- while (proxy) {
1094
- if (proxy.getPlugin() === startAt) {
1095
- return proxy;
1096
- }
1097
- proxy = proxy.getNext();
1098
- }
1099
- return createTelemetryProxyChain([startAt], config, core);
1100
- }
1101
- function _createInternalContext(telemetryChain, config, core, startAt) {
1102
- var _nextProxy = null;
1103
- var _onComplete = [];
1104
- if (startAt !== null) {
1105
- _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1106
- }
1107
- var context = {
1108
- _next: _moveNext,
1109
- ctx: {
1110
- core: function () {
1111
- return core;
1112
- },
1113
- diagLog: function () {
1114
- return safeGetLogger(core, config);
1115
- },
1116
- getCfg: function () {
1117
- return config;
1118
- },
1119
- getExtCfg: _getExtCfg,
1120
- getConfig: _getConfig,
1121
- hasNext: function () {
1122
- return !!_nextProxy;
1123
- },
1124
- getNext: function () {
1125
- return _nextProxy;
1126
- },
1127
- setNext: function (nextPlugin) {
1128
- _nextProxy = nextPlugin;
1129
- },
1130
- iterate: _iterateChain,
1131
- onComplete: _addOnComplete
1132
- }
1133
- };
1134
- function _addOnComplete(onComplete, that) {
1135
- var args = [];
1136
- for (var _i = 2; _i < arguments.length; _i++) {
1137
- args[_i - 2] = arguments[_i];
1138
- }
1139
- if (onComplete) {
1140
- _onComplete.push({
1141
- func: onComplete,
1142
- self: !isUndefined(that) ? that : context.ctx,
1143
- args: args
1144
- });
1145
- }
1146
- }
1147
- function _moveNext() {
1148
- var nextProxy = _nextProxy;
1149
- _nextProxy = nextProxy ? nextProxy.getNext() : null;
1150
- if (!nextProxy) {
1151
- var onComplete = _onComplete;
1152
- if (onComplete && onComplete.length > 0) {
1153
- arrForEach(onComplete, function (completeDetails) {
852
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
853
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
854
+ if (plugin && _hasProcessTelemetry) {
855
+ _self._hasRun = true;
1154
856
  try {
1155
- completeDetails.func.call(completeDetails.self, completeDetails.args);
1156
- }
1157
- catch (e) {
1158
- _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
857
+ itemCtx.setNext(_nextProxy);
858
+ if (_hasSetNext) {
859
+ plugin.setNextPlugin(_nextProxy);
860
+ }
861
+ _nextProxy && (_nextProxy._hasRun = false);
862
+ plugin.processTelemetry(env, itemCtx);
1159
863
  }
1160
- });
1161
- _onComplete = [];
1162
- }
1163
- }
1164
- return nextProxy;
1165
- }
1166
- function _getExtCfg(identifier, defaultValue, mergeDefault) {
1167
- if (defaultValue === void 0) { defaultValue = {}; }
1168
- if (mergeDefault === void 0) { mergeDefault = 0 ; }
1169
- var theConfig;
1170
- if (config) {
1171
- var extConfig = config.extensionConfig;
1172
- if (extConfig && identifier) {
1173
- theConfig = extConfig[identifier];
1174
- }
1175
- }
1176
- if (!theConfig) {
1177
- theConfig = defaultValue;
1178
- }
1179
- else if (isObject(defaultValue)) {
1180
- if (mergeDefault !== 0 ) {
1181
- var newConfig_1 = objExtend(true, defaultValue, theConfig);
1182
- if (config && mergeDefault === 2 ) {
1183
- objForEachKey$1(defaultValue, function (field) {
1184
- if (isNullOrUndefined(newConfig_1[field])) {
1185
- var cfgValue = config[field];
1186
- if (!isNullOrUndefined(cfgValue)) {
1187
- newConfig_1[field] = cfgValue;
1188
- }
864
+ catch (error) {
865
+ var hasRun = _nextProxy && _nextProxy._hasRun;
866
+ if (!_nextProxy || !hasRun) {
867
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1189
868
  }
1190
- });
869
+ if (_nextProxy && !hasRun) {
870
+ _nextProxy.processTelemetry(env, itemCtx);
871
+ }
872
+ }
1191
873
  }
1192
- }
1193
- }
1194
- return theConfig;
1195
- }
1196
- function _getConfig(identifier, field, defaultValue) {
1197
- if (defaultValue === void 0) { defaultValue = false; }
1198
- var theValue;
1199
- var extConfig = _getExtCfg(identifier, null);
1200
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1201
- theValue = extConfig[field];
1202
- }
1203
- else if (config && !isNullOrUndefined(config[field])) {
1204
- theValue = config[field];
1205
- }
1206
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
874
+ else if (_nextProxy) {
875
+ _self._hasRun = true;
876
+ _nextProxy.processTelemetry(env, itemCtx);
877
+ }
878
+ }, function () { return ({ item: env }); }, !(env.sync));
879
+ };
1207
880
  }
1208
- function _iterateChain(cb) {
1209
- var nextPlugin;
1210
- while (!!(nextPlugin = context._next())) {
1211
- var plugin = nextPlugin.getPlugin();
1212
- if (plugin) {
1213
- cb(plugin);
881
+ return TelemetryPluginChain;
882
+ }());
883
+
884
+ function _createProxyChain(plugins, itemCtx) {
885
+ var proxies = [];
886
+ if (plugins && plugins.length > 0) {
887
+ var lastProxy = null;
888
+ for (var idx = 0; idx < plugins.length; idx++) {
889
+ var thePlugin = plugins[idx];
890
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
891
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
892
+ proxies.push(newProxy);
893
+ if (lastProxy) {
894
+ lastProxy.setNext(newProxy);
895
+ }
896
+ lastProxy = newProxy;
1214
897
  }
1215
898
  }
1216
899
  }
1217
- return context;
900
+ return proxies.length > 0 ? proxies[0] : null;
1218
901
  }
1219
- function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1220
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1221
- var context = internalContext.ctx;
1222
- function _processNext(env) {
1223
- var nextPlugin = internalContext._next();
1224
- nextPlugin && nextPlugin.processTelemetry(env, context);
1225
- return !nextPlugin;
1226
- }
1227
- function _createNew(plugins, startAt) {
1228
- if (plugins === void 0) { plugins = null; }
1229
- if (isArray(plugins)) {
1230
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
902
+ function _copyProxyChain(proxy, itemCtx, startAt) {
903
+ var plugins = [];
904
+ var add = startAt ? false : true;
905
+ if (proxy) {
906
+ while (proxy) {
907
+ var thePlugin = proxy.getPlugin();
908
+ if (add || thePlugin === startAt) {
909
+ add = true;
910
+ plugins.push(thePlugin);
911
+ }
912
+ proxy = proxy.getNext();
1231
913
  }
1232
- return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1233
914
  }
1234
- context.processNext = _processNext;
1235
- context.createNew = _createNew;
1236
- return context;
1237
- }
1238
- function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1239
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1240
- var context = internalContext.ctx;
1241
- function _processNext(unloadState) {
1242
- var nextPlugin = internalContext._next();
1243
- nextPlugin && nextPlugin.unload(context, unloadState);
1244
- return !nextPlugin;
915
+ if (!add) {
916
+ plugins.push(startAt);
1245
917
  }
1246
- function _createNew(plugins, startAt) {
1247
- if (plugins === void 0) { plugins = null; }
1248
- if (isArray(plugins)) {
1249
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1250
- }
1251
- return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1252
- }
1253
- context.processNext = _processNext;
1254
- context.createNew = _createNew;
1255
- return context;
918
+ return _createProxyChain(plugins, itemCtx);
1256
919
  }
1257
- function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1258
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1259
- var context = internalContext.ctx;
1260
- function _processNext(updateState) {
1261
- return context.iterate(function (plugin) {
1262
- if (isFunction(plugin[strUpdate])) {
1263
- plugin[strUpdate](context, updateState);
920
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
921
+ var plugins = srcPlugins;
922
+ var add = false;
923
+ if (startAt && srcPlugins) {
924
+ plugins = [];
925
+ arrForEach(srcPlugins, function (thePlugin) {
926
+ if (add || thePlugin === startAt) {
927
+ add = true;
928
+ plugins.push(thePlugin);
1264
929
  }
1265
930
  });
1266
931
  }
1267
- function _createNew(plugins, startAt) {
1268
- if (plugins === void 0) { plugins = null; }
1269
- if (isArray(plugins)) {
1270
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
932
+ if (startAt && !add) {
933
+ if (!plugins) {
934
+ plugins = [];
1271
935
  }
1272
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
936
+ plugins.push(startAt);
1273
937
  }
1274
- context.processNext = _processNext;
1275
- context.createNew = _createNew;
1276
- return context;
938
+ return _createProxyChain(plugins, itemCtx);
1277
939
  }
1278
- function createTelemetryProxyChain(plugins, config, core, startAt) {
1279
- var firstProxy = null;
1280
- var add = startAt ? false : true;
1281
- if (isArray(plugins) && plugins.length > 0) {
1282
- var lastProxy_1 = null;
1283
- arrForEach(plugins, function (thePlugin) {
1284
- if (!add && startAt === thePlugin) {
1285
- add = true;
940
+ var ProcessTelemetryContext = /** @class */ (function () {
941
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
942
+ var _self = this;
943
+ var _nextProxy = null;
944
+ if (startAt !== null) {
945
+ if (plugins && isFunction(plugins.getPlugin)) {
946
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1286
947
  }
1287
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1288
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1289
- if (!firstProxy) {
1290
- firstProxy = newProxy;
948
+ else {
949
+ if (startAt) {
950
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1291
951
  }
1292
- if (lastProxy_1) {
1293
- lastProxy_1._setNext(newProxy);
952
+ else if (isUndefined(startAt)) {
953
+ _nextProxy = _createProxyChain(plugins, _self);
1294
954
  }
1295
- lastProxy_1 = newProxy;
1296
955
  }
1297
- });
1298
- }
1299
- if (startAt && !firstProxy) {
1300
- return createTelemetryProxyChain([startAt], config, core);
1301
- }
1302
- return firstProxy;
1303
- }
1304
- function createTelemetryPluginProxy(plugin, config, core) {
1305
- var nextProxy = null;
1306
- var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1307
- var hasSetNext = isFunction(plugin.setNextPlugin);
1308
- var chainId;
1309
- if (plugin) {
1310
- chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1311
- }
1312
- else {
1313
- chainId = "Unknown-0-" + _chainId++;
1314
- }
1315
- var proxyChain = {
1316
- getPlugin: function () {
1317
- return plugin;
1318
- },
1319
- getNext: function () {
1320
- return nextProxy;
1321
- },
1322
- processTelemetry: _processTelemetry,
1323
- unload: _unloadPlugin,
1324
- update: _updatePlugin,
1325
- _id: chainId,
1326
- _setNext: function (nextPlugin) {
1327
- nextProxy = nextPlugin;
1328
- }
1329
- };
1330
- function _getTelCtx() {
1331
- var itemCtx;
1332
- if (plugin && isFunction(plugin[strGetTelCtx])) {
1333
- itemCtx = plugin[strGetTelCtx]();
1334
956
  }
1335
- if (!itemCtx) {
1336
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1337
- }
1338
- return itemCtx;
1339
- }
1340
- function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1341
- var hasRun = false;
1342
- var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1343
- var hasRunContext = itemCtx[strHasRunFlags];
1344
- if (!hasRunContext) {
1345
- hasRunContext = itemCtx[strHasRunFlags] = {};
1346
- }
1347
- itemCtx.setNext(nextProxy);
1348
- if (plugin) {
1349
- doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1350
- hasRunContext[chainId] = true;
1351
- try {
1352
- var nextId = nextProxy ? nextProxy._id : strEmpty;
1353
- if (nextId) {
1354
- hasRunContext[nextId] = false;
1355
- }
1356
- hasRun = processPluginFn(itemCtx);
1357
- }
1358
- catch (error) {
1359
- var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1360
- if (hasNextRun) {
1361
- hasRun = true;
1362
- }
1363
- if (!nextProxy || !hasNextRun) {
1364
- _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1365
- }
957
+ _self.core = function () {
958
+ return core;
959
+ };
960
+ _self.diagLog = function () {
961
+ return safeGetLogger(core, config);
962
+ };
963
+ _self.getCfg = function () {
964
+ return config;
965
+ };
966
+ _self.getExtCfg = function (identifier, defaultValue) {
967
+ if (defaultValue === void 0) { defaultValue = {}; }
968
+ var theConfig;
969
+ if (config) {
970
+ var extConfig = config.extensionConfig;
971
+ if (extConfig && identifier) {
972
+ theConfig = extConfig[identifier];
1366
973
  }
1367
- }, details, isAsync);
1368
- }
1369
- return hasRun;
1370
- }
1371
- function _processTelemetry(env, itemCtx) {
1372
- itemCtx = itemCtx || _getTelCtx();
1373
- function _callProcessTelemetry(itemCtx) {
1374
- if (!plugin || !hasProcessTelemetry) {
1375
- return false;
1376
974
  }
1377
- var pluginState = _getPluginState(plugin);
1378
- if (pluginState[strTeardown] || pluginState[strDisabled]) {
1379
- return false;
975
+ return (theConfig ? theConfig : defaultValue);
976
+ };
977
+ _self.getConfig = function (identifier, field, defaultValue) {
978
+ if (defaultValue === void 0) { defaultValue = false; }
979
+ var theValue;
980
+ var extConfig = _self.getExtCfg(identifier, null);
981
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
982
+ theValue = extConfig[field];
1380
983
  }
1381
- if (hasSetNext) {
1382
- plugin.setNextPlugin(nextProxy);
984
+ else if (config && !isNullOrUndefined(config[field])) {
985
+ theValue = config[field];
1383
986
  }
1384
- plugin.processTelemetry(env, itemCtx);
1385
- return true;
1386
- }
1387
- if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1388
- itemCtx.processNext(env);
1389
- }
1390
- }
1391
- function _unloadPlugin(unloadCtx, unloadState) {
1392
- function _callTeardown() {
1393
- var hasRun = false;
1394
- if (plugin) {
1395
- var pluginState = _getPluginState(plugin);
1396
- var pluginCore = plugin[strCore] || pluginState.core;
1397
- if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1398
- pluginState[strCore] = null;
1399
- pluginState[strTeardown] = true;
1400
- pluginState[strIsInitialized] = false;
1401
- if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1402
- hasRun = true;
1403
- }
1404
- }
1405
- }
1406
- return hasRun;
1407
- }
1408
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1409
- unloadCtx.processNext(unloadState);
1410
- }
1411
- }
1412
- function _updatePlugin(updateCtx, updateState) {
1413
- function _callUpdate() {
1414
- var hasRun = false;
1415
- if (plugin) {
1416
- var pluginState = _getPluginState(plugin);
1417
- var pluginCore = plugin[strCore] || pluginState.core;
1418
- if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1419
- if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1420
- hasRun = true;
1421
- }
1422
- }
987
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
988
+ };
989
+ _self.hasNext = function () {
990
+ return _nextProxy != null;
991
+ };
992
+ _self.getNext = function () {
993
+ return _nextProxy;
994
+ };
995
+ _self.setNext = function (nextPlugin) {
996
+ _nextProxy = nextPlugin;
997
+ };
998
+ _self.processNext = function (env) {
999
+ var nextPlugin = _nextProxy;
1000
+ if (nextPlugin) {
1001
+ _nextProxy = nextPlugin.getNext();
1002
+ nextPlugin.processTelemetry(env, _self);
1423
1003
  }
1424
- return hasRun;
1425
- }
1426
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1427
- updateCtx.processNext(updateState);
1428
- }
1004
+ };
1005
+ _self.createNew = function (plugins, startAt) {
1006
+ if (plugins === void 0) { plugins = null; }
1007
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1008
+ };
1429
1009
  }
1430
- return objFreeze(proxyChain);
1431
- }
1010
+ return ProcessTelemetryContext;
1011
+ }());
1432
1012
 
1433
1013
  var strExtensionConfig = "extensionConfig";
1434
1014
 
1435
- function createUnloadHandlerContainer() {
1436
- var handlers = [];
1437
- function _addHandler(handler) {
1438
- if (handler) {
1439
- handlers.push(handler);
1440
- }
1441
- }
1442
- function _runHandlers(unloadCtx, unloadState) {
1443
- arrForEach(handlers, function (handler) {
1444
- try {
1445
- handler(unloadCtx, unloadState);
1446
- }
1447
- catch (e) {
1448
- _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1449
- }
1450
- });
1451
- handlers = [];
1452
- }
1453
- return {
1454
- add: _addHandler,
1455
- run: _runHandlers
1456
- };
1457
- }
1458
-
1459
1015
  var strGetPlugin = "getPlugin";
1460
1016
  var BaseTelemetryPlugin = /** @class */ (function () {
1461
1017
  function BaseTelemetryPlugin() {
1462
1018
  var _self = this;
1463
- var _isinitialized;
1464
- var _rootCtx;
1465
- var _nextPlugin;
1466
- var _unloadHandlerContainer;
1467
- var _hooks;
1468
- _initDefaults();
1469
- dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1470
- _self.initialize = function (config, core, extensions, pluginChain) {
1471
- _setDefaults(config, core, pluginChain);
1472
- _isinitialized = true;
1473
- };
1474
- _self.teardown = function (unloadCtx, unloadState) {
1475
- if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1476
- return;
1477
- }
1478
- var result;
1479
- var unloadDone = false;
1480
- var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1481
- var theUnloadState = unloadState || {
1482
- reason: 0 ,
1483
- isAsync: false
1484
- };
1485
- function _unloadCallback() {
1486
- if (!unloadDone) {
1487
- unloadDone = true;
1488
- _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1489
- arrForEach(_hooks, function (fn) {
1490
- fn.rm();
1491
- });
1492
- _hooks = [];
1493
- if (result === true) {
1494
- theUnloadCtx.processNext(theUnloadState);
1495
- }
1496
- _initDefaults();
1497
- }
1498
- }
1499
- if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1500
- _unloadCallback();
1501
- }
1502
- else {
1503
- result = true;
1504
- }
1505
- return result;
1506
- };
1507
- _self.update = function (updateCtx, updateState) {
1508
- if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1509
- return;
1510
- }
1511
- var result;
1512
- var updateDone = false;
1513
- var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1514
- var theUpdateState = updateState || {
1515
- reason: 0
1516
- };
1517
- function _updateCallback() {
1518
- if (!updateDone) {
1519
- updateDone = true;
1520
- _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1521
- }
1522
- }
1523
- if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1524
- _updateCallback();
1525
- }
1526
- else {
1527
- result = true;
1528
- }
1529
- return result;
1530
- };
1531
- _self._addHook = function (hooks) {
1532
- if (hooks) {
1533
- if (isArray(hooks)) {
1534
- _hooks = _hooks.concat(hooks);
1535
- }
1536
- else {
1537
- _hooks.push(hooks);
1538
- }
1539
- }
1540
- };
1541
- proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1542
- });
1019
+ var _isinitialized = false;
1020
+ var _rootCtx = null;
1021
+ var _nextPlugin = null;
1022
+ _self.core = null;
1543
1023
  _self.diagLog = function (itemCtx) {
1544
- return _getTelCtx(itemCtx).diagLog();
1024
+ return _self._getTelCtx(itemCtx).diagLog();
1545
1025
  };
1546
- _self[strIsInitialized] = function () {
1026
+ _self.isInitialized = function () {
1547
1027
  return _isinitialized;
1548
1028
  };
1549
1029
  _self.setInitialized = function (isInitialized) {
1550
1030
  _isinitialized = isInitialized;
1551
1031
  };
1552
- _self[strSetNextPlugin] = function (next) {
1032
+ _self.setNextPlugin = function (next) {
1553
1033
  _nextPlugin = next;
1554
1034
  };
1555
1035
  _self.processNext = function (env, itemCtx) {
@@ -1560,12 +1040,11 @@
1560
1040
  _nextPlugin.processTelemetry(env, null);
1561
1041
  }
1562
1042
  };
1563
- _self._getTelCtx = _getTelCtx;
1564
- function _getTelCtx(currentCtx) {
1043
+ _self._getTelCtx = function (currentCtx) {
1565
1044
  if (currentCtx === void 0) { currentCtx = null; }
1566
1045
  var itemCtx = currentCtx;
1567
1046
  if (!itemCtx) {
1568
- var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1047
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1569
1048
  if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1570
1049
  itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1571
1050
  }
@@ -1574,8 +1053,8 @@
1574
1053
  }
1575
1054
  }
1576
1055
  return itemCtx;
1577
- }
1578
- function _setDefaults(config, core, pluginChain) {
1056
+ };
1057
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1579
1058
  if (config) {
1580
1059
  setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1581
1060
  }
@@ -1587,109 +1066,16 @@
1587
1066
  nextPlugin = _nextPlugin[strGetPlugin]();
1588
1067
  }
1589
1068
  _self.core = core;
1590
- _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1591
- }
1592
- function _initDefaults() {
1593
- _isinitialized = false;
1594
- _self.core = null;
1595
- _rootCtx = null;
1596
- _nextPlugin = null;
1597
- _hooks = [];
1598
- _unloadHandlerContainer = createUnloadHandlerContainer();
1599
- }
1069
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1070
+ _isinitialized = true;
1071
+ };
1600
1072
  }
1073
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1074
+ this._baseTelInit(config, core, extensions, pluginChain);
1075
+ };
1601
1076
  return BaseTelemetryPlugin;
1602
1077
  }());
1603
1078
 
1604
- var LoggingSeverity = createEnumStyle({
1605
- CRITICAL: 1 ,
1606
- WARNING: 2
1607
- });
1608
- var _InternalMessageId = createEnumStyle({
1609
- BrowserDoesNotSupportLocalStorage: 0 ,
1610
- BrowserCannotReadLocalStorage: 1 ,
1611
- BrowserCannotReadSessionStorage: 2 ,
1612
- BrowserCannotWriteLocalStorage: 3 ,
1613
- BrowserCannotWriteSessionStorage: 4 ,
1614
- BrowserFailedRemovalFromLocalStorage: 5 ,
1615
- BrowserFailedRemovalFromSessionStorage: 6 ,
1616
- CannotSendEmptyTelemetry: 7 ,
1617
- ClientPerformanceMathError: 8 ,
1618
- ErrorParsingAISessionCookie: 9 ,
1619
- ErrorPVCalc: 10 ,
1620
- ExceptionWhileLoggingError: 11 ,
1621
- FailedAddingTelemetryToBuffer: 12 ,
1622
- FailedMonitorAjaxAbort: 13 ,
1623
- FailedMonitorAjaxDur: 14 ,
1624
- FailedMonitorAjaxOpen: 15 ,
1625
- FailedMonitorAjaxRSC: 16 ,
1626
- FailedMonitorAjaxSend: 17 ,
1627
- FailedMonitorAjaxGetCorrelationHeader: 18 ,
1628
- FailedToAddHandlerForOnBeforeUnload: 19 ,
1629
- FailedToSendQueuedTelemetry: 20 ,
1630
- FailedToReportDataLoss: 21 ,
1631
- FlushFailed: 22 ,
1632
- MessageLimitPerPVExceeded: 23 ,
1633
- MissingRequiredFieldSpecification: 24 ,
1634
- NavigationTimingNotSupported: 25 ,
1635
- OnError: 26 ,
1636
- SessionRenewalDateIsZero: 27 ,
1637
- SenderNotInitialized: 28 ,
1638
- StartTrackEventFailed: 29 ,
1639
- StopTrackEventFailed: 30 ,
1640
- StartTrackFailed: 31 ,
1641
- StopTrackFailed: 32 ,
1642
- TelemetrySampledAndNotSent: 33 ,
1643
- TrackEventFailed: 34 ,
1644
- TrackExceptionFailed: 35 ,
1645
- TrackMetricFailed: 36 ,
1646
- TrackPVFailed: 37 ,
1647
- TrackPVFailedCalc: 38 ,
1648
- TrackTraceFailed: 39 ,
1649
- TransmissionFailed: 40 ,
1650
- FailedToSetStorageBuffer: 41 ,
1651
- FailedToRestoreStorageBuffer: 42 ,
1652
- InvalidBackendResponse: 43 ,
1653
- FailedToFixDepricatedValues: 44 ,
1654
- InvalidDurationValue: 45 ,
1655
- TelemetryEnvelopeInvalid: 46 ,
1656
- CreateEnvelopeError: 47 ,
1657
- CannotSerializeObject: 48 ,
1658
- CannotSerializeObjectNonSerializable: 49 ,
1659
- CircularReferenceDetected: 50 ,
1660
- ClearAuthContextFailed: 51 ,
1661
- ExceptionTruncated: 52 ,
1662
- IllegalCharsInName: 53 ,
1663
- ItemNotInArray: 54 ,
1664
- MaxAjaxPerPVExceeded: 55 ,
1665
- MessageTruncated: 56 ,
1666
- NameTooLong: 57 ,
1667
- SampleRateOutOfRange: 58 ,
1668
- SetAuthContextFailed: 59 ,
1669
- SetAuthContextFailedAccountName: 60 ,
1670
- StringValueTooLong: 61 ,
1671
- StartCalledMoreThanOnce: 62 ,
1672
- StopCalledWithoutStart: 63 ,
1673
- TelemetryInitializerFailed: 64 ,
1674
- TrackArgumentsNotSpecified: 65 ,
1675
- UrlTooLong: 66 ,
1676
- SessionStorageBufferFull: 67 ,
1677
- CannotAccessCookie: 68 ,
1678
- IdTooLong: 69 ,
1679
- InvalidEvent: 70 ,
1680
- FailedMonitorAjaxSetRequestHeader: 71 ,
1681
- SendBrowserInfoOnUserInit: 72 ,
1682
- PluginException: 73 ,
1683
- NotificationException: 74 ,
1684
- SnippetScriptLoadFailure: 99 ,
1685
- InvalidInstrumentationKey: 100 ,
1686
- CannotParseAiBlobValue: 101 ,
1687
- InvalidContentBlob: 102 ,
1688
- TrackPageActionEventFailed: 103 ,
1689
- FailedAddingCustomDefinedRequestContext: 104 ,
1690
- InMemoryStorageBufferFull: 105
1691
- });
1692
-
1693
1079
  var SeverityLevel;
1694
1080
  (function (SeverityLevel) {
1695
1081
  SeverityLevel[SeverityLevel["Verbose"] = 0] = "Verbose";
@@ -1733,12 +1119,11 @@
1733
1119
  var _this = _super.call(this) || this;
1734
1120
  _this.identifier = "AppInsightsReactNativePlugin";
1735
1121
  _this.priority = 140;
1736
- var _device;
1737
- var _config;
1122
+ var _device = {};
1123
+ var _config = config || _getDefaultConfig();
1738
1124
  var _analyticsPlugin;
1739
1125
  var _defaultHandler;
1740
1126
  dynamicProto(ReactNativePlugin, _this, function (_self, _base) {
1741
- _initDefaults();
1742
1127
  _self.initialize = function (config,
1743
1128
  core, extensions) {
1744
1129
  if (!_self.isInitialized()) {
@@ -1787,16 +1172,6 @@
1787
1172
  _self.diagLog().warnToConsole("Failed to get DeviceInfo: " + getExceptionName(e) + " - " + dumpObj(e));
1788
1173
  }
1789
1174
  };
1790
- _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
1791
- _resetGlobalErrorHandler();
1792
- _initDefaults();
1793
- };
1794
- function _initDefaults() {
1795
- _device = {};
1796
- _config = config || _getDefaultConfig();
1797
- _analyticsPlugin = null;
1798
- _defaultHandler = null;
1799
- }
1800
1175
  function _applyDeviceContext(item) {
1801
1176
  if (_device) {
1802
1177
  item.ext = item.ext || {};
@@ -1822,15 +1197,9 @@
1822
1197
  var _global = _getGlobal();
1823
1198
  if (_global && _global.ErrorUtils) {
1824
1199
  _defaultHandler = (typeof _global.ErrorUtils.getGlobalHandler === "function" && _global.ErrorUtils.getGlobalHandler()) || _global.ErrorUtils._globalHandler;
1825
- _global.ErrorUtils.setGlobalHandler(_trackException);
1200
+ _global.ErrorUtils.setGlobalHandler(_trackException.bind(_this));
1826
1201
  }
1827
1202
  };
1828
- function _resetGlobalErrorHandler() {
1829
- var _global = _getGlobal();
1830
- if (_global && _global.ErrorUtils && _global.ErrorUtils.getGlobalHandler() === _trackException) {
1831
- _global.ErrorUtils.setGlobalHandler(_defaultHandler || null);
1832
- }
1833
- }
1834
1203
  function _trackException(e, isFatal) {
1835
1204
  var exception = { exception: e, severityLevel: SeverityLevel.Error };
1836
1205
  if (_analyticsPlugin) {