@microsoft/applicationinsights-clickanalytics-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-04

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 (79) hide show
  1. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.js +2883 -0
  2. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.js.map +1 -0
  3. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.min.js +6 -0
  4. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.min.js.map +1 -0
  5. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.js +2887 -0
  6. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.js.map +1 -0
  7. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.min.js +6 -0
  8. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.min.js.map +1 -0
  9. package/browser/ai.clck.2.8.0-nightly.2204-04.integrity.json +66 -0
  10. package/browser/ai.clck.2.8.0-nightly.2204-04.js +2889 -0
  11. package/browser/ai.clck.2.8.0-nightly.2204-04.js.map +1 -0
  12. package/browser/ai.clck.2.8.0-nightly.2204-04.min.js +6 -0
  13. package/browser/ai.clck.2.8.0-nightly.2204-04.min.js.map +1 -0
  14. package/browser/ai.clck.2.cjs.js +1685 -808
  15. package/browser/ai.clck.2.cjs.js.map +1 -1
  16. package/browser/ai.clck.2.cjs.min.js +2 -2
  17. package/browser/ai.clck.2.cjs.min.js.map +1 -1
  18. package/browser/ai.clck.2.gbl.js +1685 -808
  19. package/browser/ai.clck.2.gbl.js.map +1 -1
  20. package/browser/ai.clck.2.gbl.min.js +2 -2
  21. package/browser/ai.clck.2.gbl.min.js.map +1 -1
  22. package/browser/ai.clck.2.js +1685 -808
  23. package/browser/ai.clck.2.js.map +1 -1
  24. package/browser/ai.clck.2.min.js +2 -2
  25. package/browser/ai.clck.2.min.js.map +1 -1
  26. package/dist/applicationinsights-clickanalytics-js.api.json +38 -13
  27. package/dist/applicationinsights-clickanalytics-js.api.md +1 -0
  28. package/dist/applicationinsights-clickanalytics-js.d.ts +2 -5
  29. package/dist/applicationinsights-clickanalytics-js.js +1685 -808
  30. package/dist/applicationinsights-clickanalytics-js.js.map +1 -1
  31. package/dist/applicationinsights-clickanalytics-js.min.js +2 -2
  32. package/dist/applicationinsights-clickanalytics-js.min.js.map +1 -1
  33. package/dist/applicationinsights-clickanalytics-js.rollup.d.ts +2 -5
  34. package/dist-esm/Behaviours.js +1 -1
  35. package/dist-esm/ClickAnalyticsPlugin.js +74 -50
  36. package/dist-esm/ClickAnalyticsPlugin.js.map +1 -1
  37. package/dist-esm/DataCollector.js +4 -2
  38. package/dist-esm/DataCollector.js.map +1 -1
  39. package/dist-esm/Enums.js +1 -1
  40. package/dist-esm/Interfaces/Datamodel.js +1 -1
  41. package/dist-esm/applicationinsights-clickanalytics-js.js +1 -1
  42. package/dist-esm/common/Utils.js +1 -1
  43. package/dist-esm/events/PageAction.js +128 -126
  44. package/dist-esm/events/PageAction.js.map +1 -1
  45. package/dist-esm/events/WebEvent.js +109 -94
  46. package/dist-esm/events/WebEvent.js.map +1 -1
  47. package/dist-esm/handlers/AutoCaptureHandler.js +85 -83
  48. package/dist-esm/handlers/AutoCaptureHandler.js.map +1 -1
  49. package/dist-esm/handlers/DomContentHandler.js +279 -276
  50. package/dist-esm/handlers/DomContentHandler.js.map +1 -1
  51. package/package.json +5 -5
  52. package/src/ClickAnalyticsPlugin.ts +92 -47
  53. package/src/DataCollector.ts +24 -22
  54. package/src/Interfaces/Datamodel.ts +20 -21
  55. package/src/common/Utils.ts +8 -8
  56. package/src/events/PageAction.ts +165 -131
  57. package/src/events/WebEvent.ts +147 -78
  58. package/src/handlers/AutoCaptureHandler.ts +89 -79
  59. package/src/handlers/DomContentHandler.ts +336 -303
  60. package/types/ClickAnalyticsPlugin.d.ts +1 -4
  61. package/types/Interfaces/Datamodel.d.ts +3 -2
  62. package/types/events/PageAction.d.ts +6 -6
  63. package/types/events/WebEvent.d.ts +17 -17
  64. package/types/handlers/AutoCaptureHandler.d.ts +2 -10
  65. package/types/handlers/DomContentHandler.d.ts +3 -50
  66. package/types/tsdoc-metadata.json +1 -1
  67. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.js +0 -2006
  68. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.js.map +0 -1
  69. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.min.js +0 -6
  70. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.min.js.map +0 -1
  71. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.js +0 -2010
  72. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.js.map +0 -1
  73. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.min.js +0 -6
  74. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.min.js.map +0 -1
  75. package/browser/ai.clck.2.8.0-nightly.2202-06.integrity.json +0 -66
  76. package/browser/ai.clck.2.8.0-nightly.2202-06.js +0 -2012
  77. package/browser/ai.clck.2.8.0-nightly.2202-06.js.map +0 -1
  78. package/browser/ai.clck.2.8.0-nightly.2202-06.min.js +0 -6
  79. package/browser/ai.clck.2.8.0-nightly.2202-06.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Click Analytics, 2.8.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - Click Analytics, 2.8.0-nightly.2204-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  this.Microsoft = this.Microsoft || {};
@@ -73,7 +73,9 @@ this.Microsoft = this.Microsoft || {};
73
73
  var __assignFn = ObjAssign || __objAssignFnImpl;
74
74
  var extendStaticsFn = function (d, b) {
75
75
  extendStaticsFn = ObjClass["setPrototypeOf"] ||
76
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
76
+ ({ __proto__: [] } instanceof Array && function (d, b) {
77
+ d.__proto__ = b;
78
+ }) ||
77
79
  function (d, b) {
78
80
  for (var p in b) {
79
81
  if (b[strShimHasOwnProperty](p)) {
@@ -88,7 +90,9 @@ this.Microsoft = this.Microsoft || {};
88
90
  throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
89
91
  }
90
92
  extendStaticsFn(d, b);
91
- function __() { this.constructor = d; }
93
+ function __() {
94
+ this.constructor = d;
95
+ }
92
96
  d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
93
97
  }
94
98
 
@@ -107,11 +111,11 @@ this.Microsoft = this.Microsoft || {};
107
111
  var DynAllowInstChkTag = DynInstChkTag;
108
112
  var DynProtoDefaultOptions = '_dfOpts';
109
113
  var UnknownValue = '_unknown_';
110
- var str__Proto = "__proto__";
114
+ var str__Proto$1 = "__proto__";
111
115
  var strUseBaseInst = 'useBaseInst';
112
116
  var strSetInstFuncs = 'setInstFuncs';
113
117
  var Obj = Object;
114
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
118
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
115
119
  var _dynamicNames = 0;
116
120
  function _hasOwnProperty(obj, prop) {
117
121
  return obj && Obj[Prototype$1].hasOwnProperty.call(obj, prop);
@@ -122,12 +126,12 @@ this.Microsoft = this.Microsoft || {};
122
126
  function _isObjectArrayOrFunctionPrototype(target) {
123
127
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype$1];
124
128
  }
125
- function _getObjProto(target) {
129
+ function _getObjProto$1(target) {
126
130
  if (target) {
127
- if (_objGetPrototypeOf) {
128
- return _objGetPrototypeOf(target);
131
+ if (_objGetPrototypeOf$1) {
132
+ return _objGetPrototypeOf$1(target);
129
133
  }
130
- var newProto = target[str__Proto] || target[Prototype$1] || (target[Constructor] ? target[Constructor][Prototype$1] : null);
134
+ var newProto = target[str__Proto$1] || target[Prototype$1] || (target[Constructor] ? target[Constructor][Prototype$1] : null);
131
135
  if (newProto) {
132
136
  return newProto;
133
137
  }
@@ -193,16 +197,16 @@ this.Microsoft = this.Microsoft || {};
193
197
  _forEachProp(instFuncs, function (name) {
194
198
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
195
199
  });
196
- var baseProto = _getObjProto(classProto);
200
+ var baseProto = _getObjProto$1(classProto);
197
201
  var visited = [];
198
202
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
199
203
  _forEachProp(baseProto, function (name) {
200
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
204
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
201
205
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
202
206
  }
203
207
  });
204
208
  visited.push(baseProto);
205
- baseProto = _getObjProto(baseProto);
209
+ baseProto = _getObjProto$1(baseProto);
206
210
  }
207
211
  return baseFuncs;
208
212
  }
@@ -216,7 +220,7 @@ this.Microsoft = this.Microsoft || {};
216
220
  }
217
221
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
218
222
  var canAddInst = !_hasOwnProperty(target, funcName);
219
- var objProto = _getObjProto(target);
223
+ var objProto = _getObjProto$1(target);
220
224
  var visited = [];
221
225
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
222
226
  var protoFunc = objProto[funcName];
@@ -225,7 +229,7 @@ this.Microsoft = this.Microsoft || {};
225
229
  break;
226
230
  }
227
231
  visited.push(objProto);
228
- objProto = _getObjProto(objProto);
232
+ objProto = _getObjProto$1(objProto);
229
233
  }
