@microsoft/applicationinsights-clickanalytics-js 2.7.4-nightly.2202-09 → 2.8.0-beta.2202-07

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 (55) hide show
  1. package/browser/{ai.clck.2.7.4-nightly.2202-09.cjs.js → ai.clck.2.8.0-beta.2202-07.cjs.js} +349 -188
  2. package/browser/ai.clck.2.8.0-beta.2202-07.cjs.js.map +1 -0
  3. package/browser/ai.clck.2.8.0-beta.2202-07.cjs.min.js +6 -0
  4. package/browser/ai.clck.2.8.0-beta.2202-07.cjs.min.js.map +1 -0
  5. package/browser/{ai.clck.2.7.4-nightly.2202-09.gbl.js → ai.clck.2.8.0-beta.2202-07.gbl.js} +349 -188
  6. package/browser/ai.clck.2.8.0-beta.2202-07.gbl.js.map +1 -0
  7. package/browser/ai.clck.2.8.0-beta.2202-07.gbl.min.js +6 -0
  8. package/browser/ai.clck.2.8.0-beta.2202-07.gbl.min.js.map +1 -0
  9. package/browser/ai.clck.2.8.0-beta.2202-07.integrity.json +66 -0
  10. package/browser/{ai.clck.2.7.4-nightly.2202-09.js → ai.clck.2.8.0-beta.2202-07.js} +349 -188
  11. package/browser/ai.clck.2.8.0-beta.2202-07.js.map +1 -0
  12. package/browser/ai.clck.2.8.0-beta.2202-07.min.js +6 -0
  13. package/browser/ai.clck.2.8.0-beta.2202-07.min.js.map +1 -0
  14. package/browser/ai.clck.2.cjs.js +348 -187
  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 +348 -187
  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 +348 -187
  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.d.ts +1 -1
  27. package/dist/applicationinsights-clickanalytics-js.js +348 -187
  28. package/dist/applicationinsights-clickanalytics-js.js.map +1 -1
  29. package/dist/applicationinsights-clickanalytics-js.min.js +2 -2
  30. package/dist/applicationinsights-clickanalytics-js.min.js.map +1 -1
  31. package/dist/applicationinsights-clickanalytics-js.rollup.d.ts +1 -1
  32. package/dist-esm/Behaviours.js +1 -1
  33. package/dist-esm/ClickAnalyticsPlugin.js +2 -2
  34. package/dist-esm/ClickAnalyticsPlugin.js.map +1 -1
  35. package/dist-esm/DataCollector.js +1 -1
  36. package/dist-esm/Enums.js +1 -1
  37. package/dist-esm/Interfaces/Datamodel.js +1 -1
  38. package/dist-esm/applicationinsights-clickanalytics-js.js +1 -1
  39. package/dist-esm/common/Utils.js +1 -1
  40. package/dist-esm/events/PageAction.js +1 -1
  41. package/dist-esm/events/WebEvent.js +1 -1
  42. package/dist-esm/handlers/AutoCaptureHandler.js +1 -1
  43. package/dist-esm/handlers/DomContentHandler.js +1 -1
  44. package/package.json +5 -5
  45. package/src/ClickAnalyticsPlugin.ts +1 -1
  46. package/browser/ai.clck.2.7.4-nightly.2202-09.cjs.js.map +0 -1
  47. package/browser/ai.clck.2.7.4-nightly.2202-09.cjs.min.js +0 -6
  48. package/browser/ai.clck.2.7.4-nightly.2202-09.cjs.min.js.map +0 -1
  49. package/browser/ai.clck.2.7.4-nightly.2202-09.gbl.js.map +0 -1
  50. package/browser/ai.clck.2.7.4-nightly.2202-09.gbl.min.js +0 -6
  51. package/browser/ai.clck.2.7.4-nightly.2202-09.gbl.min.js.map +0 -1
  52. package/browser/ai.clck.2.7.4-nightly.2202-09.integrity.json +0 -66
  53. package/browser/ai.clck.2.7.4-nightly.2202-09.js.map +0 -1
  54. package/browser/ai.clck.2.7.4-nightly.2202-09.min.js +0 -6
  55. package/browser/ai.clck.2.7.4-nightly.2202-09.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Click Analytics, 2.7.4-nightly.2202-09
