@microsoft/applicationinsights-properties-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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript SDK - Properties Plugin, 2.7.4-nightly.2202-09
2
+ * Application Insights JavaScript SDK - Properties Plugin, 2.8.0-beta.2202-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -96,11 +96,11 @@
96
96
  var DynAllowInstChkTag = DynInstChkTag;
97
97
  var DynProtoDefaultOptions = '_dfOpts';
98
98
  var UnknownValue = '_unknown_';
99
- var str__Proto = "__proto__";
99
+ var str__Proto$1 = "__proto__";
100
100
  var strUseBaseInst = 'useBaseInst';
101
101
  var strSetInstFuncs = 'setInstFuncs';
102
102
  var Obj = Object;
103
- var _objGetPrototypeOf = Obj["getPrototypeOf"];
103
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
104
104
  var _dynamicNames = 0;
105
105
  function _hasOwnProperty(obj, prop) {
106
106
  return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
@@ -111,12 +111,12 @@
111
111
  function _isObjectArrayOrFunctionPrototype(target) {
112
112
  return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
113
113
  }
114
- function _getObjProto(target) {
114
+ function _getObjProto$1(target) {
115
115
  if (target) {
116
- if (_objGetPrototypeOf) {
117
- return _objGetPrototypeOf(target);
116
+ if (_objGetPrototypeOf$1) {
117
+ return _objGetPrototypeOf$1(target);
118
118
  }
119
- var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
119
+ var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
120
120
  if (newProto) {
121
121
  return newProto;
122
122
  }
@@ -182,16 +182,16 @@
182
182
  _forEachProp(instFuncs, function (name) {
183
183
  baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
184
184
  });
185
- var baseProto = _getObjProto(classProto);
185
+ var baseProto = _getObjProto$1(classProto);
186
186
  var visited = [];
187
187
  while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
188
188
  _forEachProp(baseProto, function (name) {
189
- if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
189
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
190
190
  baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
191
191
  }
192
192
  });
193
193
  visited.push(baseProto);
194
- baseProto = _getObjProto(baseProto);
194
+ baseProto = _getObjProto$1(baseProto);
195
195
  }
196
196
  return baseFuncs;
197
197
  }
@@ -205,7 +205,7 @@
205
205
  }
206
206
  if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
207
207
  var canAddInst = !_hasOwnProperty(target, funcName);
208
- var objProto = _getObjProto(target);
208
+ var objProto = _getObjProto$1(target);
209
209
  var visited = [];
210
210
  while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
211
211
  var protoFunc = objProto[funcName];
@@ -214,7 +214,7 @@
214
214
  break;
215
215
  }
216
216
  visited.push(objProto);
217
- objProto = _getObjProto(objProto);
217
+ objProto = _getObjProto$1(objProto);
218
218
  }