230
234
  try {
231
235
  if (canAddInst) {
@@ -243,7 +247,7 @@ this.Microsoft = this.Microsoft || {};
243
247
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
244
248
  var protoFunc = proto[funcName];
245
249
  if (protoFunc === currentDynProtoProxy) {
246
- protoFunc = _getObjProto(proto)[funcName];
250
+ protoFunc = _getObjProto$1(proto)[funcName];
247
251
  }
248
252
  if (typeof protoFunc !== strFunction) {
249
253
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -277,15 +281,15 @@ this.Microsoft = this.Microsoft || {};
277
281
  }
278
282
  }
279
283
  function _checkPrototype(classProto, thisTarget) {
280
- if (_objGetPrototypeOf) {
284
+ if (_objGetPrototypeOf$1) {
281
285
  var visited = [];
282
- var thisProto = _getObjProto(thisTarget);
286
+ var thisProto = _getObjProto$1(thisTarget);
283
287
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
284
288
  if (thisProto === classProto) {
285
289
  return true;
286
290
  }
287
291
  visited.push(thisProto);
288
- thisProto = _getObjProto(thisProto);
292
+ thisProto = _getObjProto$1(thisProto);
289
293
  }
290
294
  }
291
295
  return false;
@@ -321,7 +325,7 @@ this.Microsoft = this.Microsoft || {};
321
325
  var instFuncs = _getInstanceFuncs(target);
322
326
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
323
327
  delegateFunc(target, baseFuncs);
324
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
328
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
325
329
  if (setInstanceFunc && options) {
326
330
  setInstanceFunc = !!options[strSetInstFuncs];
327
331
  }
@@ -333,105 +337,52 @@ this.Microsoft = this.Microsoft || {};
333
337
  };
334
338
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
335
339
 
336
- var LoggingSeverity;
337
- (function (LoggingSeverity) {
338
- LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
339
- LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
340
- })(LoggingSeverity || (LoggingSeverity = {}));
341
- var _InternalMessageId = {
342
- BrowserDoesNotSupportLocalStorage: 0,
343
- BrowserCannotReadLocalStorage: 1,
344
- BrowserCannotReadSessionStorage: 2,
345
- BrowserCannotWriteLocalStorage: 3,
346
- BrowserCannotWriteSessionStorage: 4,
347
- BrowserFailedRemovalFromLocalStorage: 5,
348
- BrowserFailedRemovalFromSessionStorage: 6,
349
- CannotSendEmptyTelemetry: 7,
350
- ClientPerformanceMathError: 8,
351
- ErrorParsingAISessionCookie: 9,
352
- ErrorPVCalc: 10,
353
- ExceptionWhileLoggingError: 11,
354
- FailedAddingTelemetryToBuffer: 12,
355
- FailedMonitorAjaxAbort: 13,
356
- FailedMonitorAjaxDur: 14,
357
- FailedMonitorAjaxOpen: 15,
358
- FailedMonitorAjaxRSC: 16,
359
- FailedMonitorAjaxSend: 17,
360
- FailedMonitorAjaxGetCorrelationHeader: 18,
361
- FailedToAddHandlerForOnBeforeUnload: 19,
362
- FailedToSendQueuedTelemetry: 20,
363
- FailedToReportDataLoss: 21,
364
- FlushFailed: 22,
365
- MessageLimitPerPVExceeded: 23,
366
- MissingRequiredFieldSpecification: 24,
367
- NavigationTimingNotSupported: 25,
368
- OnError: 26,
369
- SessionRenewalDateIsZero: 27,
370
- SenderNotInitialized: 28,
371
- StartTrackEventFailed: 29,
372
- StopTrackEventFailed: 30,
373
- StartTrackFailed: 31,
374
- StopTrackFailed: 32,
375
- TelemetrySampledAndNotSent: 33,
376
- TrackEventFailed: 34,
377
- TrackExceptionFailed: 35,
378
- TrackMetricFailed: 36,
379
- TrackPVFailed: 37,
380
- TrackPVFailedCalc: 38,
381
- TrackTraceFailed: 39,
382
- TransmissionFailed: 40,
383
- FailedToSetStorageBuffer: 41,
384
- FailedToRestoreStorageBuffer: 42,
385
- InvalidBackendResponse: 43,
386
- FailedToFixDepricatedValues: 44,
387
- InvalidDurationValue: 45,
388
- TelemetryEnvelopeInvalid: 46,
389
- CreateEnvelopeError: 47,
390
- CannotSerializeObject: 48,
391
- CannotSerializeObjectNonSerializable: 49,
392
- CircularReferenceDetected: 50,
393
- ClearAuthContextFailed: 51,
394
- ExceptionTruncated: 52,
395
- IllegalCharsInName: 53,
396
- ItemNotInArray: 54,
397
- MaxAjaxPerPVExceeded: 55,
398
- MessageTruncated: 56,
399
- NameTooLong: 57,
400
- SampleRateOutOfRange: 58,
401
- SetAuthContextFailed: 59,
402
- SetAuthContextFailedAccountName: 60,
403
- StringValueTooLong: 61,
404
- StartCalledMoreThanOnce: 62,
405
- StopCalledWithoutStart: 63,
406
- TelemetryInitializerFailed: 64,
407
- TrackArgumentsNotSpecified: 65,
408
- UrlTooLong: 66,
409
- SessionStorageBufferFull: 67,
410
- CannotAccessCookie: 68,
411
- IdTooLong: 69,
412
- InvalidEvent: 70,
413
- FailedMonitorAjaxSetRequestHeader: 71,
414
- SendBrowserInfoOnUserInit: 72,
415
- PluginException: 73,
416
- NotificationException: 74,
417
- SnippetScriptLoadFailure: 99,
418
- InvalidInstrumentationKey: 100,
419
- CannotParseAiBlobValue: 101,
420
- InvalidContentBlob: 102,
421
- TrackPageActionEventFailed: 103,
422
- FailedAddingCustomDefinedRequestContext: 104,
423
- InMemoryStorageBufferFull: 105
424
- };
340
+ var strEmpty = "";
341
+ var strSetNextPlugin = "setNextPlugin";
342
+ var strIsInitialized = "isInitialized";
343
+ var strTeardown = "teardown";
344
+ var strCore = "core";
345
+ var strUpdate = "update";
346
+ var strDisabled = "disabled";
347
+ var strDoTeardown = "_doTeardown";
425
348
 
426
- var strOnPrefix = "on";
427
- var strAttachEvent = "attachEvent";
428
- var strAddEventHelper = "addEventListener";
349
+ var strToISOString = "toISOString";
350
+ var cStrEndsWith = "endsWith";
351
+ var cStrStartsWith = "startsWith";
352
+ var cStrTrim = "trim";
429
353
  var strToString = "toString";
430
- var _objDefineProperty = ObjDefineProperty;
354
+ var str__Proto = "__proto__";
355
+ var strConstructor = "constructor";
356
+ var _objDefineProperty$1 = ObjDefineProperty;
357
+ var _objFreeze = ObjClass.freeze;
358
+ ObjClass.seal;
359
+ var _objKeys = ObjClass.keys;
360
+ var StringProto = String[strShimPrototype];
361
+ StringProto[cStrTrim];
362
+ StringProto[cStrEndsWith];
363
+ StringProto[cStrStartsWith];
364
+ var DateProto = Date[strShimPrototype];
365
+ DateProto[strToISOString];
431
366
  var _isArray = Array.isArray;
432
367
  var _objToString = ObjProto[strToString];
433
368
  var _fnToString = ObjHasOwnProperty[strToString];
434
- _fnToString.call(ObjClass);
369
+ var _objFunctionString = _fnToString.call(ObjClass);
370
+ var rCamelCase = /-([a-z])/g;
371
+ var rNormalizeInvalid = /([^\w\d_$])/g;
372
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
373
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
374
+ function _getObjProto(target) {
375
+ if (target) {
376
+ if (_objGetPrototypeOf) {
377
+ return _objGetPrototypeOf(target);
378
+ }
379
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
380
+ if (newProto) {
381
+ return newProto;
382
+ }
383
+ }
384
+ return null;
385
+ }
435
386
  function isUndefined(value) {
436
387
  return value === undefined || typeof value === strShimUndefined;
437
388
  }
@@ -441,27 +392,24 @@ this.Microsoft = this.Microsoft || {};
441
392
  function hasOwnProperty(obj, prop) {
442
393
  return !!(obj && ObjHasOwnProperty.call(obj, prop));
443
394
  }
395
+ function isObject(value) {
396
+ return !!(value && typeof value === strShimObject);
397
+ }
444
398
  function isFunction(value) {
445
399
  return !!(value && typeof value === strShimFunction);
446
400
  }
447
- function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
448
- if (useCapture === void 0) { useCapture = false; }
449
- var result = false;
450
- if (!isNullOrUndefined(obj)) {
451
- try {
452
- if (!isNullOrUndefined(obj[strAddEventHelper])) {
453
- obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
454
- result = true;
455
- }
456
- else if (!isNullOrUndefined(obj[strAttachEvent])) {
457
- obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
458
- result = true;
459
- }
460
- }
461
- catch (e) {
462
- }
401
+ function normalizeJsName(name) {
402
+ var value = name;
403
+ if (value && isString(value)) {
404
+ value = value.replace(rCamelCase, function (_all, letter) {
405
+ return letter.toUpperCase();
406
+ });
407
+ value = value.replace(rNormalizeInvalid, "_");
408
+ value = value.replace(rLeadingNumeric, function (_all, match) {
409
+ return "_" + match;
410
+ });
463
411
  }
464
- return result;
412
+ return value;
465
413
  }
466
414
  function objForEachKey(target, callbackfn) {
467
415
  if (target) {
@@ -472,6 +420,12 @@ this.Microsoft = this.Microsoft || {};
472
420
  }
473
421
  }
474
422
  }
423
+ function strContains(value, search) {
424
+ if (value && search) {
425
+ return value.indexOf(search) !== -1;
426
+ }
427
+ return false;
428
+ }
475
429
  var isArray = _isArray || _isArrayPoly;
476
430
  function _isArrayPoly(obj) {
477
431
  return !!(obj && _objToString.call(obj) === "[object Array]");
@@ -479,6 +433,28 @@ this.Microsoft = this.Microsoft || {};
479
433
  function isError(obj) {
480
434
  return !!(obj && _objToString.call(obj) === "[object Error]");
481
435
  }
436
+ function isString(value) {
437
+ return typeof value === "string";
438
+ }
439
+ function isBoolean(value) {
440
+ return typeof value === "boolean";
441
+ }
442
+ function isPlainObject(value) {
443
+ var result = false;
444
+ if (value && typeof value === "object") {
445
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
446
+ if (!proto) {
447
+ result = true;
448
+ }
449
+ else {
450
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
451
+ proto = proto[strConstructor];
452
+ }
453
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
454
+ }
455
+ }
456
+ return result;
457
+ }
482
458
  function arrForEach(arr, callbackfn, thisArg) {
483
459
  var len = arr.length;
484
460
  try {
@@ -493,8 +469,42 @@ this.Microsoft = this.Microsoft || {};
493
469
  catch (e) {
494
470
  }
495
471
  }
472
+ var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
473
+ var _objKeysDontEnums = [
474
+ "toString",
475
+ "toLocaleString",
476
+ "valueOf",
477
+ "hasOwnProperty",
478
+ "isPrototypeOf",
479
+ "propertyIsEnumerable",
480
+ "constructor"
481
+ ];
482
+ function objKeys(obj) {
483
+ var objType = typeof obj;
484
+ if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
485
+ throwTypeError("objKeys called on non-object");
486
+ }
487
+ if (!_objKeysHasDontEnumBug && _objKeys) {
488
+ return _objKeys(obj);
489
+ }
490
+ var result = [];
491
+ for (var prop in obj) {
492
+ if (obj && ObjHasOwnProperty.call(obj, prop)) {
493
+ result.push(prop);
494
+ }
495
+ }
496
+ if (_objKeysHasDontEnumBug) {
497
+ var dontEnumsLength = _objKeysDontEnums.length;
498
+ for (var lp = 0; lp < dontEnumsLength; lp++) {
499
+ if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
500
+ result.push(_objKeysDontEnums[lp]);
501
+ }
502
+ }
503
+ }
504
+ return result;
505
+ }
496
506
  function objDefineAccessors(target, prop, getProp, setProp) {
497
- if (_objDefineProperty) {
507
+ if (_objDefineProperty$1) {
498
508
  try {
499
509
  var descriptor = {
500
510
  enumerable: true,
@@ -506,7 +516,7 @@ this.Microsoft = this.Microsoft || {};
506
516
  if (setProp) {
507
517
  descriptor.set = setProp;
508
518
  }
509
- _objDefineProperty(target, prop, descriptor);
519
+ _objDefineProperty$1(target, prop, descriptor);
510
520
  return true;
511
521
  }
512
522
  catch (e) {
@@ -514,6 +524,10 @@ this.Microsoft = this.Microsoft || {};
514
524
  }
515
525
  return false;
516
526
  }
527
+ function _doNothing(value) {
528
+ return value;
529
+ }
530
+ var objFreeze = _objFreeze || _doNothing;
517
531
  function dateNow() {
518
532
  var dt = Date;
519
533
  return dt.now ? dt.now() : new dt().getTime();
@@ -522,7 +536,7 @@ this.Microsoft = this.Microsoft || {};
522
536
  if (isError(object)) {
523
537
  return object.name;
524
538
  }
525
- return "";
539
+ return strEmpty;
526
540
  }
527
541
  function setValue(target, field, value, valChk, srcChk) {
528
542
  var theValue = value;
@@ -535,13 +549,105 @@ this.Microsoft = this.Microsoft || {};
535
549
  }
536
550
  return theValue;
537
551
  }
552
+ function throwError(message) {
553
+ throw new Error(message);
554
+ }
555
+ function _createProxyFunction(source, funcName) {
556
+ var srcFunc = null;
557
+ var src = null;
558
+ if (isFunction(source)) {
559
+ srcFunc = source;
560
+ }
561
+ else {
562
+ src = source;
563
+ }
564
+ return function () {
565
+ var originalArguments = arguments;
566
+ if (srcFunc) {
567
+ src = srcFunc();
568
+ }
569
+ if (src) {
570
+ return src[funcName].apply(src, originalArguments);
571
+ }
572
+ };
573
+ }
574
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
575
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
576
+ if (target && name && source) {
577
+ if (overwriteTarget || isUndefined(target[name])) {
578
+ target[name] = _createProxyFunction(source, theFunc);
579
+ }
580
+ }
581
+ }
582
+ function createEnumStyle(values) {
583
+ var enumClass = {};
584
+ objForEachKey(values, function (field, value) {
585
+ enumClass[field] = value;
586
+ if (!isUndefined(enumClass[value])) {
587
+ throwError("[" + value + "] exists for " + field);
588
+ }
589
+ enumClass[value] = field;
590
+ });
591
+ return objFreeze(enumClass);
592
+ }
593
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
594
+ var theArgs = arguments;
595
+ var extended = theArgs[0] || {};
596
+ var argLen = theArgs.length;
597
+ var deep = false;
598
+ var idx = 1;
599
+ if (argLen > 0 && isBoolean(extended)) {
600
+ deep = extended;
601
+ extended = theArgs[idx] || {};
602
+ idx++;
603
+ }
604
+ if (!isObject(extended)) {
605
+ extended = {};
606
+ }
607
+ for (; idx < argLen; idx++) {
608
+ var arg = theArgs[idx];
609
+ var isArgArray = isArray(arg);
610
+ var isArgObj = isObject(arg);
611
+ for (var prop in arg) {
612
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
613
+ if (!propOk) {
614
+ continue;
615
+ }
616
+ var newValue = arg[prop];
617
+ var isNewArray = void 0;
618
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
619
+ var clone = extended[prop];
620
+ if (isNewArray) {
621
+ if (!isArray(clone)) {
622
+ clone = [];
623
+ }
624
+ }
625
+ else if (!isPlainObject(clone)) {
626
+ clone = {};
627
+ }
628
+ newValue = objExtend(deep, clone, newValue);
629
+ }
630
+ if (newValue !== undefined) {
631
+ extended[prop] = newValue;
632
+ }
633
+ }
634
+ }
635
+ return extended;
636
+ }
538
637
 
539
638
  var strWindow = "window";
540
639
  var strDocument = "document";
640
+ var strNavigator = "navigator";
541
641
  var strLocation = "location";
542
642
  var strConsole = "console";
543
643
  var strPerformance = "performance";
544
644
  var strJSON = "JSON";
645
+ var strCrypto = "crypto";
646
+ var strMsCrypto = "msCrypto";
647
+ var strMsie = "msie";
648
+ var strTrident = "trident/";
649
+ var _isTrident = null;
650
+ var _navUserAgentCheck = null;
545
651
  var _enableMocks = false;
546
652
  function getGlobalInst(name) {
547
653
  var gbl = getGlobal();
@@ -571,6 +677,15 @@ this.Microsoft = this.Microsoft || {};
571
677
  }
572
678
  return getGlobalInst(strDocument);
573
679
  }
680
+ function hasNavigator() {
681
+ return Boolean(typeof navigator === strShimObject && navigator);
682
+ }
683
+ function getNavigator() {
684
+ if (hasNavigator()) {
685
+ return navigator;
686
+ }
687
+ return getGlobalInst(strNavigator);
688
+ }
574
689
  function getLocation(checkForMock) {
575
690
  if (checkForMock && _enableMocks) {
576
691
  var mockLocation = getGlobalInst("__mockLocation");
@@ -601,9 +716,24 @@ this.Microsoft = this.Microsoft || {};
601
716
  }
602
717
  return null;
603
718
  }
