@microsoft/applicationinsights-clickanalytics-js 2.7.5-nightly.2204-03 → 2.7.6

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