2
+ * Application Insights JavaScript SDK - Click Analytics, 2.8.0-beta.2202-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -109,11 +109,11 @@
109
109
  var DynAllowInstChkTag = DynInstChkTag;
110
110
  var DynProtoDefaultOptions = '_dfOpts';
111
111
  var UnknownValue = '_unknown_';
112
- var str__Proto = "__proto__";
112
+ var str__Proto$1 = "__proto__";
113
113
  var strUseBaseInst = 'useBaseInst';
114
114
  var strSetInstFuncs = 'setInstFuncs';
115
115
  var Obj = Object;
116
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
116
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
117
117
  var _dynamicNames = 0;
118
118
  function _hasOwnProperty(obj, prop) {
119
119
  return obj && Obj[Prototype$1].hasOwnProperty.call(obj, prop);
@@ -124,12 +124,12 @@
124
124
  function _isObjectArrayOrFunctionPrototype(target) {
125
125
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype$1];
126
126
  }
127
- function _getObjProto(target) {
127
+ function _getObjProto$1(target) {
128
128
  if (target) {
129
- if (_objGetPrototypeOf) {
130
- return _objGetPrototypeOf(target);
129
+ if (_objGetPrototypeOf$1) {
130
+ return _objGetPrototypeOf$1(target);
131
131
  }
132
- var newProto = target[str__Proto] || target[Prototype$1] || (target[Constructor] ? target[Constructor][Prototype$1] : null);
132
+ var newProto = target[str__Proto$1] || target[Prototype$1] || (target[Constructor] ? target[Constructor][Prototype$1] : null);
133
133
  if (newProto) {
134
134
  return newProto;
135
135
  }
@@ -195,16 +195,16 @@
195
195
  _forEachProp(instFuncs, function (name) {
196
196
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
197
197
  });
198
- var baseProto = _getObjProto(classProto);
198
+ var baseProto = _getObjProto$1(classProto);
199
199
  var visited = [];
200
200
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
201
201
  _forEachProp(baseProto, function (name) {
202
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
202
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
203
203
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
204
204
  }
205
205
  });
206
206
  visited.push(baseProto);
207
- baseProto = _getObjProto(baseProto);
207
+ baseProto = _getObjProto$1(baseProto);
208
208
  }
209
209
  return baseFuncs;
210
210
  }
@@ -218,7 +218,7 @@
218
218
  }
219
219
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
220
220
  var canAddInst = !_hasOwnProperty(target, funcName);
221
- var objProto = _getObjProto(target);
221
+ var objProto = _getObjProto$1(target);
222
222
  var visited = [];
223
223
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
224
224
  var protoFunc = objProto[funcName];
@@ -227,7 +227,7 @@
227
227
  break;
228
228
  }
229
229
  visited.push(objProto);
230
- objProto = _getObjProto(objProto);
230
+ objProto = _getObjProto$1(objProto);
231
231
  }