719
+ function getCrypto() {
720
+ return getGlobalInst(strCrypto);
721
+ }
722
+ function getMsCrypto() {
723
+ return getGlobalInst(strMsCrypto);
724
+ }
725
+ function isIE() {
726
+ var nav = getNavigator();
727
+ if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
728
+ _navUserAgentCheck = nav.userAgent;
729
+ var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
730
+ _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
731
+ }
732
+ return _isTrident;
733
+ }
604
734
  function dumpObj(object) {
605
735
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
606
- var propertyValueDump = "";
736
+ var propertyValueDump = strEmpty;
607
737
  if (objectTypeDump === "[object Error]") {
608
738
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
609
739
  }
@@ -636,9 +766,9 @@ this.Microsoft = this.Microsoft || {};
636
766
  var strWarnToConsole = "warnToConsole";
637
767
  function _sanitizeDiagnosticText(text) {
638
768
  if (text) {
639
- return "\"" + text.replace(/\"/g, "") + "\"";
769
+ return "\"" + text.replace(/\"/g, strEmpty) + "\"";
640
770
  }
641
- return "";
771
+ return strEmpty;
642
772
  }
643
773
  function _logToConsole(func, message) {
644
774
  var theConsole = getConsole();
@@ -660,12 +790,12 @@ this.Microsoft = this.Microsoft || {};
660
790
  _self.message =
661
791
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
662
792
  msgId;
663
- var strProps = "";
793
+ var strProps = strEmpty;
664
794
  if (hasJSON()) {
665
795
  strProps = getJSON().stringify(properties);
666
796
  }
667
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
668
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
797
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
798
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
669
799
  _self.message += diagnosticText;
670
800
  }
671
801
  _InternalLogMessage.dataType = "MessageData";
@@ -695,7 +825,7 @@ this.Microsoft = this.Microsoft || {};
695
825
  throw message;
696
826
  }
697
827
  else {
698
- var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
828
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
699
829
  if (!isUndefined(message.message)) {
700
830
  var logLevel = _self.consoleLoggingLevel();
701
831
  if (isUserAct) {
@@ -713,7 +843,7 @@ this.Microsoft = this.Microsoft || {};
713
843
  _self.logInternalMessage(severity, message);
714
844
  }
715
845
  else {
716
- _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
846
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
717
847
  }
718
848
  }
719
849
  };
@@ -745,13 +875,13 @@ this.Microsoft = this.Microsoft || {};
745
875
  if (severity <= _self.telemetryLoggingLevel()) {
746
876
  _self.queue.push(message);
747
877
  _messageCount++;
748
- _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
878
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
749
879
  }
750
880
  if (_messageCount === _self.maxInternalMessageLimit()) {
751
881
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
752
- var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
882
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
753
883
  _self.queue.push(throttleMessage);
754
- if (severity === LoggingSeverity.CRITICAL) {
884
+ if (severity === 1 ) {
755
885
  _self.errorToConsole(throttleLimitMessage);
756
886
  }
757
887
  else {
@@ -780,6 +910,10 @@ this.Microsoft = this.Microsoft || {};
780
910
  }
781
911
  return DiagnosticLogger;
782
912
  }());
913
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
914
+ if (isUserAct === void 0) { isUserAct = false; }
915
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
916
+ }
783
917
 
784
918
  var strExecutionContextKey = "ctx";
785
919
  var PerfEvent = /** @class */ (function () {
@@ -893,207 +1027,634 @@ this.Microsoft = this.Microsoft || {};
893
1027
  return func();
894
1028
  }
895
1029
 
896
- var TelemetryPluginChain = /** @class */ (function () {
897
- function TelemetryPluginChain(plugin, defItemCtx) {
898
- var _self = this;
899
- var _nextProxy = null;
900
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
901
- var _hasSetNext = isFunction(plugin.setNextPlugin);
902
- _self._hasRun = false;
903
- _self.getPlugin = function () {
904
- return plugin;
905
- };
906
- _self.getNext = function () {
907
- return _nextProxy;
908
- };
909
- _self.setNext = function (nextPlugin) {
910
- _nextProxy = nextPlugin;
911
- };
912
- _self.processTelemetry = function (env, itemCtx) {
913
- if (!itemCtx) {
914
- itemCtx = defItemCtx;
1030
+ var UInt32Mask = 0x100000000;
1031
+ var MaxUInt32 = 0xffffffff;
1032
+ var _mwcSeeded = false;
1033
+ var _mwcW = 123456789;
1034
+ var _mwcZ = 987654321;
1035
+ function _mwcSeed(seedValue) {
1036
+ if (seedValue < 0) {
1037
+ seedValue >>>= 0;
1038
+ }
1039
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1040
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1041
+ _mwcSeeded = true;
1042
+ }
1043
+ function _autoSeedMwc() {
1044
+ try {
1045
+ var now = dateNow() & 0x7fffffff;
1046
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1047
+ }
1048
+ catch (e) {
1049
+ }
1050
+ }
1051
+ function random32(signed) {
1052
+ var value = 0;
1053
+ var c = getCrypto() || getMsCrypto();
1054
+ if (c && c.getRandomValues) {
1055
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1056
+ }
1057
+ if (value === 0 && isIE()) {
1058
+ if (!_mwcSeeded) {
1059
+ _autoSeedMwc();
1060
+ }
1061
+ value = mwcRandom32() & MaxUInt32;
1062
+ }
1063
+ if (value === 0) {
1064
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1065
+ }
1066
+ if (!signed) {
1067
+ value >>>= 0;
1068
+ }
1069
+ return value;
1070
+ }
1071
+ function mwcRandom32(signed) {
1072
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1073
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1074
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1075
+ if (!signed) {
1076
+ value >>>= 0;
1077
+ }
1078
+ return value;
1079
+ }
1080
+ function newId(maxLength) {
1081
+ if (maxLength === void 0) { maxLength = 22; }
1082
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1083
+ var number = random32() >>> 0;
1084
+ var chars = 0;
1085
+ var result = strEmpty;
1086
+ while (result.length < maxLength) {
1087
+ chars++;
1088
+ result += base64chars.charAt(number & 0x3F);
1089
+ number >>>= 6;
1090
+ if (chars === 5) {
1091
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1092
+ chars = 0;
1093
+ }
1094
+ }
1095
+ return result;
1096
+ }
1097
+
1098
+ var _objDefineProperty = ObjDefineProperty;
1099
+ var version = "2.8.0-nightly.2204-04";
1100
+ var instanceName = "." + newId(6);
1101
+ var _dataUid = 0;
1102
+ function _createAccessor(target, prop, value) {
1103
+ if (_objDefineProperty) {
1104
+ try {
1105
+ _objDefineProperty(target, prop, {
1106
+ value: value,
1107
+ enumerable: false,
1108
+ configurable: true
1109
+ });
1110
+ return true;
1111
+ }
1112
+ catch (e) {
1113
+ }
1114
+ }
1115
+ return false;
1116
+ }
1117
+ function _canAcceptData(target) {
1118
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1119
+ }
1120
+ function _getCache(data, target) {
1121
+ var theCache = target[data.id];
1122
+ if (!theCache) {
1123
+ theCache = {};
1124
+ try {
1125
+ if (_canAcceptData(target)) {
1126
+ if (!_createAccessor(target, data.id, theCache)) {
1127
+ target[data.id] = theCache;
1128
+ }
915
1129
  }
916
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
917
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
918
- if (plugin && _hasProcessTelemetry) {
919
- _self._hasRun = true;
920
- try {
921
- itemCtx.setNext(_nextProxy);
922
- if (_hasSetNext) {
923
- plugin.setNextPlugin(_nextProxy);
924
- }
925
- _nextProxy && (_nextProxy._hasRun = false);
926
- plugin.processTelemetry(env, itemCtx);
927
- }
928
- catch (error) {
929
- var hasRun = _nextProxy && _nextProxy._hasRun;
930
- if (!_nextProxy || !hasRun) {
931
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
932
- }
933
- if (_nextProxy && !hasRun) {
934
- _nextProxy.processTelemetry(env, itemCtx);
935
- }
936
- }
1130
+ }
1131
+ catch (e) {
1132
+ }
1133
+ }
1134
+ return theCache;
1135
+ }
1136
+ function createUniqueNamespace(name, includeVersion) {
1137
+ if (includeVersion === void 0) { includeVersion = false; }
1138
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1139
+ }
1140
+ function createElmNodeData(name) {
1141
+ var data = {
1142
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1143
+ accept: function (target) {
1144
+ return _canAcceptData(target);
1145
+ },
1146
+ get: function (target, name, defValue, addDefault) {
1147
+ var theCache = target[data.id];
1148
+ if (!theCache) {
1149
+ if (addDefault) {
1150
+ theCache = _getCache(data, target);
1151
+ theCache[normalizeJsName(name)] = defValue;
1152
+ }
1153
+ return defValue;
1154
+ }
1155
+ return theCache[normalizeJsName(name)];
1156
+ },
1157
+ kill: function (target, name) {
1158
+ if (target && target[name]) {
1159
+ try {
1160
+ delete target[name];
937
1161
  }
938
- else if (_nextProxy) {
939
- _self._hasRun = true;
940
- _nextProxy.processTelemetry(env, itemCtx);
1162
+ catch (e) {
941
1163
  }
942
- }, function () { return ({ item: env }); }, !(env.sync));
943
- };
944
- }
945
- return TelemetryPluginChain;
946
- }());
1164
+ }
1165
+ }
1166
+ };
1167
+ return data;
1168
+ }
947
1169
 
948
- function _createProxyChain(plugins, itemCtx) {
949
- var proxies = [];
950
- if (plugins && plugins.length > 0) {
951
- var lastProxy = null;
952
- for (var idx = 0; idx < plugins.length; idx++) {
953
- var thePlugin = plugins[idx];
954
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
955
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
956
- proxies.push(newProxy);
957
- if (lastProxy) {
958
- lastProxy.setNext(newProxy);
1170
+ var strDoUnload = "_doUnload";
1171
+ var pluginStateData = createElmNodeData("plugin");
1172
+ function _getPluginState(plugin) {
1173
+ return pluginStateData.get(plugin, "state", {}, true);
1174
+ }
1175
+ function unloadComponents(components, unloadCtx, unloadState, asyncCallback) {
1176
+ var idx = 0;
1177
+ function _doUnload() {
1178
+ while (idx < components.length) {
1179
+ var component = components[idx++];
1180
+ if (component) {
1181
+ var func = component[strDoUnload] || component[strDoTeardown];
1182
+ if (isFunction(func)) {
1183
+ if (func.call(component, unloadCtx, unloadState, _doUnload) === true) {
1184
+ return true;
1185
+ }
959
1186
  }
960
- lastProxy = newProxy;
961
1187
  }
962
1188
  }
963
1189
  }
964
- return proxies.length > 0 ? proxies[0] : null;
1190
+ return _doUnload();
965
1191
  }
966
- function _copyProxyChain(proxy, itemCtx, startAt) {
967
- var plugins = [];
968
- var add = startAt ? false : true;
969
- if (proxy) {
970
- while (proxy) {
971
- var thePlugin = proxy.getPlugin();
972
- if (add || thePlugin === startAt) {
973
- add = true;
974
- plugins.push(thePlugin);
1192
+
1193
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1194
+ var strHasRunFlags = "_hasRun";
1195
+ var strGetTelCtx = "_getTelCtx";
1196
+ var _chainId = 0;
1197
+ function _getNextProxyStart(proxy, config, core, startAt) {
1198
+ while (proxy) {
1199
+ if (proxy.getPlugin() === startAt) {
1200
+ return proxy;
1201
+ }
1202
+ proxy = proxy.getNext();
1203
+ }
1204
+ return createTelemetryProxyChain([startAt], config, core);
1205
+ }
1206
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1207
+ var _nextProxy = null;
1208
+ var _onComplete = [];
1209
+ if (startAt !== null) {
1210
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1211
+ }
1212
+ var context = {
1213
+ _next: _moveNext,
1214
+ ctx: {
1215
+ core: function () {
1216
+ return core;
1217
+ },
1218
+ diagLog: function () {
1219
+ return safeGetLogger(core, config);
1220
+ },
1221
+ getCfg: function () {
1222
+ return config;
1223
+ },
1224
+ getExtCfg: _getExtCfg,
1225
+ getConfig: _getConfig,
1226
+ hasNext: function () {
1227
+ return !!_nextProxy;
1228
+ },
1229
+ getNext: function () {
1230
+ return _nextProxy;
1231
+ },
1232
+ setNext: function (nextPlugin) {
1233
+ _nextProxy = nextPlugin;
1234
+ },
1235
+ iterate: _iterateChain,
1236
+ onComplete: _addOnComplete
1237
+ }
1238
+ };
1239
+ function _addOnComplete(onComplete, that) {
1240
+ var args = [];
1241
+ for (var _i = 2; _i < arguments.length; _i++) {
1242
+ args[_i - 2] = arguments[_i];
1243
+ }
1244
+ if (onComplete) {
1245
+ _onComplete.push({
1246
+ func: onComplete,
1247
+ self: !isUndefined(that) ? that : context.ctx,
1248
+ args: args
1249
+ });
1250
+ }
1251
+ }
1252
+ function _moveNext() {
1253
+ var nextProxy = _nextProxy;
1254
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1255
+ if (!nextProxy) {
1256
+ var onComplete = _onComplete;
1257
+ if (onComplete && onComplete.length > 0) {
1258
+ arrForEach(onComplete, function (completeDetails) {
1259
+ try {
1260
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1261
+ }
1262
+ catch (e) {
1263
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1264
+ }
1265
+ });
1266
+ _onComplete = [];
1267
+ }
1268
+ }
1269
+ return nextProxy;
1270
+ }
1271
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1272
+ if (defaultValue === void 0) { defaultValue = {}; }
1273
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1274
+ var theConfig;
1275
+ if (config) {
1276
+ var extConfig = config.extensionConfig;
1277
+ if (extConfig && identifier) {
1278
+ theConfig = extConfig[identifier];
1279
+ }
1280
+ }
1281
+ if (!theConfig) {
1282
+ theConfig = defaultValue;
1283
+ }
1284
+ else if (isObject(defaultValue)) {
1285
+ if (mergeDefault !== 0 ) {
1286
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1287
+ if (config && mergeDefault === 2 ) {
1288
+ objForEachKey(defaultValue, function (field) {
1289
+ if (isNullOrUndefined(newConfig_1[field])) {
1290
+ var cfgValue = config[field];
1291
+ if (!isNullOrUndefined(cfgValue)) {
1292
+ newConfig_1[field] = cfgValue;
1293
+ }
1294
+ }
1295
+ });
1296
+ }
975
1297
  }
976
- proxy = proxy.getNext();
977
1298
  }
1299
+ return theConfig;
978
1300
  }
979
- if (!add) {
980
- plugins.push(startAt);
1301
+ function _getConfig(identifier, field, defaultValue) {
1302
+ if (defaultValue === void 0) { defaultValue = false; }
1303
+ var theValue;
1304
+ var extConfig = _getExtCfg(identifier, null);
1305
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1306
+ theValue = extConfig[field];
1307
+ }
1308
+ else if (config && !isNullOrUndefined(config[field])) {
1309
+ theValue = config[field];
1310
+ }
1311
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1312
+ }
1313
+ function _iterateChain(cb) {
1314
+ var nextPlugin;
1315
+ while (!!(nextPlugin = context._next())) {
1316
+ var plugin = nextPlugin.getPlugin();
1317
+ if (plugin) {
1318
+ cb(plugin);
1319
+ }
1320
+ }
981
1321
  }
982
- return _createProxyChain(plugins, itemCtx);
1322
+ return context;
983
1323
  }
984
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
985
- var plugins = srcPlugins;
986
- var add = false;
987
- if (startAt && srcPlugins) {
988
- plugins = [];
989
- arrForEach(srcPlugins, function (thePlugin) {
990
- if (add || thePlugin === startAt) {
991
- add = true;
992
- plugins.push(thePlugin);
1324
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1325
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1326
+ var context = internalContext.ctx;
1327
+ function _processNext(env) {
1328
+ var nextPlugin = internalContext._next();
1329
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1330
+ return !nextPlugin;
1331
+ }
1332
+ function _createNew(plugins, startAt) {
1333
+ if (plugins === void 0) { plugins = null; }
1334
+ if (isArray(plugins)) {
1335
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1336
+ }
1337
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1338
+ }
1339
+ context.processNext = _processNext;
1340
+ context.createNew = _createNew;
1341
+ return context;
1342
+ }
1343
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1344
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1345
+ var context = internalContext.ctx;
1346
+ function _processNext(unloadState) {
1347
+ var nextPlugin = internalContext._next();
1348
+ nextPlugin && nextPlugin.unload(context, unloadState);
1349
+ return !nextPlugin;
1350
+ }
1351
+ function _createNew(plugins, startAt) {
1352
+ if (plugins === void 0) { plugins = null; }
1353
+ if (isArray(plugins)) {
1354
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1355
+ }
1356
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1357
+ }
1358
+ context.processNext = _processNext;
1359
+ context.createNew = _createNew;
1360
+ return context;
1361
+ }
1362
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1363
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1364
+ var context = internalContext.ctx;
1365
+ function _processNext(updateState) {
1366
+ return context.iterate(function (plugin) {
1367
+ if (isFunction(plugin[strUpdate])) {
1368
+ plugin[strUpdate](context, updateState);
993
1369
  }
994
1370
  });
995
1371
  }
996
- if (startAt && !add) {
997
- if (!plugins) {
998
- plugins = [];
1372
+ function _createNew(plugins, startAt) {
1373
+ if (plugins === void 0) { plugins = null; }
1374
+ if (isArray(plugins)) {
1375
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
999
1376
  }
1000
- plugins.push(startAt);
1377
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1001
1378
  }
1002
- return _createProxyChain(plugins, itemCtx);
1379
+ context.processNext = _processNext;
1380
+ context.createNew = _createNew;
1381
+ return context;
1003
1382
  }
1004
- var ProcessTelemetryContext = /** @class */ (function () {
1005
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1006
- var _self = this;
1007
- var _nextProxy = null;
1008
- if (startAt !== null) {
1009
- if (plugins && isFunction(plugins.getPlugin)) {
1010
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1383
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1384
+ var firstProxy = null;
1385
+ var add = startAt ? false : true;
1386
+ if (isArray(plugins) && plugins.length > 0) {
1387
+ var lastProxy_1 = null;
1388
+ arrForEach(plugins, function (thePlugin) {
1389
+ if (!add && startAt === thePlugin) {
1390
+ add = true;
1011
1391
  }
1012
- else {
1013
- if (startAt) {
1014
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1392
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1393
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1394
+ if (!firstProxy) {
1395
+ firstProxy = newProxy;
1015
1396
  }
1016
- else if (isUndefined(startAt)) {
1017
- _nextProxy = _createProxyChain(plugins, _self);
1397
+ if (lastProxy_1) {
1398
+ lastProxy_1._setNext(newProxy);
1018
1399
  }
1400
+ lastProxy_1 = newProxy;
1019
1401
  }
1402
+ });
1403
+ }
1404
+ if (startAt && !firstProxy) {
1405
+ return createTelemetryProxyChain([startAt], config, core);
1406
+ }
1407
+ return firstProxy;
1408
+ }
1409
+ function createTelemetryPluginProxy(plugin, config, core) {
1410
+ var nextProxy = null;
1411
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1412
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1413
+ var chainId;
1414
+ if (plugin) {
1415
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1416
+ }
1417
+ else {
1418
+ chainId = "Unknown-0-" + _chainId++;
1419
+ }
1420
+ var proxyChain = {
1421
+ getPlugin: function () {
1422
+ return plugin;
1423
+ },
1424
+ getNext: function () {
1425
+ return nextProxy;
1426
+ },
1427
+ processTelemetry: _processTelemetry,
1428
+ unload: _unloadPlugin,
1429
+ update: _updatePlugin,
1430
+ _id: chainId,
1431
+ _setNext: function (nextPlugin) {
1432
+ nextProxy = nextPlugin;
1020
1433
  }
1021
- _self.core = function () {
1022
- return core;
1023
- };
1024
- _self.diagLog = function () {
1025
- return safeGetLogger(core, config);
1026
- };
1027
- _self.getCfg = function () {
1028
- return config;
1029
- };
1030
- _self.getExtCfg = function (identifier, defaultValue) {
1031
- if (defaultValue === void 0) { defaultValue = {}; }
1032
- var theConfig;
1033
- if (config) {
1034
- var extConfig = config.extensionConfig;
1035
- if (extConfig && identifier) {
1036
- theConfig = extConfig[identifier];
1434
+ };
1435
+ function _getTelCtx() {
1436
+ var itemCtx;
1437
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1438
+ itemCtx = plugin[strGetTelCtx]();
1439
+ }
1440
+ if (!itemCtx) {
1441
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1442
+ }
1443
+ return itemCtx;
1444
+ }
1445
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1446
+ var hasRun = false;
1447
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1448
+ var hasRunContext = itemCtx[strHasRunFlags];
1449
+ if (!hasRunContext) {
1450
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1451
+ }
1452
+ itemCtx.setNext(nextProxy);
1453
+ if (plugin) {
1454
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1455
+ hasRunContext[chainId] = true;
1456
+ try {
1457
+ var nextId = nextProxy ? nextProxy._id : strEmpty;
1458
+ if (nextId) {
1459
+ hasRunContext[nextId] = false;
1460
+ }
1461
+ hasRun = processPluginFn(itemCtx);
1462
+ }
1463
+ catch (error) {
1464
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1465
+ if (hasNextRun) {
1466
+ hasRun = true;
1467
+ }
1468
+ if (!nextProxy || !hasNextRun) {
1469
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1470
+ }
1037
1471
  }
1472
+ }, details, isAsync);
1473
+ }
1474
+ return hasRun;
1475
+ }
1476
+ function _processTelemetry(env, itemCtx) {
1477
+ itemCtx = itemCtx || _getTelCtx();
1478
+ function _callProcessTelemetry(itemCtx) {
1479
+ if (!plugin || !hasProcessTelemetry) {
1480
+ return false;
1038
1481
  }
1039
- return (theConfig ? theConfig : defaultValue);
1040
- };
1041
- _self.getConfig = function (identifier, field, defaultValue) {
1042
- if (defaultValue === void 0) { defaultValue = false; }
1043
- var theValue;
1044
- var extConfig = _self.getExtCfg(identifier, null);
1045
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1046
- theValue = extConfig[field];
1482
+ var pluginState = _getPluginState(plugin);
1483
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1484
+ return false;
1047
1485
  }
1048
- else if (config && !isNullOrUndefined(config[field])) {
1049
- theValue = config[field];
1486
+ if (hasSetNext) {
1487
+ plugin.setNextPlugin(nextProxy);
1050
1488
  }
1051
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1052
- };
1053
- _self.hasNext = function () {
1054
- return _nextProxy != null;
1055
- };
1056
- _self.getNext = function () {
1057
- return _nextProxy;
1058
- };
1059
- _self.setNext = function (nextPlugin) {
1060
- _nextProxy = nextPlugin;
1061
- };
1062
- _self.processNext = function (env) {
1063
- var nextPlugin = _nextProxy;
1064
- if (nextPlugin) {
1065
- _nextProxy = nextPlugin.getNext();
1066
- nextPlugin.processTelemetry(env, _self);
1489
+ plugin.processTelemetry(env, itemCtx);
1490
+ return true;
1491
+ }
1492
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1493
+ itemCtx.processNext(env);
1494
+ }
1495
+ }
1496
+ function _unloadPlugin(unloadCtx, unloadState) {
1497
+ function _callTeardown() {
1498
+ var hasRun = false;
1499
+ if (plugin) {
1500
+ var pluginState = _getPluginState(plugin);
1501
+ var pluginCore = plugin[strCore] || pluginState.core;
1502
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1503
+ pluginState[strCore] = null;
1504
+ pluginState[strTeardown] = true;
1505
+ pluginState[strIsInitialized] = false;
1506
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1507
+ hasRun = true;
1508
+ }
1509
+ }
1067
1510
  }
1068
- };
1069
- _self.createNew = function (plugins, startAt) {
1070
- if (plugins === void 0) { plugins = null; }
1071
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1072
- };
1511
+ return hasRun;
1512
+ }
1513
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1514
+ unloadCtx.processNext(unloadState);
1515
+ }
1073
1516
  }
1074
- return ProcessTelemetryContext;
1075
- }());
1517
+ function _updatePlugin(updateCtx, updateState) {
1518
+ function _callUpdate() {
1519
+ var hasRun = false;
1520
+ if (plugin) {
1521
+ var pluginState = _getPluginState(plugin);
1522
+ var pluginCore = plugin[strCore] || pluginState.core;
1523
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1524
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1525
+ hasRun = true;
1526
+ }
1527
+ }
1528
+ }
1529
+ return hasRun;
1530
+ }
1531
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1532
+ updateCtx.processNext(updateState);
1533
+ }
1534
+ }
1535
+ return objFreeze(proxyChain);
1536
+ }
1076
1537
 
1077
1538
  var strExtensionConfig = "extensionConfig";
1078
1539
 
1540
+ function createUnloadHandlerContainer() {
1541
+ var handlers = [];
1542
+ function _addHandler(handler) {
1543
+ if (handler) {
1544
+ handlers.push(handler);
1545
+ }
1546
+ }
1547
+ function _runHandlers(unloadCtx, unloadState) {
1548
+ arrForEach(handlers, function (handler) {
1549
+ try {
1550
+ handler(unloadCtx, unloadState);
1551
+ }
1552
+ catch (e) {
1553
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1554
+ }
1555
+ });
1556
+ handlers = [];
1557
+ }
1558
+ return {
1559
+ add: _addHandler,
1560
+ run: _runHandlers
1561
+ };
1562
+ }
1563
+
1079
1564
  var strGetPlugin = "getPlugin";
1080
1565
  var BaseTelemetryPlugin = /** @class */ (function () {
1081
1566
  function BaseTelemetryPlugin() {
1082
1567
  var _self = this;
1083
- var _isinitialized = false;
1084
- var _rootCtx = null;
1085
- var _nextPlugin = null;
1086
- _self.core = null;
1087
- _self.diagLog = function (itemCtx) {
1088
- return _self._getTelCtx(itemCtx).diagLog();
1089
- };
1090
- _self.isInitialized = function () {
1091
- return _isinitialized;
1092
- };
1093
- _self.setInitialized = function (isInitialized) {
1094
- _isinitialized = isInitialized;
1568
+ var _isinitialized;
1569
+ var _rootCtx;
1570
+ var _nextPlugin;
1571
+ var _unloadHandlerContainer;
1572
+ var _hooks;
1573
+ _initDefaults();
1574
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1575
+ _self.initialize = function (config, core, extensions, pluginChain) {
1576
+ _setDefaults(config, core, pluginChain);
1577
+ _isinitialized = true;
1578
+ };
1579
+ _self.teardown = function (unloadCtx, unloadState) {
1580
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1581
+ return;
1582
+ }
1583
+ var result;
1584
+ var unloadDone = false;
1585
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1586
+ var theUnloadState = unloadState || {
1587
+ reason: 0 ,
1588
+ isAsync: false
1589
+ };
1590
+ function _unloadCallback() {
1591
+ if (!unloadDone) {
1592
+ unloadDone = true;
1593
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1594
+ arrForEach(_hooks, function (fn) {
1595
+ fn.rm();
1596
+ });
1597
+ _hooks = [];
1598
+ if (result === true) {
1599
+ theUnloadCtx.processNext(theUnloadState);
1600
+ }
1601
+ _initDefaults();
1602
+ }
1603
+ }
1604
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1605
+ _unloadCallback();
1606
+ }
1607
+ else {
1608
+ result = true;
1609
+ }
1610
+ return result;
1611
+ };
1612
+ _self.update = function (updateCtx, updateState) {
1613
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1614
+ return;
1615
+ }
1616
+ var result;
1617
+ var updateDone = false;
1618
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1619
+ var theUpdateState = updateState || {
1620
+ reason: 0
1621
+ };
1622
+ function _updateCallback() {
1623
+ if (!updateDone) {
1624
+ updateDone = true;
1625
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1626
+ }
1627
+ }
1628
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1629
+ _updateCallback();
1630
+ }
1631
+ else {
1632
+ result = true;
1633
+ }
1634
+ return result;
1635
+ };
1636
+ _self._addHook = function (hooks) {
1637
+ if (hooks) {
1638
+ if (isArray(hooks)) {
1639
+ _hooks = _hooks.concat(hooks);
1640
+ }
1641
+ else {
1642
+ _hooks.push(hooks);
1643
+ }
1644
+ }
1645
+ };
1646
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1647
+ });
1648
+ _self.diagLog = function (itemCtx) {
1649
+ return _getTelCtx(itemCtx).diagLog();
1095
1650
  };
1096
- _self.setNextPlugin = function (next) {
1651
+ _self[strIsInitialized] = function () {
1652
+ return _isinitialized;
1653
+ };
1654
+ _self.setInitialized = function (isInitialized) {
1655
+ _isinitialized = isInitialized;
1656
+ };
1657
+ _self[strSetNextPlugin] = function (next) {
1097
1658
  _nextPlugin = next;
1098
1659
  };
1099
1660
  _self.processNext = function (env, itemCtx) {
@@ -1104,11 +1665,12 @@ this.Microsoft = this.Microsoft || {};
1104
1665
  _nextPlugin.processTelemetry(env, null);
1105
1666
  }
1106
1667
  };
1107
- _self._getTelCtx = function (currentCtx) {
1668
+ _self._getTelCtx = _getTelCtx;
1669
+ function _getTelCtx(currentCtx) {
1108
1670
  if (currentCtx === void 0) { currentCtx = null; }
1109
1671
  var itemCtx = currentCtx;
1110
1672
  if (!itemCtx) {
1111
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1673
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1112
1674
  if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1113
1675
  itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1114
1676
  }
@@ -1117,8 +1679,8 @@ this.Microsoft = this.Microsoft || {};
1117
1679
  }
1118
1680
  }
1119
1681
  return itemCtx;
1120
- };
1121
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1682
+ }
1683
+ function _setDefaults(config, core, pluginChain) {
1122
1684
  if (config) {
1123
1685
  setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1124
1686
  }
@@ -1130,16 +1692,280 @@ this.Microsoft = this.Microsoft || {};
1130
1692
  nextPlugin = _nextPlugin[strGetPlugin]();
1131
1693
  }
1132
1694
  _self.core = core;
1133
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1134
- _isinitialized = true;
1135
- };
1695
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1696
+ }
1697
+ function _initDefaults() {
1698
+ _isinitialized = false;
1699
+ _self.core = null;
1700
+ _rootCtx = null;
1701
+ _nextPlugin = null;
1702
+ _hooks = [];
1703
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1704
+ }
1136
1705
  }
