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

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