232
232
  try {
233
233
  if (canAddInst) {
@@ -245,7 +245,7 @@
245
245
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
246
246
  var protoFunc = proto[funcName];
247
247
  if (protoFunc === currentDynProtoProxy) {
248
- protoFunc = _getObjProto(proto)[funcName];
248
+ protoFunc = _getObjProto$1(proto)[funcName];
249
249
  }
250
250
  if (typeof protoFunc !== strFunction) {
251
251
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -279,15 +279,15 @@
279
279
  }
280
280
  }
281
281
  function _checkPrototype(classProto, thisTarget) {
282
- if (_objGetPrototypeOf) {
282
+ if (_objGetPrototypeOf$1) {
283
283
  var visited = [];
284
- var thisProto = _getObjProto(thisTarget);
284
+ var thisProto = _getObjProto$1(thisTarget);
285
285
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
286
286
  if (thisProto === classProto) {
287
287
  return true;
288
288
  }
289
289
  visited.push(thisProto);
290
- thisProto = _getObjProto(thisProto);
290
+ thisProto = _getObjProto$1(thisProto);
291
291
  }
292
292
  }
293
293
  return false;
@@ -323,7 +323,7 @@
323
323
  var instFuncs = _getInstanceFuncs(target);
324
324
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
325
325
  delegateFunc(target, baseFuncs);
326
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
326
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
327
327
  if (setInstanceFunc && options) {
328
328
  setInstanceFunc = !!options[strSetInstFuncs];
329
329
  }
@@ -429,11 +429,27 @@
429
429
  var strAttachEvent = "attachEvent";
430
430
  var strAddEventHelper = "addEventListener";
431
431
  var strToString = "toString";
432
+ var str__Proto = "__proto__";
433
+ var strConstructor = "constructor";
432
434
  var _objDefineProperty = ObjDefineProperty;
435
+ var _objFreeze = ObjClass.freeze;
433
436
  var _isArray = Array.isArray;
434
437
  var _objToString = ObjProto[strToString];
435
438
  var _fnToString = ObjHasOwnProperty[strToString];
436
- _fnToString.call(ObjClass);
439
+ var _objFunctionString = _fnToString.call(ObjClass);
440
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
441
+ function _getObjProto(target) {
442
+ if (target) {
443
+ if (_objGetPrototypeOf) {
444
+ return _objGetPrototypeOf(target);
445
+ }
446
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
447
+ if (newProto) {
448
+ return newProto;
449
+ }
450
+ }
451
+ return null;
452
+ }
437
453
  function isUndefined(value) {
438
454
  return value === undefined || typeof value === strShimUndefined;
439
455
  }
@@ -443,6 +459,9 @@
443
459
  function hasOwnProperty(obj, prop) {
444
460
  return !!(obj && ObjHasOwnProperty.call(obj, prop));
445
461
  }
462
+ function isObject(value) {
463
+ return !!(value && typeof value === strShimObject);
464
+ }
446
465
  function isFunction(value) {
447
466
  return !!(value && typeof value === strShimFunction);
448
467
  }
@@ -481,6 +500,25 @@
481
500
  function isError(obj) {
482
501
  return !!(obj && _objToString.call(obj) === "[object Error]");
483
502
  }
503
+ function isBoolean(value) {
504
+ return typeof value === "boolean";
505
+ }
506
+ function isPlainObject(value) {
507
+ var result = false;
508
+ if (value && typeof value === "object") {
509
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
510
+ if (!proto) {
511
+ result = true;
512
+ }
513
+ else {
514
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
515
+ proto = proto[strConstructor];
516
+ }
517
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
518
+ }
519
+ }
520
+ return result;
521
+ }
484
522
  function arrForEach(arr, callbackfn, thisArg) {
485
523
  var len = arr.length;
486
524
  try {
@@ -516,6 +554,10 @@
516
554
  }
517
555
  return false;
518
556
  }
557
+ function _doNothing(value) {
558
+ return value;
559
+ }
560
+ var objFreeze = _objFreeze || _doNothing;
519
561
  function dateNow() {
520
562
  var dt = Date;
521
563
  return dt.now ? dt.now() : new dt().getTime();
@@ -537,6 +579,50 @@
537
579
  }
538
580
  return theValue;
539
581
  }
582
+ function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
583
+ var theArgs = arguments;
584
+ var extended = theArgs[0] || {};
585
+ var argLen = theArgs.length;
586
+ var deep = false;
587
+ var idx = 1;
588
+ if (argLen > 0 && isBoolean(extended)) {
589
+ deep = extended;
590
+ extended = theArgs[idx] || {};
591
+ idx++;
592
+ }
593
+ if (!isObject(extended)) {
594
+ extended = {};
595
+ }
596
+ for (; idx < argLen; idx++) {
597
+ var arg = theArgs[idx];
598
+ var isArgArray = isArray(arg);
599
+ var isArgObj = isObject(arg);
600
+ for (var prop in arg) {
601
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
602
+ if (!propOk) {
603
+ continue;
604
+ }
605
+ var newValue = arg[prop];
606
+ var isNewArray = void 0;
607
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
608
+ var clone = extended[prop];
609
+ if (isNewArray) {
610
+ if (!isArray(clone)) {
611
+ clone = [];
612
+ }
613
+ }
614
+ else if (!isPlainObject(clone)) {
615
+ clone = {};
616
+ }
617
+ newValue = objExtend(deep, clone, newValue);
618
+ }
619
+ if (newValue !== undefined) {
620
+ extended[prop] = newValue;
621
+ }
622
+ }
623
+ }
624
+ return extended;
625
+ }
540
626
 
541
627
  var strWindow = "window";
542
628
  var strDocument = "document";
