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

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.5-nightly.2204-23.cjs.js +2011 -0
  2. package/browser/ai.clck.2.7.5-nightly.2204-23.cjs.js.map +1 -0
  3. package/browser/ai.clck.2.7.5-nightly.2204-23.cjs.min.js +6 -0
  4. package/browser/ai.clck.2.7.5-nightly.2204-23.cjs.min.js.map +1 -0
  5. package/browser/ai.clck.2.7.5-nightly.2204-23.gbl.js +2015 -0
  6. package/browser/ai.clck.2.7.5-nightly.2204-23.gbl.js.map +1 -0
  7. package/browser/ai.clck.2.7.5-nightly.2204-23.gbl.min.js +6 -0
  8. package/browser/ai.clck.2.7.5-nightly.2204-23.gbl.min.js.map +1 -0
  9. package/browser/ai.clck.2.7.5-nightly.2204-23.integrity.json +66 -0
  10. package/browser/ai.clck.2.7.5-nightly.2204-23.js +2017 -0
  11. package/browser/ai.clck.2.7.5-nightly.2204-23.js.map +1 -0
  12. package/browser/ai.clck.2.7.5-nightly.2204-23.min.js +6 -0
  13. package/browser/ai.clck.2.7.5-nightly.2204-23.min.js.map +1 -0
  14. package/browser/ai.clck.2.cjs.js +810 -1682
  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 +810 -1682
  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 +810 -1682
  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 +810 -1682
  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 +6 -6
  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.5-nightly.2204-23
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  'use strict';
@@ -73,9 +73,7 @@ var __objAssignFnImpl = function (t) {
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 @@ function __extendsFn(d, b) {
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.5
101
97
  * Copyright (c) Microsoft and contributors. All rights reserved.
102
98
  */
103
99
  var Constructor = 'constructor';
@@ -110,12 +106,13 @@ var DynClassNamePrefix = '_dynCls$';
110
106
  var DynInstChkTag = '_dynInstChk';
111
107
  var DynAllowInstChkTag = DynInstChkTag;
112
108
  var DynProtoDefaultOptions = '_dfOpts';
109
+ var DynProtoPolyProto = "_dynProto";
113
110
  var UnknownValue = '_unknown_';
114
- var str__Proto$1 = "__proto__";
111
+ var str__Proto = "__proto__";
115
112
  var strUseBaseInst = 'useBaseInst';
116
113
  var strSetInstFuncs = 'setInstFuncs';
117
114
  var Obj = Object;
118
- var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
115
+ var _objGetPrototypeOf = Obj["getPrototypeOf"];
119
116
  var _dynamicNames = 0;
120
117
  function _hasOwnProperty(obj, prop) {
121
118
  return obj && Obj[Prototype$1].hasOwnProperty.call(obj, prop);
@@ -126,13 +123,16 @@ function _isObjectOrArrayPrototype(target) {
126
123
  function _isObjectArrayOrFunctionPrototype(target) {
127
124
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype$1];
128
125
  }
129
- function _getObjProto$1(target) {
126
+ function _getObjProto(target) {
130
127
  if (target) {
131
- if (_objGetPrototypeOf$1) {
132
- return _objGetPrototypeOf$1(target);
128
+ if (_objGetPrototypeOf) {
129
+ return _objGetPrototypeOf(target);
133
130
  }
134
- var newProto = target[str__Proto$1] || target[Prototype$1] || (target[Constructor] ? target[Constructor][Prototype$1] : null);
131
+ var newProto = target[DynProtoPolyProto] || target[str__Proto] || target[Prototype$1] || (target[Constructor] ? target[Constructor][Prototype$1] : null);
135
132
  if (newProto) {
133
+ if (!target[DynProtoPolyProto]) {
134
+ target[DynProtoPolyProto] = newProto;
135
+ }
136
136
  return newProto;
137
137
  }
138
138
  }
@@ -197,16 +197,16 @@ function _getBaseFuncs(classProto, thisTarget, instFuncs, useBaseInst) {
197
197
  _forEachProp(instFuncs, function (name) {
198
198
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
199
199
  });
200
- var baseProto = _getObjProto$1(classProto);
200
+ var baseProto = _getObjProto(classProto);
201
201
  var visited = [];
202
202
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
203
203
  _forEachProp(baseProto, function (name) {
204
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
204
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
205
205
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
206
206
  }
207
207
  });
208
208
  visited.push(baseProto);
209
- baseProto = _getObjProto$1(baseProto);
209
+ baseProto = _getObjProto(baseProto);
210
210
  }
211
211
  return baseFuncs;
212
212
  }
@@ -220,7 +220,7 @@ function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
220
220
  }
221
221
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
222
222
  var canAddInst = !_hasOwnProperty(target, funcName);
223
- var objProto = _getObjProto$1(target);
223
+ var objProto = _getObjProto(target);
224
224
  var visited = [];
225
225
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
226
226
  var protoFunc = objProto[funcName];
@@ -229,7 +229,7 @@ function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
229
229
  break;
230
230
  }
231
231
  visited.push(objProto);
232
- objProto = _getObjProto$1(objProto);
232
+ objProto = _getObjProto(objProto);
233
233
  }
234
234
  try {
235
235
  if (canAddInst) {
@@ -247,7 +247,7 @@ function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
247
247
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
248
248
  var protoFunc = proto[funcName];
249
249
  if (protoFunc === currentDynProtoProxy) {
250
- protoFunc = _getObjProto$1(proto)[funcName];
250
+ protoFunc = _getObjProto(proto)[funcName];
251
251
  }
252
252
  if (typeof protoFunc !== strFunction) {
253
253
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -281,18 +281,19 @@ function _populatePrototype(proto, className, target, baseInstFuncs, setInstance
281
281
  }
282
282
  }
283
283
  function _checkPrototype(classProto, thisTarget) {
284
- if (_objGetPrototypeOf$1) {
284
+ if (_objGetPrototypeOf) {
285
285
  var visited = [];
286
- var thisProto = _getObjProto$1(thisTarget);
286
+ var thisProto = _getObjProto(thisTarget);
287
287
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
288
288
  if (thisProto === classProto) {
289
289
  return true;
290
290
  }
291
291
  visited.push(thisProto);
292
- thisProto = _getObjProto$1(thisProto);
292
+ thisProto = _getObjProto(thisProto);
293
293
  }
294
+ return false;
294
295
  }
295
- return false;
296
+ return true;
296
297
  }
297
298
  function _getObjName(target, unknownValue) {
298
299
  if (_hasOwnProperty(target, Prototype$1)) {
@@ -325,7 +326,7 @@ function dynamicProto(theClass, target, delegateFunc, options) {
325
326
  var instFuncs = _getInstanceFuncs(target);
326
327
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
327
328
  delegateFunc(target, baseFuncs);
328
- var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
329
+ var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
329
330
  if (setInstanceFunc && options) {
330
331
  setInstanceFunc = !!options[strSetInstFuncs];
331
332
  }
@@ -337,52 +338,105 @@ var perfDefaults = {
337
338
  };
338
339
  dynamicProto[DynProtoDefaultOptions] = perfDefaults;
339
340
 
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";
341
+ var LoggingSeverity;
342
+ (function (LoggingSeverity) {
343
+ LoggingSeverity[LoggingSeverity["CRITICAL"] = 1] = "CRITICAL";
344
+ LoggingSeverity[LoggingSeverity["WARNING"] = 2] = "WARNING";
345
+ })(LoggingSeverity || (LoggingSeverity = {}));
346
+ var _InternalMessageId = {
347
+ BrowserDoesNotSupportLocalStorage: 0,
348
+ BrowserCannotReadLocalStorage: 1,
349
+ BrowserCannotReadSessionStorage: 2,
350
+ BrowserCannotWriteLocalStorage: 3,
351
+ BrowserCannotWriteSessionStorage: 4,
352
+ BrowserFailedRemovalFromLocalStorage: 5,
353
+ BrowserFailedRemovalFromSessionStorage: 6,
354
+ CannotSendEmptyTelemetry: 7,
355
+ ClientPerformanceMathError: 8,
356
+ ErrorParsingAISessionCookie: 9,
357
+ ErrorPVCalc: 10,
358
+ ExceptionWhileLoggingError: 11,
359
+ FailedAddingTelemetryToBuffer: 12,
360
+ FailedMonitorAjaxAbort: 13,
361
+ FailedMonitorAjaxDur: 14,
362
+ FailedMonitorAjaxOpen: 15,
363
+ FailedMonitorAjaxRSC: 16,
364
+ FailedMonitorAjaxSend: 17,
365
+ FailedMonitorAjaxGetCorrelationHeader: 18,
366
+ FailedToAddHandlerForOnBeforeUnload: 19,
367
+ FailedToSendQueuedTelemetry: 20,
368
+ FailedToReportDataLoss: 21,
369
+ FlushFailed: 22,
370
+ MessageLimitPerPVExceeded: 23,
371
+ MissingRequiredFieldSpecification: 24,
372
+ NavigationTimingNotSupported: 25,
373
+ OnError: 26,
374
+ SessionRenewalDateIsZero: 27,
375
+ SenderNotInitialized: 28,
376
+ StartTrackEventFailed: 29,
377
+ StopTrackEventFailed: 30,
378
+ StartTrackFailed: 31,
379
+ StopTrackFailed: 32,
380
+ TelemetrySampledAndNotSent: 33,
381
+ TrackEventFailed: 34,
382
+ TrackExceptionFailed: 35,
383
+ TrackMetricFailed: 36,
384
+ TrackPVFailed: 37,
385
+ TrackPVFailedCalc: 38,
386
+ TrackTraceFailed: 39,
387
+ TransmissionFailed: 40,
388
+ FailedToSetStorageBuffer: 41,
389
+ FailedToRestoreStorageBuffer: 42,
390
+ InvalidBackendResponse: 43,
391
+ FailedToFixDepricatedValues: 44,
392
+ InvalidDurationValue: 45,
393
+ TelemetryEnvelopeInvalid: 46,
394
+ CreateEnvelopeError: 47,
395
+ CannotSerializeObject: 48,
396
+ CannotSerializeObjectNonSerializable: 49,
397
+ CircularReferenceDetected: 50,
398
+ ClearAuthContextFailed: 51,
399
+ ExceptionTruncated: 52,
400
+ IllegalCharsInName: 53,
401
+ ItemNotInArray: 54,
402
+ MaxAjaxPerPVExceeded: 55,
403
+ MessageTruncated: 56,
404
+ NameTooLong: 57,
405
+ SampleRateOutOfRange: 58,
406
+ SetAuthContextFailed: 59,
407
+ SetAuthContextFailedAccountName: 60,
408
+ StringValueTooLong: 61,
409
+ StartCalledMoreThanOnce: 62,
410
+ StopCalledWithoutStart: 63,
411
+ TelemetryInitializerFailed: 64,
412
+ TrackArgumentsNotSpecified: 65,
413
+ UrlTooLong: 66,
414
+ SessionStorageBufferFull: 67,
415
+ CannotAccessCookie: 68,
416
+ IdTooLong: 69,
417
+ InvalidEvent: 70,
418
+ FailedMonitorAjaxSetRequestHeader: 71,
419
+ SendBrowserInfoOnUserInit: 72,
420
+ PluginException: 73,
421
+ NotificationException: 74,
422
+ SnippetScriptLoadFailure: 99,
423
+ InvalidInstrumentationKey: 100,
424
+ CannotParseAiBlobValue: 101,
425
+ InvalidContentBlob: 102,
426
+ TrackPageActionEventFailed: 103,
427
+ FailedAddingCustomDefinedRequestContext: 104,
428
+ InMemoryStorageBufferFull: 105
429
+ };
348
430
 
349
- var strToISOString = "toISOString";
350
- var cStrEndsWith = "endsWith";
351
- var cStrStartsWith = "startsWith";
352
- var cStrTrim = "trim";
431
+ var strOnPrefix = "on";
432
+ var strAttachEvent = "attachEvent";
433
+ var strAddEventHelper = "addEventListener";
353
434
  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];
435
+ var _objDefineProperty = ObjDefineProperty;
366
436
  var _isArray = Array.isArray;
367
437
  var _objToString = ObjProto[strToString];
368
438
  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
- }
439
+ _fnToString.call(ObjClass);
386
440
  function isUndefined(value) {
387
441
  return value === undefined || typeof value === strShimUndefined;
388
442
  }
@@ -392,24 +446,27 @@ function isNullOrUndefined(value) {
392
446
  function hasOwnProperty(obj, prop) {
393
447
  return !!(obj && ObjHasOwnProperty.call(obj, prop));
394
448
  }
395
- function isObject(value) {
396
- return !!(value && typeof value === strShimObject);
397
- }
398
449
  function isFunction(value) {
399
450
  return !!(value && typeof value === strShimFunction);
400
451
  }
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
- });
452
+ function attachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
453
+ if (useCapture === void 0) { useCapture = false; }
454
+ var result = false;
455
+ if (!isNullOrUndefined(obj)) {
456
+ try {
457
+ if (!isNullOrUndefined(obj[strAddEventHelper])) {
458
+ obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
459
+ result = true;
460
+ }
461
+ else if (!isNullOrUndefined(obj[strAttachEvent])) {
462
+ obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
463
+ result = true;
464
+ }
465
+ }
466
+ catch (e) {
467
+ }
411
468
  }
412
- return value;
469
+ return result;
413
470
  }
414
471
  function objForEachKey(target, callbackfn) {
415
472
  if (target) {
@@ -420,12 +477,6 @@ function objForEachKey(target, callbackfn) {
420
477
  }
421
478
  }
422
479
  }
423
- function strContains(value, search) {
424
- if (value && search) {
425
- return value.indexOf(search) !== -1;
426
- }
427
- return false;
428
- }
429
480
  var isArray = _isArray || _isArrayPoly;
430
481
  function _isArrayPoly(obj) {
431
482
  return !!(obj && _objToString.call(obj) === "[object Array]");
@@ -433,28 +484,6 @@ function _isArrayPoly(obj) {
433
484
  function isError(obj) {
434
485
  return !!(obj && _objToString.call(obj) === "[object Error]");
435
486
  }
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
487
  function arrForEach(arr, callbackfn, thisArg) {
459
488
  var len = arr.length;
460
489
  try {
@@ -469,42 +498,8 @@ function arrForEach(arr, callbackfn, thisArg) {
469
498
  catch (e) {
470
499
  }
471
500
  }
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
501
  function objDefineAccessors(target, prop, getProp, setProp) {
507
- if (_objDefineProperty$1) {
502
+ if (_objDefineProperty) {
508
503
  try {
509
504
  var descriptor = {
510
505
  enumerable: true,
@@ -516,7 +511,7 @@ function objDefineAccessors(target, prop, getProp, setProp) {
516
511
  if (setProp) {
517
512
  descriptor.set = setProp;
518
513
  }
519
- _objDefineProperty$1(target, prop, descriptor);
514
+ _objDefineProperty(target, prop, descriptor);
520
515
  return true;
521
516
  }
522
517
  catch (e) {
@@ -524,10 +519,6 @@ function objDefineAccessors(target, prop, getProp, setProp) {
524
519
  }
525
520
  return false;
526
521
  }
527
- function _doNothing(value) {
528
- return value;
529
- }
530
- var objFreeze = _objFreeze || _doNothing;
531
522
  function dateNow() {
532
523
  var dt = Date;
533
524
  return dt.now ? dt.now() : new dt().getTime();
@@ -536,7 +527,7 @@ function getExceptionName(object) {
536
527
  if (isError(object)) {
537
528
  return object.name;
538
529
  }
539
- return strEmpty;
530
+ return "";
540
531
  }
541
532
  function setValue(target, field, value, valChk, srcChk) {
542
533
  var theValue = value;
@@ -549,105 +540,13 @@ function setValue(target, field, value, valChk, srcChk) {
549
540
  }
550
541
  return theValue;
551
542
  }
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
543
 
638
544
  var strWindow = "window";
639
545
  var strDocument = "document";
640
- var strNavigator = "navigator";
641
546
  var strLocation = "location";
642
547
  var strConsole = "console";
643
548
  var strPerformance = "performance";
644
549
  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
550
  var _enableMocks = false;
652
551
  function getGlobalInst(name) {
653
552
  var gbl = getGlobal();
@@ -677,15 +576,6 @@ function getDocument() {
677
576
  }
678
577
  return getGlobalInst(strDocument);
679
578
  }
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
579
  function getLocation(checkForMock) {
690
580
  if (checkForMock && _enableMocks) {
691
581
  var mockLocation = getGlobalInst("__mockLocation");
@@ -716,24 +606,9 @@ function getJSON() {
716
606
  }
717
607
  return null;
718
608
  }
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
609
  function dumpObj(object) {
735
610
  var objectTypeDump = Object[strShimPrototype].toString.call(object);
736
- var propertyValueDump = strEmpty;
611
+ var propertyValueDump = "";
737
612
  if (objectTypeDump === "[object Error]") {
738
613
  propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
739
614
  }
@@ -766,9 +641,9 @@ var strErrorToConsole = "errorToConsole";
766
641
  var strWarnToConsole = "warnToConsole";
767
642
  function _sanitizeDiagnosticText(text) {
768
643
  if (text) {
769
- return "\"" + text.replace(/\"/g, strEmpty) + "\"";
644
+ return "\"" + text.replace(/\"/g, "") + "\"";
770
645
  }
771
- return strEmpty;
646
+ return "";
772
647
  }
773
648
  function _logToConsole(func, message) {
774
649
  var theConsole = getConsole();
@@ -790,12 +665,12 @@ var _InternalLogMessage = /** @class */ (function () {
790
665
  _self.message =
791
666
  (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
792
667
  msgId;
793
- var strProps = strEmpty;
668
+ var strProps = "";
794
669
  if (hasJSON()) {
795
670
  strProps = getJSON().stringify(properties);
796
671
  }
797
- var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
798
- (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
672
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : "") +
673
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : "");
799
674
  _self.message += diagnosticText;
800
675
  }
801
676
  _InternalLogMessage.dataType = "MessageData";
@@ -822,10 +697,10 @@ var DiagnosticLogger = /** @class */ (function () {
822
697
  if (isUserAct === void 0) { isUserAct = false; }
823
698
  var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
824
699
  if (_self.enableDebugExceptions()) {
825
- throw message;
700
+ throw dumpObj(message);
826
701
  }
827
702
  else {
828
- var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
703
+ var logFunc = severity === LoggingSeverity.CRITICAL ? strErrorToConsole : strWarnToConsole;
829
704
  if (!isUndefined(message.message)) {
830
705
  var logLevel = _self.consoleLoggingLevel();
831
706
  if (isUserAct) {
@@ -843,7 +718,7 @@ var DiagnosticLogger = /** @class */ (function () {
843
718
  _self.logInternalMessage(severity, message);
844
719
  }
845
720
  else {
846
- _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
721
+ _debugExtMsg("throw" + (severity === LoggingSeverity.CRITICAL ? "Critical" : "Warning"), message);
847
722
  }
848
723
  }
849
724
  };
@@ -875,13 +750,13 @@ var DiagnosticLogger = /** @class */ (function () {
875
750
  if (severity <= _self.telemetryLoggingLevel()) {
876
751
  _self.queue.push(message);
877
752
  _messageCount++;
878
- _debugExtMsg((severity === 1 ? "error" : "warn"), message);
753
+ _debugExtMsg((severity === LoggingSeverity.CRITICAL ? "error" : "warn"), message);
879
754
  }
880
755
  if (_messageCount === _self.maxInternalMessageLimit()) {
881
756
  var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
882
- var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
757
+ var throttleMessage = new _InternalLogMessage(_InternalMessageId.MessageLimitPerPVExceeded, throttleLimitMessage, false);
883
758
  _self.queue.push(throttleMessage);
884
- if (severity === 1 ) {
759
+ if (severity === LoggingSeverity.CRITICAL) {
885
760
  _self.errorToConsole(throttleLimitMessage);
886
761
  }
887
762
  else {
@@ -910,10 +785,6 @@ var DiagnosticLogger = /** @class */ (function () {
910
785
  }
911
786
  return DiagnosticLogger;
912
787
  }());
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
788
 
918
789
  var strExecutionContextKey = "ctx";
919
790
  var PerfEvent = /** @class */ (function () {
@@ -1027,634 +898,207 @@ function doPerf(mgrSource, getSource, func, details, isAsync) {
1027
898
  return func();
1028
899
  }
1029
900
 
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
- }
901
+ var TelemetryPluginChain = /** @class */ (function () {
902
+ function TelemetryPluginChain(plugin, defItemCtx) {
903
+ var _self = this;
904
+ var _nextProxy = null;
905
+ var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
906
+ var _hasSetNext = isFunction(plugin.setNextPlugin);
907
+ _self._hasRun = false;
908
+ _self.getPlugin = function () {
909
+ return plugin;
910
+ };
911
+ _self.getNext = function () {
912
+ return _nextProxy;
913
+ };
914
+ _self.setNext = function (nextPlugin) {
915
+ _nextProxy = nextPlugin;
916
+ };
917
+ _self.processTelemetry = function (env, itemCtx) {
918
+ if (!itemCtx) {
919
+ itemCtx = defItemCtx;
1187
920
  }
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) {
921
+ var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
922
+ doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
923
+ if (plugin && _hasProcessTelemetry) {
924
+ _self._hasRun = true;
1259
925
  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));
926
+ itemCtx.setNext(_nextProxy);
927
+ if (_hasSetNext) {
928
+ plugin.setNextPlugin(_nextProxy);
929
+ }
930
+ _nextProxy && (_nextProxy._hasRun = false);
931
+ plugin.processTelemetry(env, itemCtx);
1264
932
  }
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
- }
933
+ catch (error) {
934
+ var hasRun = _nextProxy && _nextProxy._hasRun;
935
+ if (!_nextProxy || !hasRun) {
936
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1294
937
  }
1295
- });
938
+ if (_nextProxy && !hasRun) {
939
+ _nextProxy.processTelemetry(env, itemCtx);
940
+ }
941
+ }
1296
942
  }
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;
943
+ else if (_nextProxy) {
944
+ _self._hasRun = true;
945
+ _nextProxy.processTelemetry(env, itemCtx);
946
+ }
947
+ }, function () { return ({ item: env }); }, !(env.sync));
948
+ };
1312
949
  }
1313
- function _iterateChain(cb) {
1314
- var nextPlugin;
1315
- while (!!(nextPlugin = context._next())) {
1316
- var plugin = nextPlugin.getPlugin();
1317
- if (plugin) {
1318
- cb(plugin);
950
+ return TelemetryPluginChain;
951
+ }());
952
+
953
+ function _createProxyChain(plugins, itemCtx) {
954
+ var proxies = [];
955
+ if (plugins && plugins.length > 0) {
956
+ var lastProxy = null;
957
+ for (var idx = 0; idx < plugins.length; idx++) {
958
+ var thePlugin = plugins[idx];
959
+ if (thePlugin && isFunction(thePlugin.processTelemetry)) {
960
+ var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
961
+ proxies.push(newProxy);
962
+ if (lastProxy) {
963
+ lastProxy.setNext(newProxy);
964
+ }
965
+ lastProxy = newProxy;
1319
966
  }
1320
967
  }
1321
968
  }
1322
- return context;
969
+ return proxies.length > 0 ? proxies[0] : null;
1323
970
  }
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);
971
+ function _copyProxyChain(proxy, itemCtx, startAt) {
972
+ var plugins = [];
973
+ var add = startAt ? false : true;
974
+ if (proxy) {
975
+ while (proxy) {
976
+ var thePlugin = proxy.getPlugin();
977
+ if (add || thePlugin === startAt) {
978
+ add = true;
979
+ plugins.push(thePlugin);
980
+ }
981
+ proxy = proxy.getNext();
1336
982
  }
1337
- return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1338
- }
1339
- context.processNext = _processNext;
1340
- context.createNew = _createNew;
1341
- return context;
1342
- }
1343
- function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1344
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1345
- var context = internalContext.ctx;
1346
- function _processNext(unloadState) {
1347
- var nextPlugin = internalContext._next();
1348
- nextPlugin && nextPlugin.unload(context, unloadState);
1349
- return !nextPlugin;
1350
983
  }
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);
984
+ if (!add) {
985
+ plugins.push(startAt);
1357
986
  }
1358
- context.processNext = _processNext;
1359
- context.createNew = _createNew;
1360
- return context;
987
+ return _createProxyChain(plugins, itemCtx);
1361
988
  }
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);
989
+ function _copyPluginChain(srcPlugins, itemCtx, startAt) {
990
+ var plugins = srcPlugins;
991
+ var add = false;
992
+ if (startAt && srcPlugins) {
993
+ plugins = [];
994
+ arrForEach(srcPlugins, function (thePlugin) {
995
+ if (add || thePlugin === startAt) {
996
+ add = true;
997
+ plugins.push(thePlugin);
1369
998
  }
1370
999
  });
1371
1000
  }
1372
- function _createNew(plugins, startAt) {
1373
- if (plugins === void 0) { plugins = null; }
1374
- if (isArray(plugins)) {
1375
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1001
+ if (startAt && !add) {
1002
+ if (!plugins) {
1003
+ plugins = [];
1376
1004
  }
1377
- return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1005
+ plugins.push(startAt);
1378
1006
  }
1379
- context.processNext = _processNext;
1380
- context.createNew = _createNew;
1381
- return context;
1007
+ return _createProxyChain(plugins, itemCtx);
1382
1008
  }
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;
1009
+ var ProcessTelemetryContext = /** @class */ (function () {
1010
+ function ProcessTelemetryContext(plugins, config, core, startAt) {
1011
+ var _self = this;
1012
+ var _nextProxy = null;
1013
+ if (startAt !== null) {
1014
+ if (plugins && isFunction(plugins.getPlugin)) {
1015
+ _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1391
1016
  }
1392
- if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1393
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1394
- if (!firstProxy) {
1395
- firstProxy = newProxy;
1017
+ else {
1018
+ if (startAt) {
1019
+ _nextProxy = _copyPluginChain(plugins, _self, startAt);
1396
1020
  }
1397
- if (lastProxy_1) {
1398
- lastProxy_1._setNext(newProxy);
1021
+ else if (isUndefined(startAt)) {
1022
+ _nextProxy = _createProxyChain(plugins, _self);
1399
1023
  }
1400
- lastProxy_1 = newProxy;
1401
1024
  }
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
1025
  }
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
- }
1026
+ _self.core = function () {
1027
+ return core;
1028
+ };
1029
+ _self.diagLog = function () {
1030
+ return safeGetLogger(core, config);
1031
+ };
1032
+ _self.getCfg = function () {
1033
+ return config;
1034
+ };
1035
+ _self.getExtCfg = function (identifier, defaultValue) {
1036
+ if (defaultValue === void 0) { defaultValue = {}; }
1037
+ var theConfig;
1038
+ if (config) {
1039
+ var extConfig = config.extensionConfig;
1040
+ if (extConfig && identifier) {
1041
+ theConfig = extConfig[identifier];
1471
1042
  }
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
1043
  }
1486
- if (hasSetNext) {
1487
- plugin.setNextPlugin(nextProxy);
1044
+ return (theConfig ? theConfig : defaultValue);
1045
+ };
1046
+ _self.getConfig = function (identifier, field, defaultValue) {
1047
+ if (defaultValue === void 0) { defaultValue = false; }
1048
+ var theValue;
1049
+ var extConfig = _self.getExtCfg(identifier, null);
1050
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1051
+ theValue = extConfig[field];
1488
1052
  }
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
- }
1053
+ else if (config && !isNullOrUndefined(config[field])) {
1054
+ theValue = config[field];
1510
1055
  }
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
- }
1056
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1057
+ };
1058
+ _self.hasNext = function () {
1059
+ return _nextProxy != null;
1060
+ };
1061
+ _self.getNext = function () {
1062
+ return _nextProxy;
1063
+ };
1064
+ _self.setNext = function (nextPlugin) {
1065
+ _nextProxy = nextPlugin;
1066
+ };
1067
+ _self.processNext = function (env) {
1068
+ var nextPlugin = _nextProxy;
1069
+ if (nextPlugin) {
1070
+ _nextProxy = nextPlugin.getNext();
1071
+ nextPlugin.processTelemetry(env, _self);
1528
1072
  }
1529
- return hasRun;
1530
- }
1531
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1532
- updateCtx.processNext(updateState);
1533
- }
1073
+ };
1074
+ _self.createNew = function (plugins, startAt) {
1075
+ if (plugins === void 0) { plugins = null; }
1076
+ return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1077
+ };
1534
1078
  }
1535
- return objFreeze(proxyChain);
1536
- }
1079
+ return ProcessTelemetryContext;
1080
+ }());
1537
1081
 
1538
1082
  var strExtensionConfig = "extensionConfig";
1539
1083
 
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
1084
  var strGetPlugin = "getPlugin";
1565
1085
  var BaseTelemetryPlugin = /** @class */ (function () {
1566
1086
  function BaseTelemetryPlugin() {
1567
1087
  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
- });
1088
+ var _isinitialized = false;
1089
+ var _rootCtx = null;
1090
+ var _nextPlugin = null;
1091
+ _self.core = null;
1648
1092
  _self.diagLog = function (itemCtx) {
1649
- return _getTelCtx(itemCtx).diagLog();
1093
+ return _self._getTelCtx(itemCtx).diagLog();
1650
1094
  };
1651
- _self[strIsInitialized] = function () {
1095
+ _self.isInitialized = function () {
1652
1096
  return _isinitialized;
1653
1097
  };
1654
1098
  _self.setInitialized = function (isInitialized) {
1655
1099
  _isinitialized = isInitialized;
1656
1100
  };
1657
- _self[strSetNextPlugin] = function (next) {
1101
+ _self.setNextPlugin = function (next) {
1658
1102
  _nextPlugin = next;
1659
1103
  };
1660
1104
  _self.processNext = function (env, itemCtx) {
@@ -1665,12 +1109,11 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1665
1109
  _nextPlugin.processTelemetry(env, null);
1666
1110
  }
1667
1111
  };
1668
- _self._getTelCtx = _getTelCtx;
1669
- function _getTelCtx(currentCtx) {
1112
+ _self._getTelCtx = function (currentCtx) {
1670
1113
  if (currentCtx === void 0) { currentCtx = null; }
1671
1114
  var itemCtx = currentCtx;
1672
1115
  if (!itemCtx) {
1673
- var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1116
+ var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1674
1117
  if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1675
1118
  itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1676
1119
  }
@@ -1679,8 +1122,8 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1679
1122
  }
1680
1123
  }
1681
1124
  return itemCtx;
1682
- }
1683
- function _setDefaults(config, core, pluginChain) {
1125
+ };
1126
+ _self._baseTelInit = function (config, core, extensions, pluginChain) {
1684
1127
  if (config) {
1685
1128
  setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1686
1129
  }
@@ -1692,280 +1135,16 @@ var BaseTelemetryPlugin = /** @class */ (function () {
1692
1135
  nextPlugin = _nextPlugin[strGetPlugin]();
1693
1136
  }
1694
1137
  _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
- }
1138
+ _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1139
+ _isinitialized = true;
1140
+ };
1705
1141
  }
1142
+ BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1143
+ this._baseTelInit(config, core, extensions, pluginChain);
1144
+ };
1706
1145
  return BaseTelemetryPlugin;
1707
1146
  }());
1708
1147
 
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
1148
  var strNotSpecified = "not_specified";
1970
1149
 
1971
1150
  var PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin";
@@ -2260,200 +1439,188 @@ function getUri(config, location) {
2260
1439
  }
2261
1440
 
2262
1441
  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];
1442
+ function WebEvent(_clickAnalyticsPlugin, _config, _contentHandler, _pageTagsCallback, _metaTags, _traceLogger) {
1443
+ this._clickAnalyticsPlugin = _clickAnalyticsPlugin;
1444
+ this._config = _config;
1445
+ this._contentHandler = _contentHandler;
1446
+ this._pageTagsCallback = _pageTagsCallback;
1447
+ this._metaTags = _metaTags;
1448
+ this._traceLogger = _traceLogger;
1449
+ this._pageTags = {};
1450
+ }
1451
+ WebEvent.prototype.setBasicProperties = function (event, overrideValues) {
1452
+ if (!isValueAssigned(event.name)) {
1453
+ event.pageName = getPageName(this._config, overrideValues);
1454
+ }
1455
+ if (!isValueAssigned(event.uri) && hasWindow) {
1456
+ event.uri = getUri(this._config, getLocation());
1457
+ }
1458
+ };
1459
+ WebEvent.prototype.setCommonProperties = function (event, overrideValues) {
1460
+ this.setBasicProperties(event, overrideValues);
1461
+ this._setPageTags(event, overrideValues);
1462
+ this._pageTypeMetaTag = this._getMetaData(this._metaTags, this._config.coreData, "pageType");
1463
+ this._behaviorMetaTag = this._getMetaData(this._metaTags, this._config.coreData, "behavior");
1464
+ if (isValueAssigned(overrideValues.pageType)) {
1465
+ event.pageType = overrideValues.pageType;
1466
+ }
1467
+ if (isValueAssigned(this._pageTypeMetaTag) && !isValueAssigned(event.pageType)) {
1468
+ event.pageType = this._pageTypeMetaTag;
1469
+ }
1470
+ };
1471
+ WebEvent.prototype._setPageTags = function (event, overrideValues) {
1472
+ if (this._pageTagsCallback) {
1473
+ this._pageTags = extend(true, this._pageTags, this._pageTagsCallback());
1474
+ }
1475
+ if (isValueAssigned(overrideValues.pageTags)) {
1476
+ this._pageTags = extend(true, this._pageTags, overrideValues.pageTags);
1477
+ }
1478
+ if (this._metaTags) {
1479
+ this._pageTags.metaTags = {};
1480
+ for (var metaTag in this._metaTags) {
1481
+ if (metaTag != "behavior" && metaTag != "market" && metaTag != "pageType") {
1482
+ this._pageTags.metaTags[metaTag] = this._metaTags[metaTag];
2335
1483
  }
2336
- return "";
2337
1484
  }
2338
- });
2339
- }
1485
+ }
1486
+ event.properties = event.properties || {};
1487
+ event.properties["pageTags"] = this._pageTags;
1488
+ };
1489
+ WebEvent.prototype._getBehavior = function (overrideValues) {
1490
+ var behavior;
1491
+ if (overrideValues && isValueAssigned(overrideValues.behavior)) {
1492
+ behavior = overrideValues.behavior;
1493
+ }
1494
+ else if (isValueAssigned(this._behaviorMetaTag)) {
1495
+ behavior = this._behaviorMetaTag;
1496
+ }
1497
+ return this._getValidBehavior(behavior);
1498
+ };
1499
+ WebEvent.prototype._getValidBehavior = function (behavior) {
1500
+ return this._config.behaviorValidator(behavior);
1501
+ };
1502
+ WebEvent.prototype._getMetaData = function (metaTags, coreData, metaTagName) {
1503
+ if (coreData && coreData[metaTagName]) {
1504
+ return coreData[metaTagName];
1505
+ }
1506
+ else if (metaTags) {
1507
+ return metaTags[metaTagName];
1508
+ }
1509
+ return "";
1510
+ };
2340
1511
  return WebEvent;
2341
1512
  }());
2342
1513
 
2343
1514
  var PageAction = /** @class */ (function (_super) {
2344
1515
  __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
- }
1516
+ function PageAction() {
1517
+ return _super !== null && _super.apply(this, arguments) || this;
1518
+ }
1519
+ PageAction.prototype.trackPageAction = function (pageActionEvent, properties) {
1520
+ var _this = this;
1521
+ var ext = {};
1522
+ ext["web"] = {};
1523
+ var event = {
1524
+ name: "Microsoft.ApplicationInsights.{0}.Event",
1525
+ baseType: "EventData",
1526
+ ext: ext,
1527
+ data: {},
1528
+ baseData: {}
1529
+ };
1530
+ this._populateEventDataIfPresent(event.baseData, "name", pageActionEvent.name);
1531
+ this._populateEventDataIfPresent(event.data, "baseTypeSource", "ClickEvent");
1532
+ this._populateEventDataIfPresent(event.data, "uri", pageActionEvent.uri);
1533
+ this._populateEventDataIfPresent(event.data, "pageType", pageActionEvent.pageType);
1534
+ this._populateEventDataIfPresent(event.data, "properties", pageActionEvent.properties);
1535
+ this._populateEventDataIfPresent(event.data, "actionType", pageActionEvent.actionType);
1536
+ this._populateEventDataIfPresent(event.data, "behavior", pageActionEvent.behavior);
1537
+ this._populateEventDataIfPresent(event.data, "clickCoordinates", pageActionEvent.clickCoordinates);
1538
+ this._populateEventDataIfPresent(event.data, "content", pageActionEvent.content);
1539
+ this._populateEventDataIfPresent(event.data, "targetUri", pageActionEvent.targetUri);
1540
+ this._populateEventDataIfPresent(event.data, "timeToAction", pageActionEvent.timeToAction);
1541
+ this._populateEventDataIfPresent(event.data, "refUri", pageActionEvent.refUri);
1542
+ this._populateEventDataIfPresent(event.data, "pageName", pageActionEvent.pageName);
1543
+ this._populateEventDataIfPresent(event.data, "parentId", pageActionEvent.parentId);
1544
+ if (properties) {
1545
+ objForEachKey(properties, function (property, value) {
1546
+ if (!event.data[property]) {
1547
+ _this._populateEventDataIfPresent(event.data, property, value);
2442
1548
  }
1549
+ });
1550
+ }
1551
+ this._clickAnalyticsPlugin.core.track(event);
1552
+ };
1553
+ PageAction.prototype.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
1554
+ overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;
1555
+ var pageActionEvent = { name: "" };
1556
+ var pageActionProperties = isValueAssigned(customProperties) ? customProperties : {};
1557
+ this.setCommonProperties(pageActionEvent, overrideValues);
1558
+ pageActionEvent.behavior = this._getBehavior(overrideValues);
1559
+ var elementContent = {};
1560
+ if (isRightClick) {
1561
+ pageActionEvent.behavior = this._config.defaultRightClickBhvr;
1562
+ }
1563
+ if (element) {
1564
+ pageActionEvent.targetUri = getClickTarget(element);
1565
+ elementContent = this._contentHandler.getElementContent(element);
1566
+ if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {
1567
+ var currentBehavior = extractFieldFromObject(elementContent, "bhvr");
1568
+ pageActionEvent.behavior = this._getValidBehavior(currentBehavior);
1569
+ }
1570
+ if (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {
1571
+ this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Missing attributes id or contentName in click event. Click event information will still be collected!");
1572
+ }
1573
+ }
1574
+ pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;
1575
+ pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;
1576
+ if (isValueAssigned(overrideValues.actionType)) {
1577
+ pageActionEvent.actionType = overrideValues.actionType;
1578
+ }
1579
+ if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
1580
+ pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
1581
+ }
1582
+ this._sanitizePageActionEventContent(elementContent);
1583
+ pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));
1584
+ pageActionEvent.timeToAction = this._getTimeToClick();
1585
+ pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : this._config.coreData.referrerUri;
1586
+ if (this._isUndefinedEvent(pageActionEvent))
1587
+ return;
1588
+ this.trackPageAction(pageActionEvent, pageActionProperties);
1589
+ };
1590
+ PageAction.prototype._getTimeToClick = function () {
1591
+ var perf = getPerformance();
1592
+ if (perf && perf.timing) {
1593
+ var isNavigationStart = perf.timing.navigationStart;
1594
+ if (isNavigationStart && isNavigationStart !== 0) {
1595
+ return new Date().getTime() - isNavigationStart;
2443
1596
  }
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;
1597
+ }
1598
+ return -1;
1599
+ };
1600
+ PageAction.prototype._populateEventDataIfPresent = function (obj, property, value) {
1601
+ if (isValueAssigned(value)) {
1602
+ obj[property] = value;
1603
+ }
1604
+ };
1605
+ PageAction.prototype._sanitizePageActionEventContent = function (pageActionContent) {
1606
+ if (pageActionContent) {
1607
+ delete pageActionContent.id;
1608
+ delete pageActionContent.parentid;
1609
+ delete pageActionContent.parentname;
1610
+ if (this._config && this._config.dataTags && isValueAssigned(this._config.dataTags.parentDataTag)) {
1611
+ delete pageActionContent[this._config.dataTags.parentDataTag];
2453
1612
  }
2454
- });
2455
- return _this;
2456
- }
1613
+ }
1614
+ };
1615
+ PageAction.prototype._isUndefinedEvent = function (pageActionEvent) {
1616
+ if (this._config.dropInvalidEvents) {
1617
+ if (pageActionEvent.name === strNotSpecified
1618
+ && pageActionEvent.parentId === strNotSpecified
1619
+ && pageActionEvent.content === "[{}]")
1620
+ return true;
1621
+ }
1622
+ return false;
1623
+ };
2457
1624
  return PageAction;
2458
1625
  }(WebEvent));