219
219
  try {
220
220
  if (canAddInst) {
@@ -232,7 +232,7 @@
232
232
  function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
233
233
  var protoFunc = proto[funcName];
234
234
  if (protoFunc === currentDynProtoProxy) {
235
- protoFunc = _getObjProto(proto)[funcName];
235
+ protoFunc = _getObjProto$1(proto)[funcName];
236
236
  }
237
237
  if (typeof protoFunc !== strFunction) {
238
238
  _throwTypeError("[" + funcName + "] is not a " + strFunction);
@@ -266,15 +266,15 @@
266
266
  }
267
267
  }
268
268
  function _checkPrototype(classProto, thisTarget) {
269
- if (_objGetPrototypeOf) {
269
+ if (_objGetPrototypeOf$1) {
270
270
  var visited = [];
271
- var thisProto = _getObjProto(thisTarget);
271
+ var thisProto = _getObjProto$1(thisTarget);
272
272
  while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
273
273
  if (thisProto === classProto) {
274
274
  return true;
275
275
  }
276
276
  visited.push(thisProto);
277
- thisProto = _getObjProto(thisProto);
277
+ thisProto = _getObjProto$1(thisProto);
278
278
  }
279
279
  }
280
280
  return false;
@@ -310,7 +310,7 @@
310
310
  var instFuncs = _getInstanceFuncs(target);
311
311
  var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
312
312
  delegateFunc(target, baseFuncs);
313
- var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
313
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
314
314
  if (setInstanceFunc && options) {
315
315
  setInstanceFunc = !!options[strSetInstFuncs];
316
316
  }
@@ -416,7 +416,10 @@
416
416
  var cStrEndsWith = "endsWith";
417
417
  var cStrTrim = "trim";
418
418
  var strToString = "toString";
419
+ var str__Proto = "__proto__";
420
+ var strConstructor = "constructor";
419
421
  var _objDefineProperty = ObjDefineProperty;
422
+ var _objFreeze = ObjClass.freeze;
420
423
  var _objKeys = ObjClass.keys;
421
424
  var StringProto = String[strShimPrototype];
422
425
  var _strTrim = StringProto[cStrTrim];
@@ -426,7 +429,20 @@
426
429
  var _isArray = Array.isArray;
427
430
  var _objToString = ObjProto[strToString];
428
431
  var _fnToString = ObjHasOwnProperty[strToString];
429
- _fnToString.call(ObjClass);
432
+ var _objFunctionString = _fnToString.call(ObjClass);
433
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
434
+ function _getObjProto(target) {
435
+ if (target) {
436
+ if (_objGetPrototypeOf) {
437
+ return _objGetPrototypeOf(target);
438
+ }
439
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
440
+ if (newProto) {
441
+ return newProto;
442
+ }
443
+ }
444
+ return null;
445
+ }
430
446
  function isUndefined(value) {
431
447
  return value === undefined || typeof value === strShimUndefined;
432
448
  }
@@ -490,6 +506,25 @@
490
506
  function isString(value) {
491
507
  return typeof value === "string";
492
508
  }
509
+ function isBoolean(value) {
510
+ return typeof value === "boolean";
511
+ }
512
+ function isPlainObject(value) {
513
+ var result = false;
514
+ if (value && typeof value === "object") {
515
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
516
+ if (!proto) {
517
+ result = true;
518
+ }
519
+ else {
520
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
521
+ proto = proto[strConstructor];
522
+ }
523
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
524
+ }
525
+ }
526
+ return result;
527
+ }
493
528
  function toISOString(date) {
494
529
  if (date) {
495
530
  return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
@@ -589,6 +624,10 @@
589
624
  }
590
625
  return false;
591
626
  }
627
+ function _doNothing(value) {
628
+ return value;
629
+ }
630
+ var objFreeze = _objFreeze || _doNothing;
592
631
  function dateNow() {
593
632
  var dt = Date;
594
633
  return dt.now ? dt.now() : new dt().getTime();
@@ -640,6 +679,50 @@
640
679
  return class_1;
641
680
  }());
642
681
  }
682
+ function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
683
+ var theArgs = arguments;
684
+ var extended = theArgs[0] || {};
685
+ var argLen = theArgs.length;
686
+ var deep = false;
687
+ var idx = 1;
688
+ if (argLen > 0 && isBoolean(extended)) {
689
+ deep = extended;
690
+ extended = theArgs[idx] || {};
691
+ idx++;
692
+ }
693
+ if (!isObject(extended)) {
694
+ extended = {};
695
+ }
696
+ for (; idx < argLen; idx++) {
697
+ var arg = theArgs[idx];
698
+ var isArgArray = isArray(arg);
699
+ var isArgObj = isObject(arg);
700
+ for (var prop in arg) {
701
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
702
+ if (!propOk) {
703
+ continue;
704
+ }
705
+ var newValue = arg[prop];
706
+ var isNewArray = void 0;
707
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
708
+ var clone = extended[prop];
709
+ if (isNewArray) {
710
+ if (!isArray(clone)) {
711
+ clone = [];
712
+ }
713
+ }
714
+ else if (!isPlainObject(clone)) {
715
+ clone = {};
716
+ }
717
+ newValue = objExtend(deep, clone, newValue);
718
+ }
719
+ if (newValue !== undefined) {
720
+ extended[prop] = newValue;
721
+ }
722
+ }
723
+ }
724
+ return extended;
725
+ }
643
726
 
644
727
  var strWindow = "window";
645
728
  var strDocument = "document";
@@ -1019,252 +1102,240 @@
1019
1102
  return func();
1020
1103
  }
1021
1104
 