@@ -895,186 +981,240 @@
895
981
  return func();
896
982
  }
897
983
 
898
- var TelemetryPluginChain = /** @class */ (function () {
899
- function TelemetryPluginChain(plugin, defItemCtx) {
900
- var _self = this;
901
- var _nextProxy = null;
902
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
903
- var _hasSetNext = isFunction(plugin.setNextPlugin);
904
- _self._hasRun = false;
905
- _self.getPlugin = function () {
906
- return plugin;
907
- };
908
- _self.getNext = function () {
984
+ var strTelemetryPluginChain = "TelemetryPluginChain";
985
+ var strHasRunFlags = "_hasRun";
986
+ var strGetTelCtx = "_getTelCtx";
987
+ var _chainId = 0;
988
+ function _getNextProxyStart(proxy, config, core, startAt) {
989
+ while (proxy) {
990
+ if (proxy.getPlugin() === startAt) {
991
+ return proxy;
992
+ }
993
+ proxy = proxy.getNext();
994
+ }
995
+ return createTelemetryProxyChain([startAt], config, core);
996
+ }
997
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
998
+ var _nextProxy = null;
999
+ var _onComplete = null;
1000
+ if (startAt) {
1001
+ _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1002
+ }
1003
+ else {
1004
+ _nextProxy = telemetryChain;
1005
+ }
1006
+ var context = {
1007
+ core: function () {
1008
+ return core;
1009
+ },
1010
+ diagLog: function () {
1011
+ return safeGetLogger(core, config);
1012
+ },
1013
+ getCfg: function () {
1014
+ return config;
1015
+ },
1016
+ getExtCfg: _getExtCfg,
1017
+ getConfig: _getConfig,
1018
+ hasNext: function () {
1019
+ return _nextProxy != null;
1020
+ },
1021
+ getNext: function () {
909
1022
  return _nextProxy;
910
- };
911
- _self.setNext = function (nextPlugin) {
1023
+ },
1024
+ setNext: function (nextPlugin) {
912
1025
  _nextProxy = nextPlugin;
913
- };
914
- _self.processTelemetry = function (env, itemCtx) {
915
- if (!itemCtx) {
916
- itemCtx = defItemCtx;
917
- }
918
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
919
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
920
- if (plugin && _hasProcessTelemetry) {
921
- _self._hasRun = true;
922
- try {
923
- itemCtx.setNext(_nextProxy);
924
- if (_hasSetNext) {
925
- plugin.setNextPlugin(_nextProxy);
926
- }
927
- _nextProxy && (_nextProxy._hasRun = false);
928
- plugin.processTelemetry(env, itemCtx);
929
- }
930
- catch (error) {
931
- var hasRun = _nextProxy && _nextProxy._hasRun;
932
- if (!_nextProxy || !hasRun) {
933
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
934
- }
935
- if (_nextProxy && !hasRun) {
936
- _nextProxy.processTelemetry(env, itemCtx);
1026
+ },
1027
+ processNext: function (env) {
1028
+ _processChain(function (nextPlugin) {
1029
+ nextPlugin.processTelemetry(env, context);
1030
+ });
1031
+ },
1032
+ iterate: _iterateChain,
1033
+ createNew: function (plugins, startAt) {
1034
+ if (plugins === void 0) { plugins = null; }
1035
+ if (isArray(plugins)) {
1036
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1037
+ }
1038
+ return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1039
+ },
1040
+ onComplete: function (onComplete) {
1041
+ _onComplete = onComplete;
1042
+ }
1043
+ };
1044
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1045
+ if (defaultValue === void 0) { defaultValue = {}; }
1046
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1047
+ var theConfig;
1048
+ if (config) {
1049
+ var extConfig = config.extensionConfig;
1050
+ if (extConfig && identifier) {
1051
+ theConfig = extConfig[identifier];
1052
+ }
1053
+ }
1054
+ if (!theConfig) {
1055
+ theConfig = defaultValue;
1056
+ }
1057
+ else if (isObject(defaultValue)) {
1058
+ if (mergeDefault !== 0 ) {
1059
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1060
+ if (config && mergeDefault === 2 ) {
1061
+ objForEachKey(defaultValue, function (field) {
1062
+ if (isNullOrUndefined(newConfig_1[field])) {
1063
+ var cfgValue = config[field];
1064
+ if (!isNullOrUndefined(cfgValue)) {
1065
+ newConfig_1[field] = cfgValue;
1066
+ }
937
1067
  }
938
- }
1068
+ });
939
1069
  }
940
- else if (_nextProxy) {
941
- _self._hasRun = true;
942
- _nextProxy.processTelemetry(env, itemCtx);
943
- }
944
- }, function () { return ({ item: env }); }, !(env.sync));
945
- };
946
- }
947
- return TelemetryPluginChain;
948
- }());
949
-
950
- function _createProxyChain(plugins, itemCtx) {
951
- var proxies = [];
952
- if (plugins && plugins.length > 0) {
953
- var lastProxy = null;
954
- for (var idx = 0; idx < plugins.length; idx++) {
955
- var thePlugin = plugins[idx];
956
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
957
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
958
- proxies.push(newProxy);
959
- if (lastProxy) {
960
- lastProxy.setNext(newProxy);
961
- }
962
- lastProxy = newProxy;
963
1070
  }
964
1071
  }
1072
+ return theConfig;
965
1073
  }
966
- return proxies.length > 0 ? proxies[0] : null;
967
- }
968
- function _copyProxyChain(proxy, itemCtx, startAt) {
969
- var plugins = [];
970
- var add = startAt ? false : true;
971
- if (proxy) {
972
- while (proxy) {
973
- var thePlugin = proxy.getPlugin();
974
- if (add || thePlugin === startAt) {
975
- add = true;
976
- plugins.push(thePlugin);
1074
+ function _getConfig(identifier, field, defaultValue) {
1075
+ if (defaultValue === void 0) { defaultValue = false; }
1076
+ var theValue;
1077
+ var extConfig = _getExtCfg(identifier, null);
1078
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1079
+ theValue = extConfig[field];
1080
+ }
1081
+ else if (config && !isNullOrUndefined(config[field])) {
1082
+ theValue = config[field];
1083
+ }
1084
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1085
+ }
1086
+ function _processChain(cb) {
1087
+ var nextPlugin = _nextProxy;
1088
+ if (nextPlugin) {
1089
+ _nextProxy = nextPlugin.getNext();
1090
+ cb(nextPlugin);
1091
+ }
1092
+ else {
1093
+ if (_onComplete) {
1094
+ _onComplete();
1095
+ _onComplete = null;
977
1096
  }
978
- proxy = proxy.getNext();
979
1097
  }
980
1098
  }
981
- if (!add) {
982
- plugins.push(startAt);
1099
+ function _iterateChain(cb) {
1100
+ while (_nextProxy) {
1101
+ _processChain(function (nextPlugin) {
1102
+ var plugin = nextPlugin.getPlugin();
1103
+ if (plugin) {
1104
+ cb(plugin);
1105
+ }
1106
+ });
1107
+ }
983
1108
  }
984
- return _createProxyChain(plugins, itemCtx);
1109
+ return context;
985
1110
  }
986
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
987
- var plugins = srcPlugins;
988
- var add = false;
989
- if (startAt && srcPlugins) {
990
- plugins = [];
991
- arrForEach(srcPlugins, function (thePlugin) {
992
- if (add || thePlugin === startAt) {
1111
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1112
+ var firstProxy = null;
1113
+ var add = startAt ? false : true;
1114
+ if (isArray(plugins) && plugins.length > 0) {
1115
+ var lastProxy_1 = null;
1116
+ arrForEach(plugins, function (thePlugin) {
1117
+ if (!add && startAt === thePlugin) {
993
1118
  add = true;
994
- plugins.push(thePlugin);
1119
+ }
1120
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1121
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1122
+ if (!firstProxy) {
1123
+ firstProxy = newProxy;
1124
+ }
1125
+ if (lastProxy_1) {
1126
+ lastProxy_1._setNext(newProxy);
1127
+ }
1128
+ lastProxy_1 = newProxy;
995
1129
  }
996
1130
  });
997
1131
  }
998
- if (startAt && !add) {
999
- if (!plugins) {
1000
- plugins = [];
1001
- }
1002
- plugins.push(startAt);
1132
+ if (startAt && !firstProxy) {
1133
+ return createTelemetryProxyChain([startAt], config, core);
1003
1134
  }
1004
- return _createProxyChain(plugins, itemCtx);
1135
+ return firstProxy;
1005
1136
  }
1006
- var ProcessTelemetryContext = /** @class */ (function () {
1007
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1008
- var _self = this;
1009
- var _nextProxy = null;
1010
- if (startAt !== null) {
1011
- if (plugins && isFunction(plugins.getPlugin)) {
1012
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1137
+ function createTelemetryPluginProxy(plugin, config, core) {
1138
+ var nextProxy = null;
1139
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1140
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1141
+ var chainId;
1142
+ if (plugin) {
1143
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1144
+ }
1145
+ else {
1146
+ chainId = "Unknown-0-" + _chainId++;
1147
+ }
1148
+ var proxyChain = {
1149
+ getPlugin: function () {
1150
+ return plugin;
1151
+ },
1152
+ getNext: function () {
1153
+ return nextProxy;
1154
+ },
1155
+ processTelemetry: _processTelemetry,
1156
+ _id: chainId,
1157
+ _setNext: function (nextPlugin) {
1158
+ nextProxy = nextPlugin;
1159
+ }
1160
+ };
1161
+ function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1162
+ if (!itemCtx) {
1163
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1164
+ itemCtx = plugin[strGetTelCtx]();
1013
1165
  }
1014
- else {
1015
- if (startAt) {
1016
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1017
- }
1018
- else if (isUndefined(startAt)) {
1019
- _nextProxy = _createProxyChain(plugins, _self);
1020
- }
1166
+ if (!itemCtx) {
1167
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1021
1168
  }
1022
1169
  }
1023
- _self.core = function () {
1024
- return core;
1025
- };
1026
- _self.diagLog = function () {
1027
- return safeGetLogger(core, config);
1028
- };
1029
- _self.getCfg = function () {
1030
- return config;
1031
- };
1032
- _self.getExtCfg = function (identifier, defaultValue) {
1033
- if (defaultValue === void 0) { defaultValue = {}; }
1034
- var theConfig;
1035
- if (config) {
1036
- var extConfig = config.extensionConfig;
1037
- if (extConfig && identifier) {
1038
- theConfig = extConfig[identifier];
1170
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1171
+ var hasRunContext = itemCtx[strHasRunFlags];
1172
+ if (!hasRunContext) {
1173
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1174
+ }
1175
+ doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1176
+ hasRunContext[chainId] = true;
1177
+ var hasRun = false;
1178
+ itemCtx.setNext(nextProxy);
1179
+ if (plugin) {
1180
+ try {
1181
+ var nextId = nextProxy ? nextProxy._id : "";
1182
+ if (nextId) {
1183
+ hasRunContext[nextId] = false;
1184
+ }
1185
+ hasRun = processPluginFn(itemCtx);
1186
+ }
1187
+ catch (error) {
1188
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1189
+ if (hasNextRun) {
1190
+ hasRun = true;
1191
+ }
1192
+ if (!nextProxy || !hasNextRun) {
1193
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1194
+ }
1039
1195
  }
1040
1196
  }
1041
- return (theConfig ? theConfig : defaultValue);
1042
- };
1043
- _self.getConfig = function (identifier, field, defaultValue) {
1044
- if (defaultValue === void 0) { defaultValue = false; }
1045
- var theValue;
1046
- var extConfig = _self.getExtCfg(identifier, null);
1047
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1048
- theValue = extConfig[field];
1197
+ if (nextProxy && !hasRun) {
1198
+ processProxyFn(itemCtx);
1049
1199
  }
1050
- else if (config && !isNullOrUndefined(config[field])) {
1051
- theValue = config[field];
1200
+ }, details, isAsync);
1201
+ }
1202
+ function _processTelemetry(env, itemCtx) {
1203
+ _processChain(itemCtx, function (itemCtx) {
1204
+ if (!hasProcessTelemetry) {
1205
+ return false;
1052
1206
  }
1053
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1054
- };
1055
- _self.hasNext = function () {
1056
- return _nextProxy != null;
1057
- };
1058
- _self.getNext = function () {
1059
- return _nextProxy;
1060
- };
1061
- _self.setNext = function (nextPlugin) {
1062
- _nextProxy = nextPlugin;
1063
- };
1064
- _self.processNext = function (env) {
1065
- var nextPlugin = _nextProxy;
1066
- if (nextPlugin) {
1067
- _nextProxy = nextPlugin.getNext();
1068
- nextPlugin.processTelemetry(env, _self);
1207
+ if (hasSetNext) {
1208
+ plugin.setNextPlugin(nextProxy);
1069
1209
  }
1070
- };
1071
- _self.createNew = function (plugins, startAt) {
1072
- if (plugins === void 0) { plugins = null; }
1073
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1074
- };
1210
+ plugin.processTelemetry(env, itemCtx);
1211
+ return true;
1212
+ }, function (itemCtx) {
1213
+ nextProxy.processTelemetry(env, itemCtx);
1214
+ }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1075
1215
  }
1076
- return ProcessTelemetryContext;
1077
- }());
1216
+ return objFreeze(proxyChain);
1217
+ }
1078
1218
 
1079
1219
  var strExtensionConfig = "extensionConfig";
1080
1220
 
@@ -1082,12 +1222,29 @@
1082
1222
  var BaseTelemetryPlugin = /** @class */ (function () {
1083
1223
  function BaseTelemetryPlugin() {
1084
1224
  var _self = this;
1085
- var _isinitialized = false;
1086
- var _rootCtx = null;
1087
- var _nextPlugin = null;
1088
- _self.core = null;
1225
+ var _isinitialized;
1226
+ var _rootCtx;
1227
+ var _nextPlugin;
1228
+ var _hooks;
1229
+ _initDefaults();
1230
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1231
+ _self.initialize = function (config, core, extensions, pluginChain) {
1232
+ _setDefaults(config, core, pluginChain);
1233
+ _isinitialized = true;
1234
+ };
1235
+ _self._addHook = function (hooks) {
1236
+ if (hooks) {
1237
+ if (isArray(hooks)) {
1238
+ _hooks = _hooks.concat(hooks);
1239
+ }
1240
+ else {
1241
+ _hooks.push(hooks);
1242
+ }
1243
+ }
1244
+ };
1245
+ });
1089
1246
  _self.diagLog = function (itemCtx) {
1090
- return _self._getTelCtx(itemCtx).diagLog();
1247
+ return _getTelCtx(itemCtx).diagLog();
1091
1248
  };
1092
1249
  _self.isInitialized = function () {
1093
1250
  return _isinitialized;
@@ -1106,11 +1263,12 @@
1106
1263
  _nextPlugin.processTelemetry(env, null);
1107
1264
  }
1108
1265
  };
1109
- _self._getTelCtx = function (currentCtx) {
1266
+ _self._getTelCtx = _getTelCtx;
1267
+ function _getTelCtx(currentCtx) {
1110
1268
  if (currentCtx === void 0) { currentCtx = null; }
1111
1269
  var itemCtx = currentCtx;
1112
1270
  if (!itemCtx) {
1113
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1271
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1114
1272
  if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1115
1273
  itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1116
1274
  }
@@ -1119,8 +1277,8 @@
1119
1277
  }
1120
1278
  }
1121
1279
  return itemCtx;
1122
- };
1123
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1280
+ }
1281
+ function _setDefaults(config, core, pluginChain) {
1124
1282
  if (config) {
1125
1283
  setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1126
1284
  }
@@ -1132,13 +1290,16 @@
1132
1290
  nextPlugin = _nextPlugin[strGetPlugin]();
1133
1291
  }
1134
1292
  _self.core = core;
1135
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1136
- _isinitialized = true;
1137
- };
1293
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1294
+ }
1295
+ function _initDefaults() {
1296
+ _isinitialized = false;
1297
+ _self.core = null;
1298
+ _rootCtx = null;
1299
+ _nextPlugin = null;
1300
+ _hooks = [];
1301
+ }
1138
1302
  }
1139
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1140
- this._baseTelInit(config, core, extensions, pluginChain);
1141
- };
1142
1303
  return BaseTelemetryPlugin;
1143
1304
  }());
1144
1305
 
@@ -1997,7 +2158,7 @@
1997
2158
  this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
1998
2159
  }
1999
2160
  };
2000
- ClickAnalyticsPlugin.Version = "2.7.4-nightly.2202-09";
2161
+ ClickAnalyticsPlugin.Version = "2.8.0-beta.2202-07";
2001
2162
  return ClickAnalyticsPlugin;
2002
2163
  }(BaseTelemetryPlugin));
2003
2164