2459
1626
 
@@ -2476,83 +1643,77 @@ var AutoCaptureHandler = /** @class */ (function () {
2476
1643
  this._config = _config;
2477
1644
  this._pageAction = _pageAction;
2478
1645
  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);
1646
+ }
1647
+ AutoCaptureHandler.prototype.click = function () {
1648
+ var _this = this;
1649
+ var win = getWindow();
1650
+ var doc = getDocument();
1651
+ if (win) {
1652
+ var event_1 = (navigator.appVersion.indexOf("MSIE") !== -1) ? "click" : "mousedown";
1653
+ attachEvent(win, event_1, function (evt) { _this._processClick(evt); });
1654
+ attachEvent(win, "keyup", function (evt) { _this._processClick(evt); });
1655
+ }
1656
+ else if (doc) {
1657
+ attachEvent(doc, "click", function (evt) { _this._processClick(evt); });
1658
+ attachEvent(doc, "keyup", function (evt) { _this._processClick(evt); });
1659
+ }
1660
+ };
1661
+ AutoCaptureHandler.prototype.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
1662
+ var donotTrackTag = this._config.dataTags.customDataPrefix + this._config.dataTags.dntDataTag;
1663
+ if (!isElementDnt(element, donotTrackTag)) {
1664
+ this._pageAction.capturePageAction(element, overrideValues, customProperties, isRightClick);
1665
+ }
1666
+ };
1667
+ AutoCaptureHandler.prototype._processClick = function (clickEvent) {
1668
+ var clickCaptureElements = { A: true, BUTTON: true, AREA: true, INPUT: true };
1669
+ var win = getWindow();
1670
+ if (isNullOrUndefined(clickEvent) && win) {
1671
+ clickEvent = win.event;
1672
+ }
1673
+ if (clickEvent) {
1674
+ var element = clickEvent.srcElement || clickEvent.target;
1675
+ var overrideValues = {
1676
+ clickCoordinateX: clickEvent.pageX,
1677
+ clickCoordinateY: clickEvent.pageY
2497
1678
  };
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
- }
1679
+ var isRightClickObj = isRightClick(clickEvent);
1680
+ if (isRightClickObj) {
1681
+ overrideValues.actionType = ActionType.CLICKRIGHT;
1682
+ }
1683
+ else if (isLeftClick(clickEvent)) {
1684
+ overrideValues.actionType = ActionType.CLICKLEFT;
1685
+ }
1686
+ else if (isKeyboardEnter(clickEvent)) {
1687
+ overrideValues.actionType = ActionType.KEYBOARDENTER;
1688
+ }
1689
+ else if (isKeyboardSpace(clickEvent)) {
1690
+ overrideValues.actionType = ActionType.KEYBOARDSPACE;
2503
1691
  }
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;
1692
+ else if (isMiddleClick(clickEvent)) {
1693
+ overrideValues.actionType = ActionType.CLICKMIDDLE;
1694
+ }
1695
+ else {
1696
+ return;
1697
+ }
1698
+ while (element && element.tagName) {
1699
+ if (element.control && clickCaptureElements[element.control.tagName.toUpperCase()]) {
1700
+ element = element.control;
2509
1701
  }
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
- }
1702
+ var tagNameUpperCased = element.tagName.toUpperCase();
1703
+ if (!clickCaptureElements[tagNameUpperCased]) {
1704
+ element = element.parentElement || element.parentNode;
1705
+ continue;
1706
+ }
1707
+ else {
1708
+ var sendEvent = tagNameUpperCased === "INPUT" ? clickCaptureInputTypes[element.type.toUpperCase()] : true;
1709
+ if (sendEvent) {
1710
+ this.capturePageAction(element, overrideValues, {}, isRightClickObj);
2551
1711
  }
1712
+ break;
2552
1713
  }
2553
1714
  }