1137
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1138
- this._baseTelInit(config, core, extensions, pluginChain);
1139
- };
1140
1706
  return BaseTelemetryPlugin;
1141
1707
  }());
1142
1708
 
1709
+ var strOnPrefix = "on";
1710
+ var strAttachEvent = "attachEvent";
1711
+ var strAddEventHelper = "addEventListener";
1712
+ var strDetachEvent = "detachEvent";
1713
+ var strRemoveEventListener = "removeEventListener";
1714
+ var strEvents = "events";
1715
+ createUniqueNamespace("aiEvtPageHide");
1716
+ createUniqueNamespace("aiEvtPageShow");
1717
+ var rRemoveEmptyNs = /\.[\.]+/g;
1718
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
1719
+ var _guid = 1;
1720
+ var elmNodeData = createElmNodeData("events");
1721
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
1722
+ function _normalizeNamespace(name) {
1723
+ if (name && name.replace) {
1724
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
1725
+ }
1726
+ return name;
1727
+ }
1728
+ function _getEvtNamespace(eventName, evtNamespace) {
1729
+ if (evtNamespace) {
1730
+ var theNamespace_1 = "";
1731
+ if (isArray(evtNamespace)) {
1732
+ theNamespace_1 = "";
1733
+ arrForEach(evtNamespace, function (name) {
1734
+ name = _normalizeNamespace(name);
1735
+ if (name) {
1736
+ if (name[0] !== ".") {
1737
+ name = "." + name;
1738
+ }
1739
+ theNamespace_1 += name;
1740
+ }
1741
+ });
1742
+ }
1743
+ else {
1744
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
1745
+ }
1746
+ if (theNamespace_1) {
1747
+ if (theNamespace_1[0] !== ".") {
1748
+ theNamespace_1 = "." + theNamespace_1;
1749
+ }
1750
+ eventName = (eventName || "") + theNamespace_1;
1751
+ }
1752
+ }
1753
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
1754
+ return {
1755
+ type: parsedEvent[1],
1756
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
1757
+ };
1758
+ }
1759
+ function _getRegisteredEvents(target, evtName, addDefault) {
1760
+ if (addDefault === void 0) { addDefault = true; }
1761
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
1762
+ var registeredEvents = aiEvts[evtName];
1763
+ if (!registeredEvents) {
1764
+ registeredEvents = aiEvts[evtName] = [];
1765
+ }
1766
+ return registeredEvents;
1767
+ }
1768
+ function _doDetach(obj, evtName, handlerRef, useCapture) {
1769
+ if (obj && evtName && evtName.type) {
1770
+ if (obj[strRemoveEventListener]) {
1771
+ obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
1772
+ }
1773
+ else if (obj[strDetachEvent]) {
1774
+ obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
1775
+ }
1776
+ }
1777
+ }
1778
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
1779
+ var result = false;
1780
+ if (obj && evtName && evtName.type && handlerRef) {
1781
+ if (obj[strAddEventHelper]) {
1782
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
1783
+ result = true;
1784
+ }
1785
+ else if (obj[strAttachEvent]) {
1786
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
1787
+ result = true;
1788
+ }
1789
+ }
1790
+ return result;
1791
+ }
1792
+ function _doUnregister(target, events, evtName, unRegFn) {
1793
+ var idx = events.length;
1794
+ while (idx--) {
1795
+ var theEvent = events[idx];
1796
+ if (theEvent) {
1797
+ if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
1798
+ if (!unRegFn || unRegFn(theEvent)) {
1799
+ _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
1800
+ events.splice(idx, 1);
1801
+ }
1802
+ }
1803
+ }
1804
+ }
1805
+ }
1806
+ function _unregisterEvents(target, evtName, unRegFn) {
1807
+ if (evtName.type) {
1808
+ _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1809
+ }
1810
+ else {
1811
+ var eventCache = elmNodeData.get(target, strEvents, {});
1812
+ objForEachKey(eventCache, function (evtType, events) {
1813
+ _doUnregister(target, events, evtName, unRegFn);
1814
+ });
1815
+ if (objKeys(eventCache).length === 0) {
1816
+ elmNodeData.kill(target, strEvents);
1817
+ }
1818
+ }
1819
+ }
1820
+ function mergeEvtNamespace(theNamespace, namespaces) {
1821
+ var newNamespaces;
1822
+ if (namespaces) {
1823
+ if (isArray(namespaces)) {
1824
+ newNamespaces = [theNamespace].concat(namespaces);
1825
+ }
1826
+ else {
1827
+ newNamespaces = [theNamespace, namespaces];
1828
+ }
1829
+ newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1830
+ }
1831
+ else {
1832
+ newNamespaces = theNamespace;
1833
+ }
1834
+ return newNamespaces;
1835
+ }
1836
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
1837
+ if (useCapture === void 0) { useCapture = false; }
1838
+ var result = false;
1839
+ if (target) {
1840
+ try {
1841
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
1842
+ result = _doAttach(target, evtName, handlerRef, useCapture);
1843
+ if (result && elmNodeData.accept(target)) {
1844
+ var registeredEvent = {
1845
+ guid: _guid++,
1846
+ evtName: evtName,
1847
+ handler: handlerRef,
1848
+ capture: useCapture
1849
+ };
1850
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
1851
+ }
1852
+ }
1853
+ catch (e) {
1854
+ }
1855
+ }
1856
+ return result;
1857
+ }
1858
+ function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
1859
+ if (useCapture === void 0) { useCapture = false; }
1860
+ if (target) {
1861
+ try {
1862
+ var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
1863
+ var found_1 = false;
1864
+ _unregisterEvents(target, evtName_1, function (regEvent) {
1865
+ if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
1866
+ found_1 = true;
1867
+ return true;
1868
+ }
1869
+ return false;
1870
+ });
1871
+ if (!found_1) {
1872
+ _doDetach(target, evtName_1, handlerRef, useCapture);
1873
+ }
1874
+ }
1875
+ catch (e) {
1876
+ }
1877
+ }
1878
+ }
1879
+
1880
+ var LoggingSeverity = createEnumStyle({
1881
+ CRITICAL: 1 ,
1882
+ WARNING: 2
1883
+ });
1884
+ var _InternalMessageId = createEnumStyle({
1885
+ BrowserDoesNotSupportLocalStorage: 0 ,
1886
+ BrowserCannotReadLocalStorage: 1 ,
1887
+ BrowserCannotReadSessionStorage: 2 ,
1888
+ BrowserCannotWriteLocalStorage: 3 ,
1889
+ BrowserCannotWriteSessionStorage: 4 ,
1890
+ BrowserFailedRemovalFromLocalStorage: 5 ,
1891
+ BrowserFailedRemovalFromSessionStorage: 6 ,
1892
+ CannotSendEmptyTelemetry: 7 ,
1893
+ ClientPerformanceMathError: 8 ,
1894
+ ErrorParsingAISessionCookie: 9 ,
1895
+ ErrorPVCalc: 10 ,
1896
+ ExceptionWhileLoggingError: 11 ,
1897
+ FailedAddingTelemetryToBuffer: 12 ,
1898
+ FailedMonitorAjaxAbort: 13 ,
1899
+ FailedMonitorAjaxDur: 14 ,
1900
+ FailedMonitorAjaxOpen: 15 ,
1901
+ FailedMonitorAjaxRSC: 16 ,
1902
+ FailedMonitorAjaxSend: 17 ,
1903
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
1904
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
1905
+ FailedToSendQueuedTelemetry: 20 ,
1906
+ FailedToReportDataLoss: 21 ,
1907
+ FlushFailed: 22 ,
1908
+ MessageLimitPerPVExceeded: 23 ,
1909
+ MissingRequiredFieldSpecification: 24 ,
1910
+ NavigationTimingNotSupported: 25 ,
1911
+ OnError: 26 ,
1912
+ SessionRenewalDateIsZero: 27 ,
1913
+ SenderNotInitialized: 28 ,
1914
+ StartTrackEventFailed: 29 ,
1915
+ StopTrackEventFailed: 30 ,
1916
+ StartTrackFailed: 31 ,
1917
+ StopTrackFailed: 32 ,
1918
+ TelemetrySampledAndNotSent: 33 ,
1919
+ TrackEventFailed: 34 ,
1920
+ TrackExceptionFailed: 35 ,
1921
+ TrackMetricFailed: 36 ,
1922
+ TrackPVFailed: 37 ,
1923
+ TrackPVFailedCalc: 38 ,
1924
+ TrackTraceFailed: 39 ,
1925
+ TransmissionFailed: 40 ,
1926
+ FailedToSetStorageBuffer: 41 ,
1927
+ FailedToRestoreStorageBuffer: 42 ,
1928
+ InvalidBackendResponse: 43 ,
1929
+ FailedToFixDepricatedValues: 44 ,
1930
+ InvalidDurationValue: 45 ,
1931
+ TelemetryEnvelopeInvalid: 46 ,
1932
+ CreateEnvelopeError: 47 ,
1933
+ CannotSerializeObject: 48 ,
1934
+ CannotSerializeObjectNonSerializable: 49 ,
1935
+ CircularReferenceDetected: 50 ,
1936
+ ClearAuthContextFailed: 51 ,
1937
+ ExceptionTruncated: 52 ,
1938
+ IllegalCharsInName: 53 ,
1939
+ ItemNotInArray: 54 ,
1940
+ MaxAjaxPerPVExceeded: 55 ,
1941
+ MessageTruncated: 56 ,
1942
+ NameTooLong: 57 ,
1943
+ SampleRateOutOfRange: 58 ,
1944
+ SetAuthContextFailed: 59 ,
1945
+ SetAuthContextFailedAccountName: 60 ,
1946
+ StringValueTooLong: 61 ,
1947
+ StartCalledMoreThanOnce: 62 ,
1948
+ StopCalledWithoutStart: 63 ,
1949
+ TelemetryInitializerFailed: 64 ,
1950
+ TrackArgumentsNotSpecified: 65 ,
1951
+ UrlTooLong: 66 ,
1952
+ SessionStorageBufferFull: 67 ,
1953
+ CannotAccessCookie: 68 ,
1954
+ IdTooLong: 69 ,
1955
+ InvalidEvent: 70 ,
1956
+ FailedMonitorAjaxSetRequestHeader: 71 ,
1957
+ SendBrowserInfoOnUserInit: 72 ,
1958
+ PluginException: 73 ,
1959
+ NotificationException: 74 ,
1960
+ SnippetScriptLoadFailure: 99 ,
1961
+ InvalidInstrumentationKey: 100 ,
1962
+ CannotParseAiBlobValue: 101 ,
1963
+ InvalidContentBlob: 102 ,
1964
+ TrackPageActionEventFailed: 103 ,
1965
+ FailedAddingCustomDefinedRequestContext: 104 ,
1966
+ InMemoryStorageBufferFull: 105
1967
+ });
1968
+
1143
1969
  var strNotSpecified = "not_specified";