1022
- var TelemetryPluginChain = /** @class */ (function () {
1023
- function TelemetryPluginChain(plugin, defItemCtx) {
1024
- var _self = this;
1025
- var _nextProxy = null;
1026
- var _hasProcessTelemetry = isFunction(plugin.processTelemetry);
1027
- var _hasSetNext = isFunction(plugin.setNextPlugin);
1028
- _self._hasRun = false;
1029
- _self.getPlugin = function () {
1030
- return plugin;
1031
- };
1032
- _self.getNext = function () {
1105
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1106
+ var strHasRunFlags = "_hasRun";
1107
+ var strGetTelCtx = "_getTelCtx";
1108
+ var _chainId = 0;
1109
+ function _getNextProxyStart(proxy, config, core, startAt) {
1110
+ while (proxy) {
1111
+ if (proxy.getPlugin() === startAt) {
1112
+ return proxy;
1113
+ }
1114
+ proxy = proxy.getNext();
1115
+ }
1116
+ return createTelemetryProxyChain([startAt], config, core);
1117
+ }
1118
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1119
+ var _nextProxy = null;
1120
+ var _onComplete = null;
1121
+ if (startAt) {
1122
+ _nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
1123
+ }
1124
+ else {
1125
+ _nextProxy = telemetryChain;
1126
+ }
1127
+ var context = {
1128
+ core: function () {
1129
+ return core;
1130
+ },
1131
+ diagLog: function () {
1132
+ return safeGetLogger(core, config);
1133
+ },
1134
+ getCfg: function () {
1135
+ return config;
1136
+ },
1137
+ getExtCfg: _getExtCfg,
1138
+ getConfig: _getConfig,
1139
+ hasNext: function () {
1140
+ return _nextProxy != null;
1141
+ },
1142
+ getNext: function () {
1033
1143
  return _nextProxy;
1034
- };
1035
- _self.setNext = function (nextPlugin) {
1144
+ },
1145
+ setNext: function (nextPlugin) {
1036
1146
  _nextProxy = nextPlugin;
1037
- };
1038
- _self.processTelemetry = function (env, itemCtx) {
1039
- if (!itemCtx) {
1040
- itemCtx = defItemCtx;
1147
+ },
1148
+ processNext: function (env) {
1149
+ _processChain(function (nextPlugin) {
1150
+ nextPlugin.processTelemetry(env, context);
1151
+ });
1152
+ },
1153
+ iterate: _iterateChain,
1154
+ createNew: function (plugins, startAt) {
1155
+ if (plugins === void 0) { plugins = null; }
1156
+ if (isArray(plugins)) {
1157
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1041
1158
  }
1042
- var identifier = plugin ? plugin.identifier : "TelemetryPluginChain";
1043
- doPerf(itemCtx ? itemCtx.core() : null, function () { return identifier + ":processTelemetry"; }, function () {
1044
- if (plugin && _hasProcessTelemetry) {
1045
- _self._hasRun = true;
1046
- try {
1047
- itemCtx.setNext(_nextProxy);
1048
- if (_hasSetNext) {
1049
- plugin.setNextPlugin(_nextProxy);
1050
- }
1051
- _nextProxy && (_nextProxy._hasRun = false);
1052
- plugin.processTelemetry(env, itemCtx);
1053
- }
1054
- catch (error) {
1055
- var hasRun = _nextProxy && _nextProxy._hasRun;
1056
- if (!_nextProxy || !hasRun) {
1057
- itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
1058
- }
1059
- if (_nextProxy && !hasRun) {
1060
- _nextProxy.processTelemetry(env, itemCtx);
1159
+ return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1160
+ },
1161
+ onComplete: function (onComplete) {
1162
+ _onComplete = onComplete;
1163
+ }
1164
+ };
1165
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1166
+ if (defaultValue === void 0) { defaultValue = {}; }
1167
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1168
+ var theConfig;
1169
+ if (config) {
1170
+ var extConfig = config.extensionConfig;
1171
+ if (extConfig && identifier) {
1172
+ theConfig = extConfig[identifier];
1173
+ }
1174
+ }
1175
+ if (!theConfig) {
1176
+ theConfig = defaultValue;
1177
+ }
1178
+ else if (isObject(defaultValue)) {
1179
+ if (mergeDefault !== 0 ) {
1180
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1181
+ if (config && mergeDefault === 2 ) {
1182
+ objForEachKey(defaultValue, function (field) {
1183
+ if (isNullOrUndefined(newConfig_1[field])) {
1184
+ var cfgValue = config[field];
1185
+ if (!isNullOrUndefined(cfgValue)) {
1186
+ newConfig_1[field] = cfgValue;
1187
+ }
1061
1188
  }
1062
- }
1063
- }
1064
- else if (_nextProxy) {
1065
- _self._hasRun = true;
1066
- _nextProxy.processTelemetry(env, itemCtx);
1067
- }
1068
- }, function () { return ({ item: env }); }, !(env.sync));
1069
- };
1070
- }
1071
- return TelemetryPluginChain;
1072
- }());
1073
-
1074
- function _createProxyChain(plugins, itemCtx) {
1075
- var proxies = [];
1076
- if (plugins && plugins.length > 0) {
1077
- var lastProxy = null;
1078
- for (var idx = 0; idx < plugins.length; idx++) {
1079
- var thePlugin = plugins[idx];
1080
- if (thePlugin && isFunction(thePlugin.processTelemetry)) {
1081
- var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
1082
- proxies.push(newProxy);
1083
- if (lastProxy) {
1084
- lastProxy.setNext(newProxy);
1189
+ });
1085
1190
  }
1086
- lastProxy = newProxy;
1087
1191
  }
1088
1192
  }
1193
+ return theConfig;
1194
+ }
1195
+ function _getConfig(identifier, field, defaultValue) {
1196
+ if (defaultValue === void 0) { defaultValue = false; }
1197
+ var theValue;
1198
+ var extConfig = _getExtCfg(identifier, null);
1199
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1200
+ theValue = extConfig[field];
1201
+ }
1202
+ else if (config && !isNullOrUndefined(config[field])) {
1203
+ theValue = config[field];
1204
+ }
1205
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1089
1206
  }
1090
- return proxies.length > 0 ? proxies[0] : null;
1091
- }
1092
- function _copyProxyChain(proxy, itemCtx, startAt) {
1093
- var plugins = [];
1094
- var add = startAt ? false : true;
1095
- if (proxy) {
1096
- while (proxy) {
1097
- var thePlugin = proxy.getPlugin();
1098
- if (add || thePlugin === startAt) {
1099
- add = true;
1100
- plugins.push(thePlugin);
1207
+ function _processChain(cb) {
1208
+ var nextPlugin = _nextProxy;
1209
+ if (nextPlugin) {
1210
+ _nextProxy = nextPlugin.getNext();
1211
+ cb(nextPlugin);
1212
+ }
1213
+ else {
1214
+ if (_onComplete) {
1215
+ _onComplete();
1216
+ _onComplete = null;
1101
1217
  }
1102
- proxy = proxy.getNext();
1103
1218
  }
1104
1219
  }
1105
- if (!add) {
1106
- plugins.push(startAt);
1220
+ function _iterateChain(cb) {
1221
+ while (_nextProxy) {
1222
+ _processChain(function (nextPlugin) {
1223
+ var plugin = nextPlugin.getPlugin();
1224
+ if (plugin) {
1225
+ cb(plugin);
1226
+ }
1227
+ });
1228
+ }
1107
1229
  }
1108
- return _createProxyChain(plugins, itemCtx);
1230
+ return context;
1109
1231
  }
1110
- function _copyPluginChain(srcPlugins, itemCtx, startAt) {
1111
- var plugins = srcPlugins;
1112
- var add = false;
1113
- if (startAt && srcPlugins) {
1114
- plugins = [];
1115
- arrForEach(srcPlugins, function (thePlugin) {
1116
- if (add || thePlugin === startAt) {
1232
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1233
+ var firstProxy = null;
1234
+ var add = startAt ? false : true;
1235
+ if (isArray(plugins) && plugins.length > 0) {
1236
+ var lastProxy_1 = null;
1237
+ arrForEach(plugins, function (thePlugin) {
1238
+ if (!add && startAt === thePlugin) {
1117
1239
  add = true;
1118
- plugins.push(thePlugin);
1240
+ }
1241
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1242
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1243
+ if (!firstProxy) {
1244
+ firstProxy = newProxy;
1245
+ }
1246
+ if (lastProxy_1) {
1247
+ lastProxy_1._setNext(newProxy);
1248
+ }
1249
+ lastProxy_1 = newProxy;
1119
1250
  }
1120
1251
  });
1121
1252
  }
1122
- if (startAt && !add) {
1123
- if (!plugins) {
1124
- plugins = [];
1125
- }
1126
- plugins.push(startAt);
1253
+ if (startAt && !firstProxy) {
1254
+ return createTelemetryProxyChain([startAt], config, core);
1127
1255
  }
1128
- return _createProxyChain(plugins, itemCtx);
1256
+ return firstProxy;
1129
1257
  }
1130
- var ProcessTelemetryContext = /** @class */ (function () {
1131
- function ProcessTelemetryContext(plugins, config, core, startAt) {
1132
- var _self = this;
1133
- var _nextProxy = null;
1134
- if (startAt !== null) {
1135
- if (plugins && isFunction(plugins.getPlugin)) {
1136
- _nextProxy = _copyProxyChain(plugins, _self, startAt || plugins.getPlugin());
1137
- }
1138
- else {
1139
- if (startAt) {
1140
- _nextProxy = _copyPluginChain(plugins, _self, startAt);
1141
- }
1142
- else if (isUndefined(startAt)) {
1143
- _nextProxy = _createProxyChain(plugins, _self);
1144
- }
1145
- }
1146
- }
1147
- _self.core = function () {
1148
- return core;
1149
- };
1150
- _self.diagLog = function () {
1151
- return safeGetLogger(core, config);
1152
- };
1153
- _self.getCfg = function () {
1154
- return config;
1155
- };
1156
- _self.getExtCfg = function (identifier, defaultValue) {
1157
- if (defaultValue === void 0) { defaultValue = {}; }
1158
- var theConfig;
1159
- if (config) {
1160
- var extConfig = config.extensionConfig;
1161
- if (extConfig && identifier) {
1162
- theConfig = extConfig[identifier];
1163
- }
1164
- }
1165
- return (theConfig ? theConfig : defaultValue);
1166
- };
1167
- _self.getConfig = function (identifier, field, defaultValue) {
1168
- if (defaultValue === void 0) { defaultValue = false; }
1169
- var theValue;
1170
- var extConfig = _self.getExtCfg(identifier, null);
1171
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
1172
- theValue = extConfig[field];
1173
- }
1174
- else if (config && !isNullOrUndefined(config[field])) {
1175
- theValue = config[field];
1176
- }
1177
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1178
- };
1179
- _self.hasNext = function () {
1180
- return _nextProxy != null;
1181
- };
1182
- _self.getNext = function () {
1183
- return _nextProxy;
1184
- };
1185
- _self.setNext = function (nextPlugin) {
1186
- _nextProxy = nextPlugin;
1187
- };
1188
- _self.processNext = function (env) {
1189
- var nextPlugin = _nextProxy;
1190
- if (nextPlugin) {
1191
- _nextProxy = nextPlugin.getNext();
1192
- nextPlugin.processTelemetry(env, _self);
1193
- }
1194
- };
1195
- _self.createNew = function (plugins, startAt) {
1196
- if (plugins === void 0) { plugins = null; }
1197
- return new ProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
1198
- };
1258
+ function createTelemetryPluginProxy(plugin, config, core) {
1259
+ var nextProxy = null;
1260
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1261
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1262
+ var chainId;
1263
+ if (plugin) {
1264
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1199
1265
  }
1200
- return ProcessTelemetryContext;
1201
- }());
1202
-
1203
- var strExtensionConfig = "extensionConfig";
1204
-
1205
- var strGetPlugin = "getPlugin";
1206
- var BaseTelemetryPlugin = /** @class */ (function () {
1207
- function BaseTelemetryPlugin() {
1208
- var _self = this;
1209
- var _isinitialized = false;
1210
- var _rootCtx = null;
1211
- var _nextPlugin = null;
1212
- _self.core = null;
1213
- _self.diagLog = function (itemCtx) {
1214
- return _self._getTelCtx(itemCtx).diagLog();
1215
- };
1216
- _self.isInitialized = function () {
1217
- return _isinitialized;
1218
- };
1219
- _self.setInitialized = function (isInitialized) {
1220
- _isinitialized = isInitialized;
1221
- };
1222
- _self.setNextPlugin = function (next) {
1223
- _nextPlugin = next;
1224
- };
1225
- _self.processNext = function (env, itemCtx) {
1226
- if (itemCtx) {
1227
- itemCtx.processNext(env);
1228
- }
1229
- else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1230
- _nextPlugin.processTelemetry(env, null);
1266
+ else {
1267
+ chainId = "Unknown-0-" + _chainId++;
1268
+ }
1269
+ var proxyChain = {
1270
+ getPlugin: function () {
1271
+ return plugin;
1272
+ },
1273
+ getNext: function () {
1274
+ return nextProxy;
1275
+ },
1276
+ processTelemetry: _processTelemetry,
1277
+ _id: chainId,
1278
+ _setNext: function (nextPlugin) {
1279
+ nextProxy = nextPlugin;
1280
+ }
1281
+ };
1282
+ function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
1283
+ if (!itemCtx) {
1284
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1285
+ itemCtx = plugin[strGetTelCtx]();
1231
1286
  }
1232
- };
1233
- _self._getTelCtx = function (currentCtx) {
1234
- if (currentCtx === void 0) { currentCtx = null; }
1235
- var itemCtx = currentCtx;
1236
1287
  if (!itemCtx) {
1237
- var rootCtx = _rootCtx || new ProcessTelemetryContext(null, {}, _self.core);
1238
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1239
- itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1288
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1289
+ }
1290
+ }
1291
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1292
+ var hasRunContext = itemCtx[strHasRunFlags];
1293
+ if (!hasRunContext) {
1294
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1295
+ }
1296
+ doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
1297
+ hasRunContext[chainId] = true;
1298
+ var hasRun = false;
1299
+ itemCtx.setNext(nextProxy);
1300
+ if (plugin) {
1301
+ try {
1302
+ var nextId = nextProxy ? nextProxy._id : "";
1303
+ if (nextId) {
1304
+ hasRunContext[nextId] = false;
1305
+ }
1306
+ hasRun = processPluginFn(itemCtx);
1240
1307
  }
1241
- else {
1242
- itemCtx = rootCtx.createNew(null, _nextPlugin);
1308
+ catch (error) {
1309
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1310
+ if (hasNextRun) {
1311
+ hasRun = true;
1312
+ }
1313
+ if (!nextProxy || !hasNextRun) {
1314
+ itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1315
+ }
1243
1316
  }
1244
1317
  }
1245
- return itemCtx;
1246
- };
1247
- _self._baseTelInit = function (config, core, extensions, pluginChain) {
1248
- if (config) {
1249
- setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1318
+ if (nextProxy && !hasRun) {
1319
+ processProxyFn(itemCtx);
1250
1320
  }
1251
- if (!pluginChain && core) {
1252
- pluginChain = core.getProcessTelContext().getNext();
1321
+ }, details, isAsync);
1322
+ }
1323
+ function _processTelemetry(env, itemCtx) {
1324
+ _processChain(itemCtx, function (itemCtx) {
1325
+ if (!hasProcessTelemetry) {
1326
+ return false;
1253
1327
  }
1254
- var nextPlugin = _nextPlugin;
1255
- if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1256
- nextPlugin = _nextPlugin[strGetPlugin]();
1328
+ if (hasSetNext) {
1329
+ plugin.setNextPlugin(nextProxy);
1257
1330
  }
1258
- _self.core = core;
1259
- _rootCtx = new ProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1260
- _isinitialized = true;
1261
- };
1331
+ plugin.processTelemetry(env, itemCtx);
1332
+ return true;
1333
+ }, function (itemCtx) {
1334
+ nextProxy.processTelemetry(env, itemCtx);
1335
+ }, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
1262
1336
  }
1263
- BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
1264
- this._baseTelInit(config, core, extensions, pluginChain);
1265
- };
1266
- return BaseTelemetryPlugin;
1267
- }());
1337
+ return objFreeze(proxyChain);
1338
+ }
1268
1339
 
1269
1340
  var strToGMTString = "toGMTString";
1270
1341
  var strToUTCString = "toUTCString";
@@ -1512,6 +1583,93 @@
1512
1583
  return false;
1513
1584
  }
1514
1585
 
1586
+ var strExtensionConfig = "extensionConfig";
1587
+
1588
+ var strGetPlugin = "getPlugin";
1589
+ var BaseTelemetryPlugin = /** @class */ (function () {
1590
+ function BaseTelemetryPlugin() {
1591
+ var _self = this;
1592
+ var _isinitialized;
1593
+ var _rootCtx;
1594
+ var _nextPlugin;
1595
+ var _hooks;
1596
+ _initDefaults();
1597
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1598
+ _self.initialize = function (config, core, extensions, pluginChain) {
1599
+ _setDefaults(config, core, pluginChain);
1600
+ _isinitialized = true;
1601
+ };
1602
+ _self._addHook = function (hooks) {
1603
+ if (hooks) {
1604
+ if (isArray(hooks)) {
1605
+ _hooks = _hooks.concat(hooks);
1606
+ }
1607
+ else {
1608
+ _hooks.push(hooks);
1609
+ }
1610
+ }
1611
+ };
1612
+ });
1613
+ _self.diagLog = function (itemCtx) {
1614
+ return _getTelCtx(itemCtx).diagLog();
1615
+ };
1616
+ _self.isInitialized = function () {
1617
+ return _isinitialized;
1618
+ };
1619
+ _self.setInitialized = function (isInitialized) {
1620
+ _isinitialized = isInitialized;
1621
+ };
1622
+ _self.setNextPlugin = function (next) {
1623
+ _nextPlugin = next;
1624
+ };
1625
+ _self.processNext = function (env, itemCtx) {
1626
+ if (itemCtx) {
1627
+ itemCtx.processNext(env);
1628
+ }
1629
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1630
+ _nextPlugin.processTelemetry(env, null);
1631
+ }
1632
+ };
1633
+ _self._getTelCtx = _getTelCtx;
1634
+ function _getTelCtx(currentCtx) {
1635
+ if (currentCtx === void 0) { currentCtx = null; }
1636
+ var itemCtx = currentCtx;
1637
+ if (!itemCtx) {
1638
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1639
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1640
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1641
+ }
1642
+ else {
1643
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1644
+ }
1645
+ }
1646
+ return itemCtx;
1647
+ }
1648
+ function _setDefaults(config, core, pluginChain) {
1649
+ if (config) {
1650
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1651
+ }
1652
+ if (!pluginChain && core) {
1653
+ pluginChain = core.getProcessTelContext().getNext();
1654
+ }
1655
+ var nextPlugin = _nextPlugin;
1656
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1657
+ nextPlugin = _nextPlugin[strGetPlugin]();
1658
+ }
1659
+ _self.core = core;
1660
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1661
+ }
1662
+ function _initDefaults() {
1663
+ _isinitialized = false;
1664
+ _self.core = null;
1665
+ _rootCtx = null;
1666
+ _nextPlugin = null;
1667
+ _hooks = [];
1668
+ }
1669
+ }
1670
+ return BaseTelemetryPlugin;
1671
+ }());
1672
+
1515
1673
  var UInt32Mask = 0x100000000;
1516
1674
  var MaxUInt32 = 0xffffffff;
1517
1675
  var _mwcSeeded = false;
@@ -1534,18 +1692,18 @@
1534
1692
  }
1535
1693
  }
1536
1694
  function random32(signed) {
1537
- var value;
1695
+ var value = 0;
1538
1696
  var c = getCrypto() || getMsCrypto();
1539
1697
  if (c && c.getRandomValues) {
1540
1698
  value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1541
1699
  }
1542
- else if (isIE()) {
1700
+ if (value === 0 && isIE()) {
1543
1701
  if (!_mwcSeeded) {
1544
1702
  _autoSeedMwc();
1545
1703
  }
1546
1704
  value = mwcRandom32() & MaxUInt32;
1547
1705
  }
1548
- else {
1706
+ if (value === 0) {
1549
1707
  value = Math.floor((UInt32Mask * Math.random()) | 0);
1550
1708
  }
1551
1709
  if (!signed) {
@@ -1562,7 +1720,6 @@
1562
1720
  }
1563
1721
  return value;
1564
1722
  }
1565
-
1566
1723
  function newId(maxLength) {
1567
1724
  if (maxLength === void 0) { maxLength = 22; }
1568
1725
  var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -1580,6 +1737,7 @@
1580
1737
  }
1581
1738
  return result;
1582
1739
  }
1740
+
1583
1741
  function generateW3CId() {
1584
1742
  var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
1585
1743
  var oct = "", tmp;
@@ -2100,7 +2258,7 @@
2100
2258
  return Device;
2101
2259
  }());
2102
2260
 
2103
- var Version = "2.7.4-nightly.2202-09";
2261
+ var Version = "2.8.0-beta.2202-07";
2104
2262
  var Internal = /** @class */ (function () {
2105
2263
  function Internal(config) {
2106
2264
  this.sdkVersion = (config.sdkExtension && config.sdkExtension() ? config.sdkExtension() + "_" : "") + "javascript:" + Version;