2554
- });
2555
- }
1715
+ }
1716
+ };
2556
1717
  return AutoCaptureHandler;
2557
1718
  }());
2558
1719
 
@@ -2561,318 +1722,285 @@ var DomContentHandler = /** @class */ (function () {
2561
1722
  function DomContentHandler(_config, _traceLogger) {
2562
1723
  this._config = _config;
2563
1724
  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));
1725
+ }
1726
+ DomContentHandler.prototype.getMetadata = function () {
1727
+ var metaTags = {};
1728
+ if (hasDocument) {
1729
+ metaTags = isValueAssigned(this._config.dataTags.metaDataPrefix) ? this._getMetaDataFromDOM(this._config.dataTags.captureAllMetaDataContent, this._config.dataTags.metaDataPrefix, false) :
1730
+ this._getMetaDataFromDOM(this._config.dataTags.captureAllMetaDataContent, "", false);
1731
+ }
1732
+ return metaTags;
1733
+ };
1734
+ DomContentHandler.prototype.getElementContent = function (element) {
1735
+ if (!element) {
1736
+ return {};
1737
+ }
1738
+ var elementContent = {};
1739
+ var biBlobValue;
1740
+ var parentDataTagPrefix;
1741
+ var dataTagPrefix = this._config.dataTags.customDataPrefix;
1742
+ var aiBlobAttributeTag = dataTagPrefix + this._config.dataTags.aiBlobAttributeTag;
1743
+ if (isValueAssigned(this._config.dataTags.parentDataTag)) {
1744
+ parentDataTagPrefix = dataTagPrefix + this._config.dataTags.parentDataTag;
1745
+ }
1746
+ if (!this._isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {
1747
+ biBlobValue = element.getAttribute(aiBlobAttributeTag);
1748
+ if (biBlobValue) {
1749
+ try {
1750
+ elementContent = JSON.parse(biBlobValue);
2603
1751
  }
2604
- removeInvalidElements(elementContent);
2605
- if (parentDataTagPrefix) {
2606
- elementContent = extend(elementContent, _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));
1752
+ catch (e) {
1753
+ this._traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + biBlobValue);
2607
1754
  }
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, "");
1755
+ }
1756
+ else {
1757
+ elementContent = extend(elementContent, this._populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
1758
+ }
1759
+ }
1760
+ else {
1761
+ elementContent = extend(elementContent, this._populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
1762
+ }
1763
+ removeInvalidElements(elementContent);
1764
+ if (parentDataTagPrefix) {
1765
+ elementContent = extend(elementContent, this._getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));
1766
+ }
1767
+ return elementContent;
1768
+ };
1769
+ DomContentHandler.prototype._captureElementContentWithDataTag = function (contentElement, elementContent, dataTagPrefix) {
1770
+ for (var i = 0, attrib; i < contentElement.attributes.length; i++) {
1771
+ attrib = contentElement.attributes[i];
1772
+ if (attrib.name.indexOf(dataTagPrefix) !== 0) {
1773
+ continue;
1774
+ }
1775
+ var attribName = attrib.name.replace(dataTagPrefix, "");
1776
+ elementContent[attribName] = attrib.value;
1777
+ }
1778
+ };
1779
+ DomContentHandler.prototype._walkUpDomChainCaptureData = function (el, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
1780
+ var element = el;
1781
+ var parentDataTagFound = false;
1782
+ var elementLevelFlag = false;
1783
+ while (!isNullOrUndefined(element) && !isNullOrUndefined(element.attributes)) {
1784
+ var attributes = element.attributes;
1785
+ for (var i = 0; i < attributes.length; i++) {
1786
+ var attrib = attributes[i];
1787
+ if (attrib.name.indexOf(dataTagPrefix) !== 0) {
1788
+ continue;
1789
+ }
1790
+ if (attrib.name.indexOf(parentDataTagPrefix) === 0) {
1791
+ parentDataTagFound = true;
1792
+ }
1793
+ if (attrib.name.indexOf(aiBlobAttributeTag) === 0) {
1794
+ continue;
1795
+ }
1796
+ var attribName = attrib.name.replace(dataTagPrefix, "");
1797
+ if (elementLevelFlag && attribName === "id")
1798
+ continue;
1799
+ if (!isValueAssigned(elementContent[attribName])) {
2617
1800
  elementContent[attribName] = attrib.value;
2618
1801
  }
2619
1802
  }
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
- }
1803
+ if (parentDataTagFound) {
1804
+ break;
2651
1805
  }
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;
1806
+ elementLevelFlag = true;
1807
+ element = element.parentNode;
1808
+ }
1809
+ };
1810
+ DomContentHandler.prototype._populateElementContent = function (element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
1811
+ var elementContent = {};
1812
+ if (!element)
1813
+ return elementContent;
1814
+ var htmlContent = this._getHtmlIdAndContentName(element);
1815
+ elementContent = {
1816
+ id: htmlContent.id || "",
1817
+ contentName: htmlContent.contentName || ""
1818
+ };
1819
+ if (isValueAssigned(parentDataTagPrefix)) {
1820
+ this._walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
1821
+ }
1822
+ if (!elementContent.id && !elementContent.contentName) {
1823
+ this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
1824
+ " Content information will still be collected!");
1825
+ }
1826
+ return elementContent;
1827
+ };
1828
+ DomContentHandler.prototype._populateElementContentwithDataTag = function (element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
1829
+ var elementContent = {};
1830
+ if (!element)
1831
+ return elementContent;
1832
+ var htmlContent = this._getHtmlIdAndContentName(element);
1833
+ if (isValueAssigned(parentDataTagPrefix)) {
1834
+ this._walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
1835
+ }
1836
+ else {
1837
+ this._captureElementContentWithDataTag(element, elementContent, dataTagPrefix);
1838
+ }
1839
+ if (this._config.dataTags.useDefaultContentNameOrId) {
1840
+ if (!isValueAssigned(elementContent.id)) {
1841
+ elementContent.id = htmlContent.id || "";
2670
1842
  }
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
- }
1843
+ elementContent.contentName = htmlContent.contentName || "";
1844
+ }
1845
+ if (!elementContent.id && !elementContent.contentName) {
1846
+ this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
1847
+ " Content information will still be collected!");
1848
+ }
1849
+ return elementContent;
1850
+ };
1851
+ DomContentHandler.prototype._getMetaDataFromDOM = function (captureAllMetaDataContent, prefix, removePrefix) {
1852
+ var metaElements;
1853
+ var metaData = {};
1854
+ if (hasDocument) {
1855
+ metaElements = document.querySelectorAll("meta");
1856
+ for (var i = 0; i < metaElements.length; i++) {
1857
+ var meta = metaElements[i];
1858
+ if (meta.name) {
1859
+ if (captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {
1860
+ var name_1 = removePrefix ? meta.name.replace(prefix, "") : meta.name;
1861
+ metaData[name_1] = meta.content;
2709
1862
  }
2710
1863
  }
2711
- return metaData;
2712
1864
  }
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
- }
1865
+ }
1866
+ return metaData;
1867
+ };
1868
+ DomContentHandler.prototype._getDefaultContentName = function (element, useDefaultContentName) {
1869
+ if (useDefaultContentName === false || !element.tagName) {
1870
+ return "";
1871
+ }
1872
+ var doc = getDocument() || {};
1873
+ var contentName;
1874
+ switch (element.tagName) {
1875
+ case "A":
1876
+ contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
1877
+ break;
1878
+ case "IMG":
1879
+ case "AREA":
1880
+ contentName = element.alt;
1881
+ break;
1882
+ default:
1883
+ contentName = element.value || element.name || element.alt || element.innerText || element.id;
1884
+ }
1885
+ return contentName.substring(0, MAX_CONTENTNAME_LENGTH);
1886
+ };
1887
+ DomContentHandler.prototype._isTracked = function (element, dataTag, aiBlobAttributeTag) {
1888
+ var attrs = element.attributes;
1889
+ var dataTagFound = false;
1890
+ for (var i = 0; i < attrs.length; i++) {
1891
+ var attributeName = attrs[i].name;
1892
+ if (attributeName === aiBlobAttributeTag) {
1893
+ return false;
1894
+ }
1895
+ else if (attributeName.indexOf(dataTag) === 0) {
1896
+ dataTagFound = true;
1897
+ }
1898
+ }
1899
+ return dataTagFound;
1900
+ };
1901
+ DomContentHandler.prototype._getHtmlIdAndContentName = function (element) {
1902
+ var htmlContent = {};
1903
+ if (!element)
1904
+ return htmlContent;
1905
+ if (this._config.dataTags.useDefaultContentNameOrId) {
1906
+ var customizedContentName = this._config.callback.contentName ? this._config.callback.contentName(element, this._config.dataTags.useDefaultContentNameOrId) : "";
1907
+ var defaultContentName = this._getDefaultContentName(element, this._config.dataTags.useDefaultContentNameOrId);
1908
+ htmlContent = {
1909
+ id: element.id,
1910
+ contentName: customizedContentName || defaultContentName || element.getAttribute("alt")
1911
+ };
1912
+ }
1913
+ return htmlContent;
1914
+ };
1915
+ DomContentHandler.prototype._getParentDetails = function (element, elementContent, dataTagPrefix, aiBlobAttributeTag) {
1916
+ var parentId = elementContent["parentid"];
1917
+ var parentName = elementContent["parentname"];
1918
+ var parentInfo = {};
1919
+ if (parentId || parentName || !element) {
1920
+ return parentInfo;
1921
+ }
1922
+ return this._populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);
1923
+ };
1924
+ DomContentHandler.prototype._populateParentInfo = function (element, dataTagPrefix, aiBlobAttributeTag) {
1925
+ var parentInfo = {};
1926
+ var parentId;
1927
+ var closestParentElement = walkUpDomChainWithElementValidation(element.parentElement, this._isTracked, dataTagPrefix);
1928
+ if (closestParentElement) {
1929
+ var dataAttr = closestParentElement.getAttribute(aiBlobAttributeTag) || element[aiBlobAttributeTag];
1930
+ if (dataAttr) {
1931
+ try {
1932
+ var telemetryObject = JSON.parse(dataAttr);
2792
1933
  }
2793
- if (parentId) {
2794
- parentInfo["parentid"] = parentId;
1934
+ catch (e) {
1935
+ this._traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + dataAttr);
2795
1936
  }
2796
- else {
2797
- var htmlContent = _getHtmlIdAndContentName(element.parentElement);
2798
- parentInfo["parentid"] = htmlContent.id;
2799
- parentInfo["parentname"] = htmlContent.contentName;
1937
+ if (telemetryObject) {
1938
+ parentId = telemetryObject.id;
2800
1939
  }
2801
- return parentInfo;
2802
1940
  }
2803
- });
2804
- }
1941
+ else {
1942
+ parentId = closestParentElement.getAttribute(dataTagPrefix + "id");
1943
+ }
1944
+ }
1945
+ if (parentId) {
1946
+ parentInfo["parentid"] = parentId;
1947
+ }
1948
+ else {
1949
+ var htmlContent = this._getHtmlIdAndContentName(element.parentElement);
1950
+ parentInfo["parentid"] = htmlContent.id;
1951
+ parentInfo["parentname"] = htmlContent.contentName;
1952
+ }
1953
+ return parentInfo;
1954
+ };
2805
1955
  return DomContentHandler;