1144
1970
 
1145
1971
  var PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin";
@@ -1434,188 +2260,200 @@ this.Microsoft = this.Microsoft || {};
1434
2260
  }
1435
2261
 
1436
2262
  var WebEvent = /** @class */ (function () {
1437
- function WebEvent(_clickAnalyticsPlugin, _config, _contentHandler, _pageTagsCallback, _metaTags, _traceLogger) {
1438
- this._clickAnalyticsPlugin = _clickAnalyticsPlugin;
1439
- this._config = _config;
1440
- this._contentHandler = _contentHandler;
1441
- this._pageTagsCallback = _pageTagsCallback;
1442
- this._metaTags = _metaTags;
1443
- this._traceLogger = _traceLogger;
1444
- this._pageTags = {};
1445
- }
1446
- WebEvent.prototype.setBasicProperties = function (event, overrideValues) {
1447
- if (!isValueAssigned(event.name)) {
1448
- event.pageName = getPageName(this._config, overrideValues);
1449
- }
1450
- if (!isValueAssigned(event.uri) && hasWindow) {
1451
- event.uri = getUri(this._config, getLocation());
1452
- }
1453
- };
1454
- WebEvent.prototype.setCommonProperties = function (event, overrideValues) {
1455
- this.setBasicProperties(event, overrideValues);
1456
- this._setPageTags(event, overrideValues);
1457
- this._pageTypeMetaTag = this._getMetaData(this._metaTags, this._config.coreData, "pageType");
1458
- this._behaviorMetaTag = this._getMetaData(this._metaTags, this._config.coreData, "behavior");
1459
- if (isValueAssigned(overrideValues.pageType)) {
1460
- event.pageType = overrideValues.pageType;
1461
- }
1462
- if (isValueAssigned(this._pageTypeMetaTag) && !isValueAssigned(event.pageType)) {
1463
- event.pageType = this._pageTypeMetaTag;
1464
- }
1465
- };
1466
- WebEvent.prototype._setPageTags = function (event, overrideValues) {
1467
- if (this._pageTagsCallback) {
1468
- this._pageTags = extend(true, this._pageTags, this._pageTagsCallback());
1469
- }
1470
- if (isValueAssigned(overrideValues.pageTags)) {
1471
- this._pageTags = extend(true, this._pageTags, overrideValues.pageTags);
1472
- }
1473
- if (this._metaTags) {
1474
- this._pageTags.metaTags = {};
1475
- for (var metaTag in this._metaTags) {
1476
- if (metaTag != "behavior" && metaTag != "market" && metaTag != "pageType") {
1477
- this._pageTags.metaTags[metaTag] = this._metaTags[metaTag];
2263
+ function WebEvent(clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) {
2264
+ dynamicProto(WebEvent, this, function (_self) {
2265
+ _initDefaults();
2266
+ function _initDefaults() {
2267
+ _self._pageTags = {};
2268
+ _self._clickAnalyticsPlugin = clickAnalyticsPlugin;
2269
+ _self._config = config;
2270
+ _self._contentHandler = contentHandler;
2271
+ _self._pageTagsCallback = pageTagsCallback;
2272
+ _self._metaTags = metaTags;
2273
+ _self._traceLogger = traceLogger;
2274
+ }
2275
+ _self.setBasicProperties = function (event, overrideValues) {
2276
+ if (!isValueAssigned(event.name)) {
2277
+ event.pageName = getPageName(_self._config, overrideValues);
2278
+ }
2279
+ if (!isValueAssigned(event.uri) && hasWindow) {
2280
+ event.uri = getUri(_self._config, getLocation());
2281
+ }
2282
+ };
2283
+ _self.setCommonProperties = function (event, overrideValues) {
2284
+ _self.setBasicProperties(event, overrideValues);
2285
+ _self._setPageTags(event, overrideValues);
2286
+ _self._pageTypeMetaTag = _getMetaData(_self._metaTags, _self._config.coreData, "pageType");
2287
+ _self._behaviorMetaTag = _getMetaData(_self._metaTags, _self._config.coreData, "behavior");
2288
+ if (isValueAssigned(overrideValues.pageType)) {
2289
+ event.pageType = overrideValues.pageType;
1478
2290
  }
2291
+ if (isValueAssigned(_self._pageTypeMetaTag) && !isValueAssigned(event.pageType)) {
2292
+ event.pageType = _self._pageTypeMetaTag;
2293
+ }
2294
+ };
2295
+ _self._setPageTags = function (event, overrideValues) {
2296
+ if (_self._pageTagsCallback) {
2297
+ _self._pageTags = extend(true, _self._pageTags, _self._pageTagsCallback());
2298
+ }
2299
+ if (isValueAssigned(overrideValues.pageTags)) {
2300
+ _self._pageTags = extend(true, _self._pageTags, overrideValues.pageTags);
2301
+ }
2302
+ if (_self._metaTags) {
2303
+ _self._pageTags.metaTags = {};
2304
+ for (var metaTag in _self._metaTags) {
2305
+ if (metaTag != "behavior" && metaTag != "market" && metaTag != "pageType") {
2306
+ _self._pageTags.metaTags[metaTag] = _self._metaTags[metaTag];
2307
+ }
2308
+ }
2309
+ }
2310
+ event.properties = event.properties || {};
2311
+ event.properties["pageTags"] = _self._pageTags;
2312
+ };
2313
+ _self._getBehavior = function (overrideValues) {
2314
+ var behavior;
2315
+ if (overrideValues && isValueAssigned(overrideValues.behavior)) {
2316
+ behavior = overrideValues.behavior;
2317
+ }
2318
+ else if (isValueAssigned(_self._behaviorMetaTag)) {
2319
+ behavior = _self._behaviorMetaTag;
2320
+ }
2321
+ return _self._getValidBehavior(behavior);
2322
+ };
2323
+ _self._getValidBehavior = function (behavior) {
2324
+ return _self._config.behaviorValidator(behavior);
2325
+ };
2326
+ _self._doUnload = function (unloadCtx, unloadState, asyncCallback) {
2327
+ _initDefaults();
2328
+ };
2329
+ function _getMetaData(metaTags, coreData, metaTagName) {
2330
+ if (coreData && coreData[metaTagName]) {
2331
+ return coreData[metaTagName];
2332
+ }
2333
+ if (metaTags) {
2334
+ return metaTags[metaTagName];
2335
+ }
2336
+ return "";
1479
2337
  }
1480
- }
1481
- event.properties = event.properties || {};
1482
- event.properties["pageTags"] = this._pageTags;
1483
- };
1484
- WebEvent.prototype._getBehavior = function (overrideValues) {
1485
- var behavior;
1486
- if (overrideValues && isValueAssigned(overrideValues.behavior)) {
1487
- behavior = overrideValues.behavior;
1488
- }
1489
- else if (isValueAssigned(this._behaviorMetaTag)) {
1490
- behavior = this._behaviorMetaTag;
1491
- }
1492
- return this._getValidBehavior(behavior);
1493
- };
1494
- WebEvent.prototype._getValidBehavior = function (behavior) {
1495
- return this._config.behaviorValidator(behavior);
1496
- };
1497
- WebEvent.prototype._getMetaData = function (metaTags, coreData, metaTagName) {
1498
- if (coreData && coreData[metaTagName]) {
1499
- return coreData[metaTagName];
1500
- }
1501
- else if (metaTags) {
1502
- return metaTags[metaTagName];
1503
- }
1504
- return "";
1505
- };
2338
+ });
2339
+ }
1506
2340
  return WebEvent;
1507
2341
  }());
1508
2342
 
1509
2343
  var PageAction = /** @class */ (function (_super) {
1510
2344
  __extendsFn(PageAction, _super);
1511
- function PageAction() {
1512
- return _super !== null && _super.apply(this, arguments) || this;
1513
- }
1514
- PageAction.prototype.trackPageAction = function (pageActionEvent, properties) {
1515
- var _this = this;
1516
- var ext = {};
1517
- ext["web"] = {};
1518
- var event = {
1519
- name: "Microsoft.ApplicationInsights.{0}.Event",
1520
- baseType: "EventData",
1521
- ext: ext,
1522
- data: {},
1523
- baseData: {}
1524
- };
1525
- this._populateEventDataIfPresent(event.baseData, "name", pageActionEvent.name);
1526
- this._populateEventDataIfPresent(event.data, "baseTypeSource", "ClickEvent");
1527
- this._populateEventDataIfPresent(event.data, "uri", pageActionEvent.uri);
1528
- this._populateEventDataIfPresent(event.data, "pageType", pageActionEvent.pageType);
1529
- this._populateEventDataIfPresent(event.data, "properties", pageActionEvent.properties);
1530
- this._populateEventDataIfPresent(event.data, "actionType", pageActionEvent.actionType);
1531
- this._populateEventDataIfPresent(event.data, "behavior", pageActionEvent.behavior);
1532
- this._populateEventDataIfPresent(event.data, "clickCoordinates", pageActionEvent.clickCoordinates);
1533
- this._populateEventDataIfPresent(event.data, "content", pageActionEvent.content);
1534
- this._populateEventDataIfPresent(event.data, "targetUri", pageActionEvent.targetUri);
1535
- this._populateEventDataIfPresent(event.data, "timeToAction", pageActionEvent.timeToAction);
1536
- this._populateEventDataIfPresent(event.data, "refUri", pageActionEvent.refUri);
1537
- this._populateEventDataIfPresent(event.data, "pageName", pageActionEvent.pageName);
1538
- this._populateEventDataIfPresent(event.data, "parentId", pageActionEvent.parentId);
1539
- if (properties) {
1540
- objForEachKey(properties, function (property, value) {
1541
- if (!event.data[property]) {
1542
- _this._populateEventDataIfPresent(event.data, property, value);
2345
+ function PageAction(clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) {
2346
+ var _this = _super.call(this, clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) || this;
2347
+ dynamicProto(PageAction, _this, function (_self, _base) {
2348
+ _self.trackPageAction = function (pageActionEvent, properties) {
2349
+ var ext = {};
2350
+ ext["web"] = {};
2351
+ var event = {
2352
+ name: "Microsoft.ApplicationInsights.{0}.Event",
2353
+ baseType: "EventData",
2354
+ ext: ext,
2355
+ data: {},
2356
+ baseData: {}
2357
+ };
2358
+ _populateEventDataIfPresent(event.baseData, "name", pageActionEvent.name);
2359
+ _populateEventDataIfPresent(event.data, "baseTypeSource", "ClickEvent");
2360
+ _populateEventDataIfPresent(event.data, "uri", pageActionEvent.uri);
2361
+ _populateEventDataIfPresent(event.data, "pageType", pageActionEvent.pageType);
2362
+ _populateEventDataIfPresent(event.data, "properties", pageActionEvent.properties);
2363
+ _populateEventDataIfPresent(event.data, "actionType", pageActionEvent.actionType);
2364
+ _populateEventDataIfPresent(event.data, "behavior", pageActionEvent.behavior);
2365
+ _populateEventDataIfPresent(event.data, "clickCoordinates", pageActionEvent.clickCoordinates);
2366
+ _populateEventDataIfPresent(event.data, "content", pageActionEvent.content);
2367
+ _populateEventDataIfPresent(event.data, "targetUri", pageActionEvent.targetUri);
2368
+ _populateEventDataIfPresent(event.data, "timeToAction", pageActionEvent.timeToAction);
2369
+ _populateEventDataIfPresent(event.data, "refUri", pageActionEvent.refUri);
2370
+ _populateEventDataIfPresent(event.data, "pageName", pageActionEvent.pageName);
2371
+ _populateEventDataIfPresent(event.data, "parentId", pageActionEvent.parentId);
2372
+ if (properties) {
2373
+ objForEachKey(properties, function (property, value) {
2374
+ if (!event.data[property]) {
2375
+ _populateEventDataIfPresent(event.data, property, value);
2376
+ }
2377
+ });
1543
2378
  }
1544
- });
1545
- }
1546
- this._clickAnalyticsPlugin.core.track(event);
1547
- };
1548
- PageAction.prototype.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
1549
- overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;
1550
- var pageActionEvent = { name: "" };
1551
- var pageActionProperties = isValueAssigned(customProperties) ? customProperties : {};
1552
- this.setCommonProperties(pageActionEvent, overrideValues);
1553
- pageActionEvent.behavior = this._getBehavior(overrideValues);
1554
- var elementContent = {};
1555
- if (isRightClick) {
1556
- pageActionEvent.behavior = this._config.defaultRightClickBhvr;
1557
- }
1558
- if (element) {
1559
- pageActionEvent.targetUri = getClickTarget(element);
1560
- elementContent = this._contentHandler.getElementContent(element);
1561
- if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {
1562
- var currentBehavior = extractFieldFromObject(elementContent, "bhvr");
1563
- pageActionEvent.behavior = this._getValidBehavior(currentBehavior);
1564
- }
1565
- if (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {
1566
- this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Missing attributes id or contentName in click event. Click event information will still be collected!");
1567
- }
1568
- }
1569
- pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;
1570
- pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;
1571
- if (isValueAssigned(overrideValues.actionType)) {
1572
- pageActionEvent.actionType = overrideValues.actionType;
1573
- }
1574
- if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
1575
- pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
1576
- }
1577
- this._sanitizePageActionEventContent(elementContent);
1578
- pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));
1579
- pageActionEvent.timeToAction = this._getTimeToClick();
1580
- pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : this._config.coreData.referrerUri;
1581
- if (this._isUndefinedEvent(pageActionEvent))
1582
- return;
1583
- this.trackPageAction(pageActionEvent, pageActionProperties);
1584
- };
1585
- PageAction.prototype._getTimeToClick = function () {
1586
- var perf = getPerformance();
1587
- if (perf && perf.timing) {
1588
- var isNavigationStart = perf.timing.navigationStart;
1589
- if (isNavigationStart && isNavigationStart !== 0) {
1590
- return new Date().getTime() - isNavigationStart;
2379
+ _self._clickAnalyticsPlugin.core.track(event);
2380
+ };
2381
+ _self.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
2382
+ overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;
2383
+ var pageActionEvent = { name: "" };
2384
+ var pageActionProperties = isValueAssigned(customProperties) ? customProperties : {};
2385
+ _self.setCommonProperties(pageActionEvent, overrideValues);
2386
+ pageActionEvent.behavior = _self._getBehavior(overrideValues);
2387
+ var elementContent = {};
2388
+ if (isRightClick) {
2389
+ pageActionEvent.behavior = _self._config.defaultRightClickBhvr;
2390
+ }
2391
+ if (element) {
2392
+ pageActionEvent.targetUri = getClickTarget(element);
2393
+ elementContent = _self._contentHandler.getElementContent(element);
2394
+ if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {
2395
+ var currentBehavior = extractFieldFromObject(elementContent, "bhvr");
2396
+ pageActionEvent.behavior = _self._getValidBehavior(currentBehavior);
2397
+ }
2398
+ if (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {
2399
+ _self._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Missing attributes id or contentName in click event. Click event information will still be collected!");
2400
+ }
2401
+ }
2402
+ pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;
2403
+ pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;
2404
+ if (isValueAssigned(overrideValues.actionType)) {
2405
+ pageActionEvent.actionType = overrideValues.actionType;
2406
+ }
2407
+ if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
2408
+ pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
2409
+ }
2410
+ _sanitizePageActionEventContent(elementContent);
2411
+ pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));
2412
+ pageActionEvent.timeToAction = _getTimeToClick();
2413
+ pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : _self._config.coreData.referrerUri;
2414
+ if (_isUndefinedEvent(pageActionEvent)) {
2415
+ return;
2416
+ }
2417
+ _self.trackPageAction(pageActionEvent, pageActionProperties);
2418
+ };
2419
+ function _getTimeToClick() {
2420
+ var perf = getPerformance();
2421
+ if (perf && perf.timing) {
2422
+ var isNavigationStart = perf.timing.navigationStart;
2423
+ if (isNavigationStart && isNavigationStart !== 0) {
2424
+ return new Date().getTime() - isNavigationStart;
2425
+ }
2426
+ }
2427
+ return -1;
1591
2428
  }
1592
- }
1593
- return -1;
1594
- };
1595
- PageAction.prototype._populateEventDataIfPresent = function (obj, property, value) {
1596
- if (isValueAssigned(value)) {
1597
- obj[property] = value;
1598
- }
1599
- };
1600
- PageAction.prototype._sanitizePageActionEventContent = function (pageActionContent) {
1601
- if (pageActionContent) {
1602
- delete pageActionContent.id;
1603
- delete pageActionContent.parentid;
1604
- delete pageActionContent.parentname;
1605
- if (this._config && this._config.dataTags && isValueAssigned(this._config.dataTags.parentDataTag)) {
1606
- delete pageActionContent[this._config.dataTags.parentDataTag];
2429
+ function _populateEventDataIfPresent(obj, property, value) {
2430
+ if (isValueAssigned(value)) {
2431
+ obj[property] = value;
2432
+ }
1607
2433
  }
1608
- }
1609
- };
1610
- PageAction.prototype._isUndefinedEvent = function (pageActionEvent) {
1611
- if (this._config.dropInvalidEvents) {
1612
- if (pageActionEvent.name === strNotSpecified
1613
- && pageActionEvent.parentId === strNotSpecified
1614
- && pageActionEvent.content === "[{}]")
1615
- return true;
1616
- }
1617
- return false;
1618
- };
2434
+ function _sanitizePageActionEventContent(pageActionContent) {
2435
+ if (pageActionContent) {
2436
+ delete pageActionContent.id;
2437
+ delete pageActionContent.parentid;
2438
+ delete pageActionContent.parentname;
2439
+ if (_self._config && _self._config.dataTags && isValueAssigned(_self._config.dataTags.parentDataTag)) {
2440
+ delete pageActionContent[_self._config.dataTags.parentDataTag];
2441
+ }
2442
+ }
2443
+ }
2444
+ function _isUndefinedEvent(pageActionEvent) {
2445
+ if (_self._config.dropInvalidEvents) {
2446
+ if (pageActionEvent.name === strNotSpecified
2447
+ && pageActionEvent.parentId === strNotSpecified
2448
+ && pageActionEvent.content === "[{}]") {
2449
+ return true;
2450
+ }
2451
+ }
2452
+ return false;
2453
+ }
2454
+ });
2455
+ return _this;
2456
+ }
1619
2457
  return PageAction;
1620
2458
  }(WebEvent));
