@microsoft/applicationinsights-react-native 2.4.4-nightly.2202-09 → 2.5.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.
- package/browser/applicationinsights-react-native.js +352 -185
- package/browser/applicationinsights-react-native.js.map +1 -1
- package/browser/applicationinsights-react-native.min.js +2 -2
- package/browser/applicationinsights-react-native.min.js.map +1 -1
- package/dist/applicationinsights-react-native.d.ts +1 -1
- package/dist/applicationinsights-react-native.js +352 -185
- package/dist/applicationinsights-react-native.js.map +1 -1
- package/dist/applicationinsights-react-native.min.js +2 -2
- package/dist/applicationinsights-react-native.min.js.map +1 -1
- package/dist/applicationinsights-react-native.rollup.d.ts +1 -1
- package/dist-esm/Interfaces/INativeDevice.js +1 -1
- package/dist-esm/Interfaces/IReactNativePluginConfig.js +1 -1
- package/dist-esm/Interfaces/index.js +1 -1
- package/dist-esm/ReactNativePlugin.js +1 -1
- package/dist-esm/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript SDK - React Native Plugin, 2.
|
|
2
|
+
* Application Insights JavaScript SDK - React Native Plugin, 2.5.0-beta.2202-06
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
var DynAllowInstChkTag = DynInstChkTag;
|
|
101
101
|
var DynProtoDefaultOptions = '_dfOpts';
|
|
102
102
|
var UnknownValue = '_unknown_';
|
|
103
|
-
var str__Proto = "__proto__";
|
|
103
|
+
var str__Proto$1 = "__proto__";
|
|
104
104
|
var strUseBaseInst = 'useBaseInst';
|
|
105
105
|
var strSetInstFuncs = 'setInstFuncs';
|
|
106
106
|
var Obj = Object;
|
|
107
|
-
var _objGetPrototypeOf = Obj["getPrototypeOf"];
|
|
107
|
+
var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
|
|
108
108
|
var _dynamicNames = 0;
|
|
109
109
|
function _hasOwnProperty(obj, prop) {
|
|
110
110
|
return obj && Obj[Prototype].hasOwnProperty.call(obj, prop);
|
|
@@ -115,12 +115,12 @@
|
|
|
115
115
|
function _isObjectArrayOrFunctionPrototype(target) {
|
|
116
116
|
return _isObjectOrArrayPrototype(target) || target === Function[Prototype];
|
|
117
117
|
}
|
|
118
|
-
function _getObjProto(target) {
|
|
118
|
+
function _getObjProto$1(target) {
|
|
119
119
|
if (target) {
|
|
120
|
-
if (_objGetPrototypeOf) {
|
|
121
|
-
return _objGetPrototypeOf(target);
|
|
120
|
+
if (_objGetPrototypeOf$1) {
|
|
121
|
+
return _objGetPrototypeOf$1(target);
|
|
122
122
|
}
|
|
123
|
-
var newProto = target[str__Proto] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
|
|
123
|
+
var newProto = target[str__Proto$1] || target[Prototype] || (target[Constructor] ? target[Constructor][Prototype] : null);
|
|
124
124
|
if (newProto) {
|
|
125
125
|
return newProto;
|
|
126
126
|
}
|
|
@@ -186,16 +186,16 @@
|
|
|
186
186
|
_forEachProp(instFuncs, function (name) {
|
|
187
187
|
baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
|
|
188
188
|
});
|
|
189
|
-
var baseProto = _getObjProto(classProto);
|
|
189
|
+
var baseProto = _getObjProto$1(classProto);
|
|
190
190
|
var visited = [];
|
|
191
191
|
while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
|
|
192
192
|
_forEachProp(baseProto, function (name) {
|
|
193
|
-
if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf)) {
|
|
193
|
+
if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
|
|
194
194
|
baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
visited.push(baseProto);
|
|
198
|
-
baseProto = _getObjProto(baseProto);
|
|
198
|
+
baseProto = _getObjProto$1(baseProto);
|
|
199
199
|
}
|
|
200
200
|
return baseFuncs;
|
|
201
201
|
}
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
}
|
|
210
210
|
if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
|
|
211
211
|
var canAddInst = !_hasOwnProperty(target, funcName);
|
|
212
|
-
var objProto = _getObjProto(target);
|
|
212
|
+
var objProto = _getObjProto$1(target);
|
|
213
213
|
var visited = [];
|
|
214
214
|
while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
|
|
215
215
|
var protoFunc = objProto[funcName];
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
break;
|
|
219
219
|
}
|
|
220
220
|
visited.push(objProto);
|
|
221
|
-
objProto = _getObjProto(objProto);
|
|
221
|
+
objProto = _getObjProto$1(objProto);
|
|
222
222
|
}
|
|
223
223
|
try {
|
|
224
224
|
if (canAddInst) {
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
|
|
237
237
|
var protoFunc = proto[funcName];
|
|
238
238
|
if (protoFunc === currentDynProtoProxy) {
|
|
239
|
-
protoFunc = _getObjProto(proto)[funcName];
|
|
239
|
+
protoFunc = _getObjProto$1(proto)[funcName];
|
|
240
240
|
}
|
|
241
241
|
if (typeof protoFunc !== strFunction) {
|
|
242
242
|
_throwTypeError("[" + funcName + "] is not a " + strFunction);
|
|
@@ -270,15 +270,15 @@
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
function _checkPrototype(classProto, thisTarget) {
|
|
273
|
-
if (_objGetPrototypeOf) {
|
|
273
|
+
if (_objGetPrototypeOf$1) {
|
|
274
274
|
var visited = [];
|
|
275
|
-
var thisProto = _getObjProto(thisTarget);
|
|
275
|
+
var thisProto = _getObjProto$1(thisTarget);
|
|
276
276
|
while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
|
|
277
277
|
if (thisProto === classProto) {
|
|
278
278
|
return true;
|
|
279
279
|
}
|
|
280
280
|
visited.push(thisProto);
|
|
281
|
-
thisProto = _getObjProto(thisProto);
|
|
281
|
+
thisProto = _getObjProto$1(thisProto);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
return false;
|
|
@@ -314,7 +314,7 @@
|
|
|
314
314
|
var instFuncs = _getInstanceFuncs(target);
|
|
315
315
|
var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
|
|
316
316
|
delegateFunc(target, baseFuncs);
|
|
317
|
-
var setInstanceFunc = !!_objGetPrototypeOf && !!perfOptions[strSetInstFuncs];
|
|
317
|
+
var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
|
|
318
318
|
if (setInstanceFunc && options) {
|
|
319
319
|
setInstanceFunc = !!options[strSetInstFuncs];
|
|
320
320
|
}
|
|
@@ -417,11 +417,27 @@
|
|
|
417
417
|
};
|
|
418
418
|
|
|
419
419
|
var strToString = "toString";
|
|
420
|
+
var str__Proto = "__proto__";
|
|
421
|
+
var strConstructor = "constructor";
|
|
420
422
|
var _objDefineProperty = ObjDefineProperty;
|
|
423
|
+
var _objFreeze = ObjClass.freeze;
|
|
421
424
|
var _isArray = Array.isArray;
|
|
422
425
|
var _objToString = ObjProto[strToString];
|
|
423
426
|
var _fnToString = ObjHasOwnProperty[strToString];
|
|
424
|
-
_fnToString.call(ObjClass);
|
|
427
|
+
var _objFunctionString = _fnToString.call(ObjClass);
|
|
428
|
+
var _objGetPrototypeOf = Object["getPrototypeOf"];
|
|
429
|
+
function _getObjProto(target) {
|
|
430
|
+
if (target) {
|
|
431
|
+
if (_objGetPrototypeOf) {
|
|
432
|
+
return _objGetPrototypeOf(target);
|
|
433
|
+
}
|
|
434
|
+
var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
|
|
435
|
+
if (newProto) {
|
|
436
|
+
return newProto;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
425
441
|
function isUndefined(value) {
|
|
426
442
|
return value === undefined || typeof value === strShimUndefined;
|
|
427
443
|
}
|
|
@@ -437,6 +453,15 @@
|
|
|
437
453
|
function isFunction(value) {
|
|
438
454
|
return !!(value && typeof value === strShimFunction);
|
|
439
455
|
}
|
|
456
|
+
function objForEachKey$1(target, callbackfn) {
|
|
457
|
+
if (target) {
|
|
458
|
+
for (var prop in target) {
|
|
459
|
+
if (ObjHasOwnProperty.call(target, prop)) {
|
|
460
|
+
callbackfn.call(target, prop, target[prop]);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
440
465
|
var isArray = _isArray || _isArrayPoly;
|
|
441
466
|
function _isArrayPoly(obj) {
|
|
442
467
|
return !!(obj && _objToString.call(obj) === "[object Array]");
|
|
@@ -444,6 +469,25 @@
|
|
|
444
469
|
function isError(obj) {
|
|
445
470
|
return !!(obj && _objToString.call(obj) === "[object Error]");
|
|
446
471
|
}
|
|
472
|
+
function isBoolean(value) {
|
|
473
|
+
return typeof value === "boolean";
|
|
474
|
+
}
|
|
475
|
+
function isPlainObject(value) {
|
|
476
|
+
var result = false;
|
|
477
|
+
if (value && typeof value === "object") {
|
|
478
|
+
var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
|
|
479
|
+
if (!proto) {
|
|
480
|
+
result = true;
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
|
|
484
|
+
proto = proto[strConstructor];
|
|
485
|
+
}
|
|
486
|
+
result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
447
491
|
function arrForEach(arr, callbackfn, thisArg) {
|
|
448
492
|
var len = arr.length;
|
|
449
493
|
try {
|
|
@@ -479,6 +523,10 @@
|
|
|
479
523
|
}
|
|
480
524
|
return false;
|
|
481
525
|
}
|
|
526
|
+
function _doNothing(value) {
|
|
527
|
+
return value;
|
|
528
|
+
}
|
|
529
|
+
var objFreeze = _objFreeze || _doNothing;
|
|
482
530
|
function dateNow() {
|
|
483
531
|
var dt = Date;
|
|
484
532
|
return dt.now ? dt.now() : new dt().getTime();
|
|
@@ -500,6 +548,50 @@
|
|
|
500
548
|
}
|
|
501
549
|
return theValue;
|
|
502
550
|
}
|
|
551
|
+
function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
|
|
552
|
+
var theArgs = arguments;
|
|
553
|
+
var extended = theArgs[0] || {};
|
|
554
|
+
var argLen = theArgs.length;
|
|
555
|
+
var deep = false;
|
|
556
|
+
var idx = 1;
|
|
557
|
+
if (argLen > 0 && isBoolean(extended)) {
|
|
558
|
+
deep = extended;
|
|
559
|
+
extended = theArgs[idx] || {};
|
|
560
|
+
idx++;
|
|
561
|
+
}
|
|
562
|
+
if (!isObject(extended)) {
|
|
563
|
+
extended = {};
|
|
564
|
+
}
|
|
565
|
+
for (; idx < argLen; idx++) {
|
|
566
|
+
var arg = theArgs[idx];
|
|
567
|
+
var isArgArray = isArray(arg);
|
|
568
|
+
var isArgObj = isObject(arg);
|
|
569
|
+
for (var prop in arg) {
|
|
570
|
+
var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
|
|
571
|
+
if (!propOk) {
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
var newValue = arg[prop];
|
|
575
|
+
var isNewArray = void 0;
|
|
576
|
+
if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
|
|
577
|
+
var clone = extended[prop];
|
|
578
|
+
if (isNewArray) {
|
|
579
|
+
if (!isArray(clone)) {
|
|
580
|
+
clone = [];
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
else if (!isPlainObject(clone)) {
|
|
584
|
+
clone = {};
|
|
585
|
+
}
|
|
586
|
+
newValue = objExtend(deep, clone, newValue);
|
|
587
|
+
}
|
|
588
|
+
if (newValue !== undefined) {
|
|
589
|
+
extended[prop] = newValue;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return extended;
|
|
594
|
+
}
|
|
503
595
|
|
|
504
596
|
var strWindow = "window";
|
|
505
597
|
var strConsole = "console";
|
|
@@ -824,186 +916,240 @@
|
|
|
824
916
|
return func();
|
|
825
917
|
}
|
|
826
918
|
|
|
827
|
-
var
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
919
|
+
var strTelemetryPluginChain = "TelemetryPluginChain";
|
|
920
|
+
var strHasRunFlags = "_hasRun";
|
|
921
|
+
var strGetTelCtx = "_getTelCtx";
|
|
922
|
+
var _chainId = 0;
|
|
923
|
+
function _getNextProxyStart(proxy, config, core, startAt) {
|
|
924
|
+
while (proxy) {
|
|
925
|
+
if (proxy.getPlugin() === startAt) {
|
|
926
|
+
return proxy;
|
|
927
|
+
}
|
|
928
|
+
proxy = proxy.getNext();
|
|
929
|
+
}
|
|
930
|
+
return createTelemetryProxyChain([startAt], config, core);
|
|
931
|
+
}
|
|
932
|
+
function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
|
|
933
|
+
var _nextProxy = null;
|
|
934
|
+
var _onComplete = null;
|
|
935
|
+
if (startAt) {
|
|
936
|
+
_nextProxy = _getNextProxyStart(telemetryChain, config, core, startAt);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
_nextProxy = telemetryChain;
|
|
940
|
+
}
|
|
941
|
+
var context = {
|
|
942
|
+
core: function () {
|
|
943
|
+
return core;
|
|
944
|
+
},
|
|
945
|
+
diagLog: function () {
|
|
946
|
+
return safeGetLogger(core, config);
|
|
947
|
+
},
|
|
948
|
+
getCfg: function () {
|
|
949
|
+
return config;
|
|
950
|
+
},
|
|
951
|
+
getExtCfg: _getExtCfg,
|
|
952
|
+
getConfig: _getConfig,
|
|
953
|
+
hasNext: function () {
|
|
954
|
+
return _nextProxy != null;
|
|
955
|
+
},
|
|
956
|
+
getNext: function () {
|
|
838
957
|
return _nextProxy;
|
|
839
|
-
}
|
|
840
|
-
|
|
958
|
+
},
|
|
959
|
+
setNext: function (nextPlugin) {
|
|
841
960
|
_nextProxy = nextPlugin;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
961
|
+
},
|
|
962
|
+
processNext: function (env) {
|
|
963
|
+
_processChain(function (nextPlugin) {
|
|
964
|
+
nextPlugin.processTelemetry(env, context);
|
|
965
|
+
});
|
|
966
|
+
},
|
|
967
|
+
iterate: _iterateChain,
|
|
968
|
+
createNew: function (plugins, startAt) {
|
|
969
|
+
if (plugins === void 0) { plugins = null; }
|
|
970
|
+
if (isArray(plugins)) {
|
|
971
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
846
972
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
973
|
+
return createProcessTelemetryContext(plugins || _nextProxy, config, core, startAt);
|
|
974
|
+
},
|
|
975
|
+
onComplete: function (onComplete) {
|
|
976
|
+
_onComplete = onComplete;
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
function _getExtCfg(identifier, defaultValue, mergeDefault) {
|
|
980
|
+
if (defaultValue === void 0) { defaultValue = {}; }
|
|
981
|
+
if (mergeDefault === void 0) { mergeDefault = 0 ; }
|
|
982
|
+
var theConfig;
|
|
983
|
+
if (config) {
|
|
984
|
+
var extConfig = config.extensionConfig;
|
|
985
|
+
if (extConfig && identifier) {
|
|
986
|
+
theConfig = extConfig[identifier];
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
if (!theConfig) {
|
|
990
|
+
theConfig = defaultValue;
|
|
991
|
+
}
|
|
992
|
+
else if (isObject(defaultValue)) {
|
|
993
|
+
if (mergeDefault !== 0 ) {
|
|
994
|
+
var newConfig_1 = objExtend(true, defaultValue, theConfig);
|
|
995
|
+
if (config && mergeDefault === 2 ) {
|
|
996
|
+
objForEachKey$1(defaultValue, function (field) {
|
|
997
|
+
if (isNullOrUndefined(newConfig_1[field])) {
|
|
998
|
+
var cfgValue = config[field];
|
|
999
|
+
if (!isNullOrUndefined(cfgValue)) {
|
|
1000
|
+
newConfig_1[field] = cfgValue;
|
|
1001
|
+
}
|
|
866
1002
|
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
else if (_nextProxy) {
|
|
870
|
-
_self._hasRun = true;
|
|
871
|
-
_nextProxy.processTelemetry(env, itemCtx);
|
|
872
|
-
}
|
|
873
|
-
}, function () { return ({ item: env }); }, !(env.sync));
|
|
874
|
-
};
|
|
875
|
-
}
|
|
876
|
-
return TelemetryPluginChain;
|
|
877
|
-
}());
|
|
878
|
-
|
|
879
|
-
function _createProxyChain(plugins, itemCtx) {
|
|
880
|
-
var proxies = [];
|
|
881
|
-
if (plugins && plugins.length > 0) {
|
|
882
|
-
var lastProxy = null;
|
|
883
|
-
for (var idx = 0; idx < plugins.length; idx++) {
|
|
884
|
-
var thePlugin = plugins[idx];
|
|
885
|
-
if (thePlugin && isFunction(thePlugin.processTelemetry)) {
|
|
886
|
-
var newProxy = new TelemetryPluginChain(thePlugin, itemCtx);
|
|
887
|
-
proxies.push(newProxy);
|
|
888
|
-
if (lastProxy) {
|
|
889
|
-
lastProxy.setNext(newProxy);
|
|
1003
|
+
});
|
|
890
1004
|
}
|
|
891
|
-
lastProxy = newProxy;
|
|
892
1005
|
}
|
|
893
1006
|
}
|
|
1007
|
+
return theConfig;
|
|
894
1008
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1009
|
+
function _getConfig(identifier, field, defaultValue) {
|
|
1010
|
+
if (defaultValue === void 0) { defaultValue = false; }
|
|
1011
|
+
var theValue;
|
|
1012
|
+
var extConfig = _getExtCfg(identifier, null);
|
|
1013
|
+
if (extConfig && !isNullOrUndefined(extConfig[field])) {
|
|
1014
|
+
theValue = extConfig[field];
|
|
1015
|
+
}
|
|
1016
|
+
else if (config && !isNullOrUndefined(config[field])) {
|
|
1017
|
+
theValue = config[field];
|
|
1018
|
+
}
|
|
1019
|
+
return !isNullOrUndefined(theValue) ? theValue : defaultValue;
|
|
1020
|
+
}
|
|
1021
|
+
function _processChain(cb) {
|
|
1022
|
+
var nextPlugin = _nextProxy;
|
|
1023
|
+
if (nextPlugin) {
|
|
1024
|
+
_nextProxy = nextPlugin.getNext();
|
|
1025
|
+
cb(nextPlugin);
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
if (_onComplete) {
|
|
1029
|
+
_onComplete();
|
|
1030
|
+
_onComplete = null;
|
|
906
1031
|
}
|
|
907
|
-
proxy = proxy.getNext();
|
|
908
1032
|
}
|
|
909
1033
|
}
|
|
910
|
-
|
|
911
|
-
|
|
1034
|
+
function _iterateChain(cb) {
|
|
1035
|
+
while (_nextProxy) {
|
|
1036
|
+
_processChain(function (nextPlugin) {
|
|
1037
|
+
var plugin = nextPlugin.getPlugin();
|
|
1038
|
+
if (plugin) {
|
|
1039
|
+
cb(plugin);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
912
1043
|
}
|
|
913
|
-
return
|
|
1044
|
+
return context;
|
|
914
1045
|
}
|
|
915
|
-
function
|
|
916
|
-
var
|
|
917
|
-
var add = false;
|
|
918
|
-
if (
|
|
919
|
-
|
|
920
|
-
arrForEach(
|
|
921
|
-
if (add
|
|
1046
|
+
function createTelemetryProxyChain(plugins, config, core, startAt) {
|
|
1047
|
+
var firstProxy = null;
|
|
1048
|
+
var add = startAt ? false : true;
|
|
1049
|
+
if (isArray(plugins) && plugins.length > 0) {
|
|
1050
|
+
var lastProxy_1 = null;
|
|
1051
|
+
arrForEach(plugins, function (thePlugin) {
|
|
1052
|
+
if (!add && startAt === thePlugin) {
|
|
922
1053
|
add = true;
|
|
923
|
-
|
|
1054
|
+
}
|
|
1055
|
+
if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
|
|
1056
|
+
var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
|
|
1057
|
+
if (!firstProxy) {
|
|
1058
|
+
firstProxy = newProxy;
|
|
1059
|
+
}
|
|
1060
|
+
if (lastProxy_1) {
|
|
1061
|
+
lastProxy_1._setNext(newProxy);
|
|
1062
|
+
}
|
|
1063
|
+
lastProxy_1 = newProxy;
|
|
924
1064
|
}
|
|
925
1065
|
});
|
|
926
1066
|
}
|
|
927
|
-
if (startAt && !
|
|
928
|
-
|
|
929
|
-
plugins = [];
|
|
930
|
-
}
|
|
931
|
-
plugins.push(startAt);
|
|
1067
|
+
if (startAt && !firstProxy) {
|
|
1068
|
+
return createTelemetryProxyChain([startAt], config, core);
|
|
932
1069
|
}
|
|
933
|
-
return
|
|
1070
|
+
return firstProxy;
|
|
934
1071
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1072
|
+
function createTelemetryPluginProxy(plugin, config, core) {
|
|
1073
|
+
var nextProxy = null;
|
|
1074
|
+
var hasProcessTelemetry = isFunction(plugin.processTelemetry);
|
|
1075
|
+
var hasSetNext = isFunction(plugin.setNextPlugin);
|
|
1076
|
+
var chainId;
|
|
1077
|
+
if (plugin) {
|
|
1078
|
+
chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
chainId = "Unknown-0-" + _chainId++;
|
|
1082
|
+
}
|
|
1083
|
+
var proxyChain = {
|
|
1084
|
+
getPlugin: function () {
|
|
1085
|
+
return plugin;
|
|
1086
|
+
},
|
|
1087
|
+
getNext: function () {
|
|
1088
|
+
return nextProxy;
|
|
1089
|
+
},
|
|
1090
|
+
processTelemetry: _processTelemetry,
|
|
1091
|
+
_id: chainId,
|
|
1092
|
+
_setNext: function (nextPlugin) {
|
|
1093
|
+
nextProxy = nextPlugin;
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
function _processChain(itemCtx, processPluginFn, processProxyFn, name, details, isAsync) {
|
|
1097
|
+
if (!itemCtx) {
|
|
1098
|
+
if (plugin && isFunction(plugin[strGetTelCtx])) {
|
|
1099
|
+
itemCtx = plugin[strGetTelCtx]();
|
|
942
1100
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
_nextProxy = _copyPluginChain(plugins, _self, startAt);
|
|
946
|
-
}
|
|
947
|
-
else if (isUndefined(startAt)) {
|
|
948
|
-
_nextProxy = _createProxyChain(plugins, _self);
|
|
949
|
-
}
|
|
1101
|
+
if (!itemCtx) {
|
|
1102
|
+
itemCtx = createProcessTelemetryContext(proxyChain, config, core);
|
|
950
1103
|
}
|
|
951
1104
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1105
|
+
var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
|
|
1106
|
+
var hasRunContext = itemCtx[strHasRunFlags];
|
|
1107
|
+
if (!hasRunContext) {
|
|
1108
|
+
hasRunContext = itemCtx[strHasRunFlags] = {};
|
|
1109
|
+
}
|
|
1110
|
+
doPerf(itemCtx.core(), function () { return identifier + ":" + name; }, function () {
|
|
1111
|
+
hasRunContext[chainId] = true;
|
|
1112
|
+
var hasRun = false;
|
|
1113
|
+
itemCtx.setNext(nextProxy);
|
|
1114
|
+
if (plugin) {
|
|
1115
|
+
try {
|
|
1116
|
+
var nextId = nextProxy ? nextProxy._id : "";
|
|
1117
|
+
if (nextId) {
|
|
1118
|
+
hasRunContext[nextId] = false;
|
|
1119
|
+
}
|
|
1120
|
+
hasRun = processPluginFn(itemCtx);
|
|
1121
|
+
}
|
|
1122
|
+
catch (error) {
|
|
1123
|
+
var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
|
|
1124
|
+
if (hasNextRun) {
|
|
1125
|
+
hasRun = true;
|
|
1126
|
+
}
|
|
1127
|
+
if (!nextProxy || !hasNextRun) {
|
|
1128
|
+
itemCtx.diagLog().throwInternal(LoggingSeverity.CRITICAL, _InternalMessageId.PluginException, "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
|
|
1129
|
+
}
|
|
968
1130
|
}
|
|
969
1131
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
_self.getConfig = function (identifier, field, defaultValue) {
|
|
973
|
-
if (defaultValue === void 0) { defaultValue = false; }
|
|
974
|
-
var theValue;
|
|
975
|
-
var extConfig = _self.getExtCfg(identifier, null);
|
|
976
|
-
if (extConfig && !isNullOrUndefined(extConfig[field])) {
|
|
977
|
-
theValue = extConfig[field];
|
|
1132
|
+
if (nextProxy && !hasRun) {
|
|
1133
|
+
processProxyFn(itemCtx);
|
|
978
1134
|
}
|
|
979
|
-
|
|
980
|
-
|
|
1135
|
+
}, details, isAsync);
|
|
1136
|
+
}
|
|
1137
|
+
function _processTelemetry(env, itemCtx) {
|
|
1138
|
+
_processChain(itemCtx, function (itemCtx) {
|
|
1139
|
+
if (!hasProcessTelemetry) {
|
|
1140
|
+
return false;
|
|
981
1141
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
_self.hasNext = function () {
|
|
985
|
-
return _nextProxy != null;
|
|
986
|
-
};
|
|
987
|
-
_self.getNext = function () {
|
|
988
|
-
return _nextProxy;
|
|
989
|
-
};
|
|
990
|
-
_self.setNext = function (nextPlugin) {
|
|
991
|
-
_nextProxy = nextPlugin;
|
|
992
|
-
};
|
|
993
|
-
_self.processNext = function (env) {
|
|
994
|
-
var nextPlugin = _nextProxy;
|
|
995
|
-
if (nextPlugin) {
|
|
996
|
-
_nextProxy = nextPlugin.getNext();
|
|
997
|
-
nextPlugin.processTelemetry(env, _self);
|
|
1142
|
+
if (hasSetNext) {
|
|
1143
|
+
plugin.setNextPlugin(nextProxy);
|
|
998
1144
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
};
|
|
1145
|
+
plugin.processTelemetry(env, itemCtx);
|
|
1146
|
+
return true;
|
|
1147
|
+
}, function (itemCtx) {
|
|
1148
|
+
nextProxy.processTelemetry(env, itemCtx);
|
|
1149
|
+
}, "processTelemetry", function () { return ({ item: env }); }, !(env.sync));
|
|
1004
1150
|
}
|
|
1005
|
-
return
|
|
1006
|
-
}
|
|
1151
|
+
return objFreeze(proxyChain);
|
|
1152
|
+
}
|
|
1007
1153
|
|
|
1008
1154
|
var strExtensionConfig = "extensionConfig";
|
|
1009
1155
|
|
|
@@ -1011,12 +1157,29 @@
|
|
|
1011
1157
|
var BaseTelemetryPlugin = /** @class */ (function () {
|
|
1012
1158
|
function BaseTelemetryPlugin() {
|
|
1013
1159
|
var _self = this;
|
|
1014
|
-
var _isinitialized
|
|
1015
|
-
var _rootCtx
|
|
1016
|
-
var _nextPlugin
|
|
1017
|
-
|
|
1160
|
+
var _isinitialized;
|
|
1161
|
+
var _rootCtx;
|
|
1162
|
+
var _nextPlugin;
|
|
1163
|
+
var _hooks;
|
|
1164
|
+
_initDefaults();
|
|
1165
|
+
dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
|
|
1166
|
+
_self.initialize = function (config, core, extensions, pluginChain) {
|
|
1167
|
+
_setDefaults(config, core, pluginChain);
|
|
1168
|
+
_isinitialized = true;
|
|
1169
|
+
};
|
|
1170
|
+
_self._addHook = function (hooks) {
|
|
1171
|
+
if (hooks) {
|
|
1172
|
+
if (isArray(hooks)) {
|
|
1173
|
+
_hooks = _hooks.concat(hooks);
|
|
1174
|
+
}
|
|
1175
|
+
else {
|
|
1176
|
+
_hooks.push(hooks);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
});
|
|
1018
1181
|
_self.diagLog = function (itemCtx) {
|
|
1019
|
-
return
|
|
1182
|
+
return _getTelCtx(itemCtx).diagLog();
|
|
1020
1183
|
};
|
|
1021
1184
|
_self.isInitialized = function () {
|
|
1022
1185
|
return _isinitialized;
|
|
@@ -1035,11 +1198,12 @@
|
|
|
1035
1198
|
_nextPlugin.processTelemetry(env, null);
|
|
1036
1199
|
}
|
|
1037
1200
|
};
|
|
1038
|
-
_self._getTelCtx =
|
|
1201
|
+
_self._getTelCtx = _getTelCtx;
|
|
1202
|
+
function _getTelCtx(currentCtx) {
|
|
1039
1203
|
if (currentCtx === void 0) { currentCtx = null; }
|
|
1040
1204
|
var itemCtx = currentCtx;
|
|
1041
1205
|
if (!itemCtx) {
|
|
1042
|
-
var rootCtx = _rootCtx ||
|
|
1206
|
+
var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
|
|
1043
1207
|
if (_nextPlugin && _nextPlugin[strGetPlugin]) {
|
|
1044
1208
|
itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
|
|
1045
1209
|
}
|
|
@@ -1048,8 +1212,8 @@
|
|
|
1048
1212
|
}
|
|
1049
1213
|
}
|
|
1050
1214
|
return itemCtx;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1215
|
+
}
|
|
1216
|
+
function _setDefaults(config, core, pluginChain) {
|
|
1053
1217
|
if (config) {
|
|
1054
1218
|
setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
|
|
1055
1219
|
}
|
|
@@ -1061,13 +1225,16 @@
|
|
|
1061
1225
|
nextPlugin = _nextPlugin[strGetPlugin]();
|
|
1062
1226
|
}
|
|
1063
1227
|
_self.core = core;
|
|
1064
|
-
_rootCtx =
|
|
1065
|
-
|
|
1066
|
-
|
|
1228
|
+
_rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
|
|
1229
|
+
}
|
|
1230
|
+
function _initDefaults() {
|
|
1231
|
+
_isinitialized = false;
|
|
1232
|
+
_self.core = null;
|
|
1233
|
+
_rootCtx = null;
|
|
1234
|
+
_nextPlugin = null;
|
|
1235
|
+
_hooks = [];
|
|
1236
|
+
}
|
|
1067
1237
|
}
|
|
1068
|
-
BaseTelemetryPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {
|
|
1069
|
-
this._baseTelInit(config, core, extensions, pluginChain);
|
|
1070
|
-
};
|
|
1071
1238
|
return BaseTelemetryPlugin;
|
|
1072
1239
|
}());
|
|
1073
1240
|
|