2806
1956
  }());
2807
1957
 
2808
1958
  var ClickAnalyticsPlugin = /** @class */ (function (_super) {
2809
1959
  __extendsFn(ClickAnalyticsPlugin, _super);
2810
1960
  function ClickAnalyticsPlugin() {
2811
- var _this = _super.call(this) || this;
1961
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2812
1962
  _this.identifier = "ClickAnalyticsPlugin";
2813
1963
  _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
1964
  return _this;
2874
1965
  }
2875
- ClickAnalyticsPlugin.Version = "2.7.5-nightly.2204-03";
1966
+ ClickAnalyticsPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1967
+ if (isNullOrUndefined(core)) {
1968
+ throw Error("Error initializing");
1969
+ }
1970
+ config.extensionConfig = config.extensionConfig || [];
1971
+ config.extensionConfig[this.identifier] = config.extensionConfig[this.identifier] || {};
1972
+ this._config = mergeConfig(config.extensionConfig[this.identifier]);
1973
+ _super.prototype.initialize.call(this, config, core, extensions, pluginChain);
1974
+ this._contentHandler = this._contentHandler ? this._contentHandler : new DomContentHandler(this._config, this.diagLog());
1975
+ var metaTags = this._contentHandler.getMetadata();
1976
+ this.pageAction = new PageAction(this, this._config, this._contentHandler, this._config.callback.pageActionPageTags, metaTags, this.diagLog());
1977
+ this._autoCaptureHandler = this._autoCaptureHandler ? this._autoCaptureHandler : new AutoCaptureHandler(this, this._config, this.pageAction, this.diagLog());
1978
+ if (this._config.autoCapture) {
1979
+ this._autoCaptureHandler.click();
1980
+ }
1981
+ var _propertiesExtension;
1982
+ arrForEach(extensions, function (extension) {
1983
+ if (extension.identifier === PropertiesPluginIdentifier) {
1984
+ _propertiesExtension = extension;
1985
+ }
1986
+ });
1987
+ if (_propertiesExtension && _propertiesExtension.context &&
1988
+ _propertiesExtension.context.internal && _propertiesExtension.context.internal.sdkVersion) {
1989
+ _propertiesExtension.context.internal.sdkVersion += "_ClickPlugin" + ClickAnalyticsPlugin.Version;
1990
+ }
1991
+ };
1992
+ ClickAnalyticsPlugin.prototype.processTelemetry = function (env, itemCtx) {
1993
+ this.processNext(env, itemCtx);
1994
+ };
1995
+ ClickAnalyticsPlugin.prototype.trackPageAction = function (pageAction, customProperties) {
1996
+ try {
1997
+ this.pageAction.trackPageAction(pageAction, customProperties);
1998
+ }
1999
+ catch (e) {
2000
+ this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
2001
+ }
2002
+ };
2003
+ ClickAnalyticsPlugin.Version = "2.7.5-nightly.2204-23";
2876
2004
  return ClickAnalyticsPlugin;
2877
2005
  }(BaseTelemetryPlugin));
2878
2006