1621
2459
 
@@ -1638,77 +2476,83 @@ this.Microsoft = this.Microsoft || {};
1638
2476
  this._config = _config;
1639
2477
  this._pageAction = _pageAction;
1640
2478
  this._traceLogger = _traceLogger;
1641
- }
1642
- AutoCaptureHandler.prototype.click = function () {
1643
- var _this = this;
1644
- var win = getWindow();
1645
- var doc = getDocument();
1646
- if (win) {
1647
- var event_1 = (navigator.appVersion.indexOf("MSIE") !== -1) ? "click" : "mousedown";
1648
- attachEvent(win, event_1, function (evt) { _this._processClick(evt); });
1649
- attachEvent(win, "keyup", function (evt) { _this._processClick(evt); });
1650
- }
1651
- else if (doc) {
1652
- attachEvent(doc, "click", function (evt) { _this._processClick(evt); });
1653
- attachEvent(doc, "keyup", function (evt) { _this._processClick(evt); });
1654
- }
1655
- };
1656
- AutoCaptureHandler.prototype.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
1657
- var donotTrackTag = this._config.dataTags.customDataPrefix + this._config.dataTags.dntDataTag;
1658
- if (!isElementDnt(element, donotTrackTag)) {
1659
- this._pageAction.capturePageAction(element, overrideValues, customProperties, isRightClick);
1660
- }
1661
- };
1662
- AutoCaptureHandler.prototype._processClick = function (clickEvent) {
1663
- var clickCaptureElements = { A: true, BUTTON: true, AREA: true, INPUT: true };
1664
- var win = getWindow();
1665
- if (isNullOrUndefined(clickEvent) && win) {
1666
- clickEvent = win.event;
1667
- }
1668
- if (clickEvent) {
1669
- var element = clickEvent.srcElement || clickEvent.target;
1670
- var overrideValues = {
1671
- clickCoordinateX: clickEvent.pageX,
1672
- clickCoordinateY: clickEvent.pageY
2479
+ var _evtNamespace = mergeEvtNamespace(createUniqueNamespace("AutoCaptureHandler"), _analyticsPlugin._evtNamespace);
2480
+ dynamicProto(AutoCaptureHandler, this, function (_self) {
2481
+ _self.click = function () {
2482
+ var win = getWindow();
2483
+ var doc = getDocument();
2484
+ if (win) {
2485
+ var event_1 = (navigator.appVersion.indexOf("MSIE") !== -1) ? "click" : "mousedown";
2486
+ eventOn(win, event_1, _processClick, _evtNamespace);
2487
+ eventOn(win, "keyup", _processClick, _evtNamespace);
2488
+ }
2489
+ else if (doc) {
2490
+ eventOn(doc, "click", _processClick, _evtNamespace);
2491
+ eventOn(doc, "keyup", _processClick, _evtNamespace);
2492
+ }
1673
2493
  };
1674
- var isRightClickObj = isRightClick(clickEvent);
1675
- if (isRightClickObj) {
1676
- overrideValues.actionType = ActionType.CLICKRIGHT;
1677
- }
1678
- else if (isLeftClick(clickEvent)) {
1679
- overrideValues.actionType = ActionType.CLICKLEFT;
1680
- }
1681
- else if (isKeyboardEnter(clickEvent)) {
1682
- overrideValues.actionType = ActionType.KEYBOARDENTER;
1683
- }
1684
- else if (isKeyboardSpace(clickEvent)) {
1685
- overrideValues.actionType = ActionType.KEYBOARDSPACE;
1686
- }
1687
- else if (isMiddleClick(clickEvent)) {
1688
- overrideValues.actionType = ActionType.CLICKMIDDLE;
1689
- }
1690
- else {
1691
- return;
1692
- }
1693
- while (element && element.tagName) {
1694
- if (element.control && clickCaptureElements[element.control.tagName.toUpperCase()]) {
1695
- element = element.control;
2494
+ _self._doUnload = function (unloadCtx, unloadState, asyncCallback) {
2495
+ eventOff(getWindow(), null, null, _evtNamespace);
2496
+ eventOff(getDocument(), null, null, _evtNamespace);
2497
+ };
2498
+ function _capturePageAction(element, overrideValues, customProperties, isRightClick) {
2499
+ var donotTrackTag = _self._config.dataTags.customDataPrefix + _self._config.dataTags.dntDataTag;
2500
+ if (!isElementDnt(element, donotTrackTag)) {
2501
+ _self._pageAction.capturePageAction(element, overrideValues, customProperties, isRightClick);
1696
2502
  }
1697
- var tagNameUpperCased = element.tagName.toUpperCase();
1698
- if (!clickCaptureElements[tagNameUpperCased]) {
1699
- element = element.parentElement || element.parentNode;
1700
- continue;
2503
+ }
2504
+ function _processClick(clickEvent) {
2505
+ var clickCaptureElements = { A: true, BUTTON: true, AREA: true, INPUT: true };
2506
+ var win = getWindow();
2507
+ if (isNullOrUndefined(clickEvent) && win) {
2508
+ clickEvent = win.event;
1701
2509
  }
1702
- else {
1703
- var sendEvent = tagNameUpperCased === "INPUT" ? clickCaptureInputTypes[element.type.toUpperCase()] : true;
1704
- if (sendEvent) {
1705
- this.capturePageAction(element, overrideValues, {}, isRightClickObj);
2510
+ if (clickEvent) {
2511
+ var element = clickEvent.srcElement || clickEvent.target;
2512
+ var overrideValues = {
2513
+ clickCoordinateX: clickEvent.pageX,
2514
+ clickCoordinateY: clickEvent.pageY
2515
+ };
2516
+ var isRightClickObj = isRightClick(clickEvent);
2517
+ if (isRightClickObj) {
2518
+ overrideValues.actionType = ActionType.CLICKRIGHT;
2519
+ }
2520
+ else if (isLeftClick(clickEvent)) {
2521
+ overrideValues.actionType = ActionType.CLICKLEFT;
2522
+ }
2523
+ else if (isKeyboardEnter(clickEvent)) {
2524
+ overrideValues.actionType = ActionType.KEYBOARDENTER;
2525
+ }
2526
+ else if (isKeyboardSpace(clickEvent)) {
2527
+ overrideValues.actionType = ActionType.KEYBOARDSPACE;
2528
+ }
2529
+ else if (isMiddleClick(clickEvent)) {
2530
+ overrideValues.actionType = ActionType.CLICKMIDDLE;
2531
+ }
2532
+ else {
2533
+ return;
2534
+ }
2535
+ while (element && element.tagName) {
2536
+ if (element.control && clickCaptureElements[element.control.tagName.toUpperCase()]) {
2537
+ element = element.control;
2538
+ }
2539
+ var tagNameUpperCased = element.tagName.toUpperCase();
2540
+ if (!clickCaptureElements[tagNameUpperCased]) {
2541
+ element = element.parentElement || element.parentNode;
2542
+ continue;
2543
+ }
2544
+ else {
2545
+ var sendEvent = tagNameUpperCased === "INPUT" ? clickCaptureInputTypes[element.type.toUpperCase()] : true;
2546
+ if (sendEvent) {
2547
+ _capturePageAction(element, overrideValues, {}, isRightClickObj);
2548
+ }
2549
+ break;
2550
+ }
1706
2551
  }
1707
- break;
1708
2552
  }
1709
2553
  }
1710
- }
1711
- };
2554
+ });
2555
+ }
1712
2556
  return AutoCaptureHandler;
1713
2557
  }());
1714
2558
 
@@ -1717,285 +2561,318 @@ this.Microsoft = this.Microsoft || {};
1717
2561
  function DomContentHandler(_config, _traceLogger) {
1718
2562
  this._config = _config;
1719
2563
  this._traceLogger = _traceLogger;
1720
- }
1721
- DomContentHandler.prototype.getMetadata = function () {
1722
- var metaTags = {};
1723
- if (hasDocument) {
1724
- metaTags = isValueAssigned(this._config.dataTags.metaDataPrefix) ? this._getMetaDataFromDOM(this._config.dataTags.captureAllMetaDataContent, this._config.dataTags.metaDataPrefix, false) :
1725
- this._getMetaDataFromDOM(this._config.dataTags.captureAllMetaDataContent, "", false);
1726
- }
1727
- return metaTags;
1728
- };
1729
- DomContentHandler.prototype.getElementContent = function (element) {
1730
- if (!element) {
1731
- return {};
1732
- }
1733
- var elementContent = {};
1734
- var biBlobValue;
1735
- var parentDataTagPrefix;
1736
- var dataTagPrefix = this._config.dataTags.customDataPrefix;
1737
- var aiBlobAttributeTag = dataTagPrefix + this._config.dataTags.aiBlobAttributeTag;
1738
- if (isValueAssigned(this._config.dataTags.parentDataTag)) {
1739
- parentDataTagPrefix = dataTagPrefix + this._config.dataTags.parentDataTag;
1740
- }
1741
- if (!this._isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {
1742
- biBlobValue = element.getAttribute(aiBlobAttributeTag);
1743
- if (biBlobValue) {
1744
- try {
1745
- elementContent = JSON.parse(biBlobValue);
2564
+ dynamicProto(DomContentHandler, this, function (_self) {
2565
+ _self.getMetadata = function () {
2566
+ var dataTags = (_self._config || {}).dataTags;
2567
+ var metaTags = {};
2568
+ if (hasDocument) {
2569
+ metaTags = isValueAssigned(dataTags.metaDataPrefix) ? _getMetaDataFromDOM(dataTags.captureAllMetaDataContent, dataTags.metaDataPrefix, false) :
2570
+ _getMetaDataFromDOM(dataTags.captureAllMetaDataContent, "", false);
1746
2571
  }
1747
- catch (e) {
1748
- this._traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + biBlobValue);
2572
+ return metaTags;
2573
+ };
2574
+ _self.getElementContent = function (element) {
2575
+ if (!element) {
2576
+ return {};
1749
2577
  }
1750
- }
1751
- else {
1752
- elementContent = extend(elementContent, this._populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
1753
- }
1754
- }
1755
- else {
1756
- elementContent = extend(elementContent, this._populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
1757
- }
1758
- removeInvalidElements(elementContent);
1759
- if (parentDataTagPrefix) {
1760
- elementContent = extend(elementContent, this._getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));
1761
- }
1762
- return elementContent;
1763
- };
1764
- DomContentHandler.prototype._captureElementContentWithDataTag = function (contentElement, elementContent, dataTagPrefix) {
1765
- for (var i = 0, attrib; i < contentElement.attributes.length; i++) {
1766
- attrib = contentElement.attributes[i];
1767
- if (attrib.name.indexOf(dataTagPrefix) !== 0) {
1768
- continue;
1769
- }
1770
- var attribName = attrib.name.replace(dataTagPrefix, "");
1771
- elementContent[attribName] = attrib.value;
1772
- }
1773
- };
1774
- DomContentHandler.prototype._walkUpDomChainCaptureData = function (el, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
1775
- var element = el;
1776
- var parentDataTagFound = false;
1777
- var elementLevelFlag = false;
1778
- while (!isNullOrUndefined(element) && !isNullOrUndefined(element.attributes)) {
1779
- var attributes = element.attributes;
1780
- for (var i = 0; i < attributes.length; i++) {
1781
- var attrib = attributes[i];
1782
- if (attrib.name.indexOf(dataTagPrefix) !== 0) {
1783
- continue;
1784
- }
1785
- if (attrib.name.indexOf(parentDataTagPrefix) === 0) {
1786
- parentDataTagFound = true;
1787
- }
1788
- if (attrib.name.indexOf(aiBlobAttributeTag) === 0) {
1789
- continue;
1790
- }
1791
- var attribName = attrib.name.replace(dataTagPrefix, "");
1792
- if (elementLevelFlag && attribName === "id")
1793
- continue;
1794
- if (!isValueAssigned(elementContent[attribName])) {
2578
+ var dataTags = (_self._config || {}).dataTags;
2579
+ var elementContent = {};
2580
+ var biBlobValue;
2581
+ var parentDataTagPrefix;
2582
+ var dataTagPrefix = dataTags.customDataPrefix;
2583
+ var aiBlobAttributeTag = dataTagPrefix + dataTags.aiBlobAttributeTag;
2584
+ if (isValueAssigned(dataTags.parentDataTag)) {
2585
+ parentDataTagPrefix = dataTagPrefix + dataTags.parentDataTag;
2586
+ }
2587
+ if (!_isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {
2588
+ biBlobValue = element.getAttribute(aiBlobAttributeTag);
2589
+ if (biBlobValue) {
2590
+ try {
2591
+ elementContent = JSON.parse(biBlobValue);
2592
+ }
2593
+ catch (e) {
2594
+ _self._traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + biBlobValue);
2595
+ }
2596
+ }
2597
+ else {
2598
+ elementContent = extend(elementContent, _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
2599
+ }
2600
+ }
2601
+ else {
2602
+ elementContent = extend(elementContent, _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
2603
+ }
2604
+ removeInvalidElements(elementContent);
2605
+ if (parentDataTagPrefix) {
2606
+ elementContent = extend(elementContent, _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));
2607
+ }
2608
+ return elementContent;
2609
+ };
2610
+ function _captureElementContentWithDataTag(contentElement, elementContent, dataTagPrefix) {
2611
+ for (var i = 0, attrib; i < contentElement.attributes.length; i++) {
2612
+ attrib = contentElement.attributes[i];
2613
+ if (attrib.name.indexOf(dataTagPrefix) !== 0) {
2614
+ continue;
2615
+ }
2616
+ var attribName = attrib.name.replace(dataTagPrefix, "");
1795
2617
  elementContent[attribName] = attrib.value;
1796
2618
  }
1797
2619
  }
1798
- if (parentDataTagFound) {
1799
- break;
1800
- }
1801
- elementLevelFlag = true;
1802
- element = element.parentNode;
1803
- }
1804
- };
1805
- DomContentHandler.prototype._populateElementContent = function (element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
1806
- var elementContent = {};
1807
- if (!element)
1808
- return elementContent;
1809
- var htmlContent = this._getHtmlIdAndContentName(element);
1810
- elementContent = {
1811
- id: htmlContent.id || "",
1812
- contentName: htmlContent.contentName || ""
1813
- };
1814
- if (isValueAssigned(parentDataTagPrefix)) {
1815
- this._walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
1816
- }
1817
- if (!elementContent.id && !elementContent.contentName) {
1818
- this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
1819
- " Content information will still be collected!");
1820
- }
1821
- return elementContent;
1822
- };
1823
- DomContentHandler.prototype._populateElementContentwithDataTag = function (element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
1824
- var elementContent = {};
1825
- if (!element)
1826
- return elementContent;
1827
- var htmlContent = this._getHtmlIdAndContentName(element);
1828
- if (isValueAssigned(parentDataTagPrefix)) {
1829
- this._walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
1830
- }
1831
- else {
1832
- this._captureElementContentWithDataTag(element, elementContent, dataTagPrefix);
1833
- }
1834
- if (this._config.dataTags.useDefaultContentNameOrId) {
1835
- if (!isValueAssigned(elementContent.id)) {
1836
- elementContent.id = htmlContent.id || "";
1837
- }
1838
- elementContent.contentName = htmlContent.contentName || "";
1839
- }
1840
- if (!elementContent.id && !elementContent.contentName) {
1841
- this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
1842
- " Content information will still be collected!");
1843
- }
1844
- return elementContent;
1845
- };
1846
- DomContentHandler.prototype._getMetaDataFromDOM = function (captureAllMetaDataContent, prefix, removePrefix) {
1847
- var metaElements;
1848
- var metaData = {};
1849
- if (hasDocument) {
1850
- metaElements = document.querySelectorAll("meta");
1851
- for (var i = 0; i < metaElements.length; i++) {
1852
- var meta = metaElements[i];
1853
- if (meta.name) {
1854
- if (captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {
1855
- var name_1 = removePrefix ? meta.name.replace(prefix, "") : meta.name;
1856
- metaData[name_1] = meta.content;
2620
+ function _walkUpDomChainCaptureData(el, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
2621
+ var element = el;
2622
+ var parentDataTagFound = false;
2623
+ var elementLevelFlag = false;
2624
+ while (!isNullOrUndefined(element) && !isNullOrUndefined(element.attributes)) {
2625
+ var attributes = element.attributes;
2626
+ for (var i = 0; i < attributes.length; i++) {
2627
+ var attrib = attributes[i];
2628
+ if (attrib.name.indexOf(dataTagPrefix) !== 0) {
2629
+ continue;
2630
+ }
2631
+ if (attrib.name.indexOf(parentDataTagPrefix) === 0) {
2632
+ parentDataTagFound = true;
2633
+ }
2634
+ if (attrib.name.indexOf(aiBlobAttributeTag) === 0) {
2635
+ continue;
2636
+ }
2637
+ var attribName = attrib.name.replace(dataTagPrefix, "");
2638
+ if (elementLevelFlag && attribName === "id") {
2639
+ continue;
2640
+ }
2641
+ if (!isValueAssigned(elementContent[attribName])) {
2642
+ elementContent[attribName] = attrib.value;
2643
+ }
1857
2644
  }
2645
+ if (parentDataTagFound) {
2646
+ break;
2647
+ }
2648
+ elementLevelFlag = true;
2649
+ element = element.parentNode;
1858
2650
  }
1859
2651
  }
1860
- }
1861
- return metaData;
1862
- };
1863
- DomContentHandler.prototype._getDefaultContentName = function (element, useDefaultContentName) {
1864
- if (useDefaultContentName === false || !element.tagName) {
1865
- return "";
1866
- }
1867
- var doc = getDocument() || {};
1868
- var contentName;
1869
- switch (element.tagName) {
1870
- case "A":
1871
- contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
1872
- break;
1873
- case "IMG":
1874
- case "AREA":
1875
- contentName = element.alt;
1876
- break;
1877
- default:
1878
- contentName = element.value || element.name || element.alt || element.innerText || element.id;
1879
- }
1880
- return contentName.substring(0, MAX_CONTENTNAME_LENGTH);
1881
- };
1882
- DomContentHandler.prototype._isTracked = function (element, dataTag, aiBlobAttributeTag) {
1883
- var attrs = element.attributes;
1884
- var dataTagFound = false;
1885
- for (var i = 0; i < attrs.length; i++) {
1886
- var attributeName = attrs[i].name;
1887
- if (attributeName === aiBlobAttributeTag) {
1888
- return false;
1889
- }
1890
- else if (attributeName.indexOf(dataTag) === 0) {
1891
- dataTagFound = true;
2652
+ function _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
2653
+ var elementContent = {};
2654
+ if (!element) {
2655
+ return elementContent;
2656
+ }
2657
+ var htmlContent = _getHtmlIdAndContentName(element);
2658
+ elementContent = {
2659
+ id: htmlContent.id || "",
2660
+ contentName: htmlContent.contentName || ""
2661
+ };
2662
+ if (isValueAssigned(parentDataTagPrefix)) {
2663
+ _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
2664
+ }
2665
+ if (!elementContent.id && !elementContent.contentName) {
2666
+ _traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
2667
+ " Content information will still be collected!");
2668
+ }
2669
+ return elementContent;
1892
2670
  }
1893
- }
1894
- return dataTagFound;
1895
- };
1896
- DomContentHandler.prototype._getHtmlIdAndContentName = function (element) {
1897
- var htmlContent = {};
1898
- if (!element)
1899
- return htmlContent;
1900
- if (this._config.dataTags.useDefaultContentNameOrId) {
1901
- var customizedContentName = this._config.callback.contentName ? this._config.callback.contentName(element, this._config.dataTags.useDefaultContentNameOrId) : "";
1902
- var defaultContentName = this._getDefaultContentName(element, this._config.dataTags.useDefaultContentNameOrId);
1903
- htmlContent = {
1904
- id: element.id,
1905
- contentName: customizedContentName || defaultContentName || element.getAttribute("alt")
1906
- };
1907
- }
1908
- return htmlContent;
1909
- };
1910
- DomContentHandler.prototype._getParentDetails = function (element, elementContent, dataTagPrefix, aiBlobAttributeTag) {
1911
- var parentId = elementContent["parentid"];
1912
- var parentName = elementContent["parentname"];
1913
- var parentInfo = {};
1914
- if (parentId || parentName || !element) {
1915
- return parentInfo;
1916
- }
1917
- return this._populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);
1918
- };
1919
- DomContentHandler.prototype._populateParentInfo = function (element, dataTagPrefix, aiBlobAttributeTag) {
1920
- var parentInfo = {};
1921
- var parentId;
1922
- var closestParentElement = walkUpDomChainWithElementValidation(element.parentElement, this._isTracked, dataTagPrefix);
1923
- if (closestParentElement) {
1924
- var dataAttr = closestParentElement.getAttribute(aiBlobAttributeTag) || element[aiBlobAttributeTag];
1925
- if (dataAttr) {
1926
- try {
1927
- var telemetryObject = JSON.parse(dataAttr);
2671
+ function _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
2672
+ var dataTags = (_self._config || {}).dataTags;
2673
+ var elementContent = {};
2674
+ if (!element) {
2675
+ return elementContent;
1928
2676
  }
1929
- catch (e) {
1930
- this._traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + dataAttr);
2677
+ var htmlContent = _getHtmlIdAndContentName(element);
2678
+ if (isValueAssigned(parentDataTagPrefix)) {
2679
+ _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
1931
2680
  }
1932
- if (telemetryObject) {
1933
- parentId = telemetryObject.id;
2681
+ else {
2682
+ _captureElementContentWithDataTag(element, elementContent, dataTagPrefix);
2683
+ }
2684
+ if (dataTags.useDefaultContentNameOrId) {
2685
+ if (!isValueAssigned(elementContent.id)) {
2686
+ elementContent.id = htmlContent.id || "";
2687
+ }
2688
+ elementContent.contentName = htmlContent.contentName || "";
1934
2689
  }
2690
+ if (!elementContent.id && !elementContent.contentName) {
2691
+ _traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
2692
+ " Content information will still be collected!");
2693
+ }
2694
+ return elementContent;
2695
+ }
2696
+ function _getMetaDataFromDOM(captureAllMetaDataContent, prefix, removePrefix) {
2697
+ var metaElements;
2698
+ var metaData = {};
2699
+ if (hasDocument) {
2700
+ metaElements = document.querySelectorAll("meta");
2701
+ for (var i = 0; i < metaElements.length; i++) {
2702
+ var meta = metaElements[i];
2703
+ if (meta.name) {
2704
+ if (captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {
2705
+ var name_1 = removePrefix ? meta.name.replace(prefix, "") : meta.name;
2706
+ metaData[name_1] = meta.content;
2707
+ }
2708
+ }
2709
+ }
2710
+ }
2711
+ return metaData;
1935
2712
  }
1936
- else {
1937
- parentId = closestParentElement.getAttribute(dataTagPrefix + "id");
2713
+ function _getDefaultContentName(element, useDefaultContentName) {
2714
+ if (useDefaultContentName === false || !element.tagName) {
2715
+ return "";
2716
+ }
2717
+ var doc = getDocument() || {};
2718
+ var contentName;
2719
+ switch (element.tagName) {
2720
+ case "A":
2721
+ contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
2722
+ break;
2723
+ case "IMG":
2724
+ case "AREA":
2725
+ contentName = element.alt;
2726
+ break;
2727
+ default:
2728
+ contentName = element.value || element.name || element.alt || element.innerText || element.id;
2729
+ }
2730
+ return contentName.substring(0, MAX_CONTENTNAME_LENGTH);
2731
+ }
2732
+ function _isTracked(element, dataTag, aiBlobAttributeTag) {
2733
+ var attrs = element.attributes;
2734
+ var dataTagFound = false;
2735
+ for (var i = 0; i < attrs.length; i++) {
2736
+ var attributeName = attrs[i].name;
2737
+ if (attributeName === aiBlobAttributeTag) {
2738
+ return false;
2739
+ }
2740
+ else if (attributeName.indexOf(dataTag) === 0) {
2741
+ dataTagFound = true;
2742
+ }
2743
+ }
2744
+ return dataTagFound;
2745
+ }
2746
+ function _getHtmlIdAndContentName(element) {
2747
+ var dataTags = (_self._config || {}).dataTags;
2748
+ var callback = (_self._config || {}).callback;
2749
+ var htmlContent = {};
2750
+ if (!element) {
2751
+ return htmlContent;
2752
+ }
2753
+ if (dataTags.useDefaultContentNameOrId) {
2754
+ var customizedContentName = callback.contentName ? callback.contentName(element, dataTags.useDefaultContentNameOrId) : "";
2755
+ var defaultContentName = _getDefaultContentName(element, dataTags.useDefaultContentNameOrId);
2756
+ htmlContent = {
2757
+ id: element.id,
2758
+ contentName: customizedContentName || defaultContentName || element.getAttribute("alt")
2759
+ };
2760
+ }
2761
+ return htmlContent;
2762
+ }
2763
+ function _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag) {
2764
+ var parentId = elementContent["parentid"];
2765
+ var parentName = elementContent["parentname"];
2766
+ var parentInfo = {};
2767
+ if (parentId || parentName || !element) {
2768
+ return parentInfo;
2769
+ }
2770
+ return _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);
2771
+ }
2772
+ function _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag) {
2773
+ var parentInfo = {};
2774
+ var parentId;
2775
+ var closestParentElement = walkUpDomChainWithElementValidation(element.parentElement, _isTracked, dataTagPrefix);
2776
+ if (closestParentElement) {
2777
+ var dataAttr = closestParentElement.getAttribute(aiBlobAttributeTag) || element[aiBlobAttributeTag];
2778
+ if (dataAttr) {
2779
+ try {
2780
+ var telemetryObject = JSON.parse(dataAttr);
2781
+ }
2782
+ catch (e) {
2783
+ _traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + dataAttr);
2784
+ }
2785
+ if (telemetryObject) {
2786
+ parentId = telemetryObject.id;
2787
+ }
2788
+ }
2789
+ else {
2790
+ parentId = closestParentElement.getAttribute(dataTagPrefix + "id");
2791
+ }
2792
+ }
2793
+ if (parentId) {
2794
+ parentInfo["parentid"] = parentId;
2795
+ }
2796
+ else {
2797
+ var htmlContent = _getHtmlIdAndContentName(element.parentElement);
2798
+ parentInfo["parentid"] = htmlContent.id;
2799
+ parentInfo["parentname"] = htmlContent.contentName;
2800
+ }
2801
+ return parentInfo;
1938
2802
  }
1939
- }
1940
- if (parentId) {
1941
- parentInfo["parentid"] = parentId;
1942
- }
1943
- else {
1944
- var htmlContent = this._getHtmlIdAndContentName(element.parentElement);
1945
- parentInfo["parentid"] = htmlContent.id;
1946
- parentInfo["parentname"] = htmlContent.contentName;
1947
- }
1948
- return parentInfo;
1949
- };
2803
+ });
2804
+ }
1950
2805
  return DomContentHandler;
1951
2806
  }());
1952
2807
 
1953
2808
  var ClickAnalyticsPlugin = /** @class */ (function (_super) {
1954
2809
  __extendsFn(ClickAnalyticsPlugin, _super);
1955
2810
  function ClickAnalyticsPlugin() {
1956
- var _this = _super !== null && _super.apply(this, arguments) || this;
2811
+ var _this = _super.call(this) || this;
1957
2812
  _this.identifier = "ClickAnalyticsPlugin";
1958
2813
  _this.priority = 181;
1959
- return _this;
1960
- }
1961
- ClickAnalyticsPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1962
- if (isNullOrUndefined(core)) {
1963
- throw Error("Error initializing");
1964
- }
1965
- config.extensionConfig = config.extensionConfig || [];
1966
- config.extensionConfig[this.identifier] = config.extensionConfig[this.identifier] || {};
1967
- this._config = mergeConfig(config.extensionConfig[this.identifier]);
1968
- _super.prototype.initialize.call(this, config, core, extensions, pluginChain);
1969
- this._contentHandler = this._contentHandler ? this._contentHandler : new DomContentHandler(this._config, this.diagLog());
1970
- var metaTags = this._contentHandler.getMetadata();
1971
- this.pageAction = new PageAction(this, this._config, this._contentHandler, this._config.callback.pageActionPageTags, metaTags, this.diagLog());
1972
- this._autoCaptureHandler = this._autoCaptureHandler ? this._autoCaptureHandler : new AutoCaptureHandler(this, this._config, this.pageAction, this.diagLog());
1973
- if (this._config.autoCapture) {
1974
- this._autoCaptureHandler.click();
1975
- }
1976
- var _propertiesExtension;
1977
- arrForEach(extensions, function (extension) {
1978
- if (extension.identifier === PropertiesPluginIdentifier) {
1979
- _propertiesExtension = extension;
1980
- }
2814
+ var _config;
2815
+ var _pageAction;
2816
+ var _autoCaptureHandler;
2817
+ var _contentHandler;
2818
+ dynamicProto(ClickAnalyticsPlugin, _this, function (_self, _base) {
2819
+ var _identifier = _self.identifier;
2820
+ _initDefaults();
2821
+ _self.initialize = function (config, core, extensions, pluginChain) {
2822
+ if (isNullOrUndefined(core)) {
2823
+ throwError("Error initializing");
2824
+ }
2825
+ config.extensionConfig = config.extensionConfig || [];
2826
+ config.extensionConfig[_identifier] = config.extensionConfig[_identifier] || {};
2827
+ _config = mergeConfig(config.extensionConfig[_identifier]);
2828
+ _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
2829
+ var logger = _self.diagLog();
2830
+ _contentHandler = _contentHandler ? _contentHandler : new DomContentHandler(_config, logger);
2831
+ var metaTags = _contentHandler.getMetadata();
2832
+ _pageAction = new PageAction(_this, _config, _contentHandler, _config.callback.pageActionPageTags, metaTags, logger);
2833
+ _autoCaptureHandler = _autoCaptureHandler ? _autoCaptureHandler : new AutoCaptureHandler(_self, _config, _pageAction, logger);
2834
+ if (_config.autoCapture) {
2835
+ _autoCaptureHandler.click();
2836
+ }
2837
+ var _propertiesExtension;
2838
+ arrForEach(extensions, function (extension) {
2839
+ if (extension.identifier === PropertiesPluginIdentifier) {
2840
+ _propertiesExtension = extension;
2841
+ }
2842
+ });
2843
+ if (_propertiesExtension && _propertiesExtension.context &&
2844
+ _propertiesExtension.context.internal && _propertiesExtension.context.internal.sdkVersion) {
2845
+ _propertiesExtension.context.internal.sdkVersion += "_ClickPlugin" + ClickAnalyticsPlugin.Version;
2846
+ }
2847
+ };
2848
+ _self.processTelemetry = function (env, itemCtx) {
2849
+ _self.processNext(env, itemCtx);
2850
+ };
2851
+ _self.trackPageAction = function (pageAction, customProperties) {
2852
+ try {
2853
+ _pageAction.trackPageAction(pageAction, customProperties);
2854
+ }
2855
+ catch (e) {
2856
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
2857
+ }
2858
+ };
2859
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
2860
+ return unloadComponents([
2861
+ _autoCaptureHandler,
2862
+ _contentHandler,
2863
+ _pageAction
2864
+ ], unloadCtx, unloadState);
2865
+ };
1981
2866
  });
1982
- if (_propertiesExtension && _propertiesExtension.context &&
1983
- _propertiesExtension.context.internal && _propertiesExtension.context.internal.sdkVersion) {
1984
- _propertiesExtension.context.internal.sdkVersion += "_ClickPlugin" + ClickAnalyticsPlugin.Version;
1985
- }
1986
- };
1987
- ClickAnalyticsPlugin.prototype.processTelemetry = function (env, itemCtx) {
1988
- this.processNext(env, itemCtx);
1989
- };
1990
- ClickAnalyticsPlugin.prototype.trackPageAction = function (pageAction, customProperties) {
1991
- try {
1992
- this.pageAction.trackPageAction(pageAction, customProperties);
2867
+ function _initDefaults() {
2868
+ _config = null;
2869
+ _pageAction = null;
2870
+ _autoCaptureHandler = null;
2871
+ _contentHandler = null;
1993
2872
  }
1994
- catch (e) {
1995
- this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
1996
- }
1997
- };
1998
- ClickAnalyticsPlugin.Version = "2.8.0-nightly.2202-06";
2873
+ return _this;
2874
+ }
2875
+ ClickAnalyticsPlugin.Version = "2.8.0-nightly.2204-04";
1999
2876
  return ClickAnalyticsPlugin;
2000
2877
  }(BaseTelemetryPlugin));
2001
2878