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

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