@microsoft/applicationinsights-properties-js 3.0.0-beta.2211-03 → 3.0.0-beta.2212-03

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, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Properties Plugin, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -540,114 +540,39 @@
540
540
  return registry.k[key];
541
541
  }
542
542
 
543
- function objSetPrototypeOf(obj, proto) {
544
- var fn = ObjClass["setPrototypeOf"] ||
545
- ({ __proto__: [] } instanceof Array && function (d, b) {
546
- d.__proto__ = b;
547
- }) ||
548
- function (d, b) {
549
- objForEachKey(b, function (key, value) {
550
- d[key] = value;
551
- });
552
- };
553
- return fn(obj, proto);
554
- }
555
-
556
- function _createCustomError(name, d, b) {
557
- objSetPrototypeOf(d, b);
558
- function __() {
559
- this.constructor = d;
560
- }
561
- __[PROTOTYPE] = b[PROTOTYPE];
562
- __[PROTOTYPE].name = name;
563
- d[PROTOTYPE] = new __();
564
- return d;
565
- }
566
- function createCustomError(name, constructCb) {
567
- var baseClass = Error;
568
- var customError = _createCustomError(name, function () {
569
- var _this = this;
570
- _this = baseClass.apply(_this, arguments) || _this;
571
- constructCb && constructCb(_this, arguments);
572
- return _this;
573
- }, baseClass);
574
- return customError;
575
- }
576
- var _unsupportedError;
577
- function throwUnsupported(message) {
578
- if (!_unsupportedError) {
579
- _unsupportedError = createCustomError("UnsupportedError");
580
- }
581
- throw new _unsupportedError(message);
582
- }
583
-
584
- function dumpObj(object, format) {
585
- var objectTypeDump = objToString(object);
586
- var propertyValueDump = "";
587
- if (objectTypeDump === "[object Error]") {
588
- propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
589
- }
590
- else {
591
- try {
592
- if (format) {
593
- if (isNumber(format)) {
594
- propertyValueDump = JSON.stringify(object, null, format);
595
- }
596
- else {
597
- propertyValueDump = JSON.stringify(object, null, 4);
598
- }
599
- }
600
- else {
601
- propertyValueDump = JSON.stringify(object);
602
- }
603
- }
604
- catch (e) {
605
- propertyValueDump = objToString(object) + " - " + dumpObj(e, format);
606
- }
607
- }
608
- return objectTypeDump + ": " + propertyValueDump;
609
- }
610
-
611
- var _objDefineProperty$1 = ObjClass["defineProperty"];
612
- function objDefineProp(target, key, descriptor) {
613
- if (_objDefineProperty$1) {
614
- _objDefineProperty$1(target, key, descriptor);
615
- return target;
616
- }
617
- throwUnsupported("Unable to define property [" + objToString(key) + "] on " + dumpObj(target));
543
+ var propMap = {
544
+ e: "enumerable",
545
+ c: "configurable",
546
+ v: VALUE,
547
+ w: "writable",
548
+ g: "get",
549
+ s: "set"
550
+ };
551
+ function _createProp(value) {
552
+ var prop = {};
553
+ prop[propMap["c"]] = true;
554
+ prop[propMap["e"]] = true;
555
+ objForEachKey(value, function (key, value) {
556
+ prop[propMap[key]] = isUndefined(value) ? prop[propMap[key]] : value;
557
+ });
558
+ return prop;
618
559
  }
619
- function objDefineGet(target, key, value, configurable) {
560
+ var objDefineProp = ObjClass.defineProperty;
561
+ function objDefineAccessors(target, prop, getProp, setProp, configurable, enumerable) {
620
562
  var desc = {
621
- enumerable: true,
622
- configurable: isUndefined(configurable) ? true : configurable
563
+ e: enumerable,
564
+ c: configurable
623
565
  };
624
- if (isFunction(value)) {
625
- desc.get = value;
566
+ if (getProp) {
567
+ desc.g = getProp;
626
568
  }
627
- else {
628
- desc[VALUE] = value;
569
+ if (setProp) {
570
+ desc.s = setProp;
629
571
  }
630
- return objDefineProp(target, key, desc);
572
+ return objDefineProp(target, prop, _createProp(desc));
631
573
  }
632
- function objDefineAccessors(target, prop, getProp, setProp, configurable) {
633
- if (_objDefineProperty$1) {
634
- try {
635
- var descriptor = {
636
- enumerable: true,
637
- configurable: isUndefined(configurable) ? true : configurable
638
- };
639
- if (getProp) {
640
- descriptor.get = getProp;
641
- }
642
- if (setProp) {
643
- descriptor.set = setProp;
644
- }
645
- return objDefineProp(target, prop, descriptor);
646
- }
647
- catch (e) {
648
- throwUnsupported("Unable to define accessors for [" + objToString(prop) + "] on " + dumpObj(target));
649
- }
650
- }
574
+ function objDefine(target, key, propDesc) {
575
+ return objDefineProp(target, key, _createProp(propDesc));
651
576
  }
652
577
 
653
578
  var _globalLazyTestHooks;
@@ -659,24 +584,21 @@
659
584
  var lazyValue = {};
660
585
  _fetchLazyTestHooks && _fetchLazyTestHooks();
661
586
  lazyValue.b = _globalLazyTestHooks.lzy;
662
- objDefineGet(lazyValue, "v", function () {
663
- var result = cb();
664
- if (!_globalLazyTestHooks.lzy) {
665
- objDefineProp(lazyValue, "v", {
666
- enumerable: true,
667
- configurable: true,
668
- writable: false,
669
- value: result
670
- });
671
- if (lazyValue.b) {
672
- delete lazyValue.b;
587
+ objDefine(lazyValue, "v", {
588
+ g: function () {
589
+ var result = cb();
590
+ if (!_globalLazyTestHooks.lzy) {
591
+ objDefine(lazyValue, "v", { v: result });
592
+ if (lazyValue.b) {
593
+ delete lazyValue.b;
594
+ }
673
595
  }
596
+ if (_globalLazyTestHooks.lzy && lazyValue.b !== _globalLazyTestHooks.lzy) {
597
+ lazyValue.b = _globalLazyTestHooks.lzy;
598
+ }
599
+ return result;
674
600
  }
675
- if (_globalLazyTestHooks.lzy && lazyValue.b !== _globalLazyTestHooks.lzy) {
676
- lazyValue.b = _globalLazyTestHooks.lzy;
677
- }
678
- return result;
679
- }, true);
601
+ });
680
602
  return lazyValue;
681
603
  }
682
604
 
@@ -776,6 +698,33 @@
776
698
  }
777
699
  }
778
700
 
701
+ function dumpObj(object, format) {
702
+ var objectTypeDump = objToString(object);
703
+ var propertyValueDump = "";
704
+ if (objectTypeDump === "[object Error]") {
705
+ propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
706
+ }
707
+ else {
708
+ try {
709
+ if (format) {
710
+ if (isNumber(format)) {
711
+ propertyValueDump = JSON.stringify(object, null, format);
712
+ }
713
+ else {
714
+ propertyValueDump = JSON.stringify(object, null, 4);
715
+ }
716
+ }
717
+ else {
718
+ propertyValueDump = JSON.stringify(object);
719
+ }
720
+ }
721
+ catch (e) {
722
+ propertyValueDump = objToString(object) + " - " + dumpObj(e, format);
723
+ }
724
+ }
725
+ return objectTypeDump + ": " + propertyValueDump;
726
+ }
727
+
779
728
  function _unwrapFunction(funcName) {
780
729
  return function (thisArg) {
781
730
  var args = [];
@@ -791,6 +740,40 @@
791
740
 
792
741
  var arrIndexOf = _unwrapFunction(INDEX_OF);
793
742
 
743
+ function objSetPrototypeOf(obj, proto) {
744
+ var fn = ObjClass["setPrototypeOf"] ||
745
+ ({ __proto__: [] } instanceof Array && function (d, b) {
746
+ d.__proto__ = b;
747
+ }) ||
748
+ function (d, b) {
749
+ objForEachKey(b, function (key, value) {
750
+ d[key] = value;
751
+ });
752
+ };
753
+ return fn(obj, proto);
754
+ }
755
+
756
+ function _createCustomError(name, d, b) {
757
+ objSetPrototypeOf(d, b);
758
+ function __() {
759
+ this.constructor = d;
760
+ }
761
+ __[PROTOTYPE] = b[PROTOTYPE];
762
+ __[PROTOTYPE].name = name;
763
+ d[PROTOTYPE] = new __();
764
+ return d;
765
+ }
766
+ function createCustomError(name, constructCb) {
767
+ var baseClass = Error;
768
+ var customError = _createCustomError(name, function () {
769
+ var _this = this;
770
+ _this = baseClass.apply(_this, arguments) || _this;
771
+ constructCb && constructCb(_this, arguments);
772
+ return _this;
773
+ }, baseClass);
774
+ return customError;
775
+ }
776
+
794
777
  function utcNow() {
795
778
  return (Date.now || polyUtcNow)();
796
779
  }
@@ -931,13 +914,14 @@
931
914
  var _DYN_INITIALIZE = "initialize";
932
915
  var _DYN_IDENTIFIER = "identifier";
933
916
  var _DYN_IS_INITIALIZED = "isInitialized";
917
+ var _DYN_GET_PLUGIN = "getPlugin";
934
918
  var _DYN_NAME$1 = "name";
935
919
  var _DYN_TIME = "time";
936
920
  var _DYN_PROCESS_NEXT = "processNext";
937
921
  var _DYN_GET_PROCESS_TEL_CONT0 = "getProcessTelContext";
938
922
  var _DYN_CALL = "call";
939
- var _DYN_GET_PLUGIN = "getPlugin";
940
923
  var _DYN_LOGGING_LEVEL_CONSOL4 = "loggingLevelConsole";
924
+ var _DYN_CREATE_NEW = "createNew";
941
925
  var _DYN_TEARDOWN = "teardown";
942
926
  var _DYN_MESSAGE_ID = "messageId";
943
927
  var _DYN_MESSAGE = "message";
@@ -947,8 +931,6 @@
947
931
  var _DYN_UPDATE$1 = "update";
948
932
  var _DYN_GET_NEXT = "getNext";
949
933
  var _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
950
- var _DYN_CREATE_NEW = "createNew";
951
- var _DYN_CONFIG = "config";
952
934
  var _DYN_USER_AGENT = "userAgent";
953
935
  var _DYN_SPLIT = "split";
954
936
  var _DYN_NODE_TYPE = "nodeType";
@@ -1215,7 +1197,7 @@
1215
1197
  }
1216
1198
 
1217
1199
  var _objDefineProperty = ObjDefineProperty;
1218
- var version = "3.0.0-beta.2211-03";
1200
+ var version = "3.0.0-beta.2212-03";
1219
1201
  var instanceName = "." + newId(6);
1220
1202
  var _dataUid = 0;
1221
1203
  function _createAccessor(target, prop, value) {
@@ -1899,791 +1881,791 @@
1899
1881
  _getLogger(logger)[_DYN_LOG_INTERNAL_MESSAGE ](severity, message);
1900
1882
  }
1901
1883
 
1902
- var strExecutionContextKey = "ctx";
1903
- var strParentContextKey = "ParentContextKey";
1904
- var strChildrenContextKey = "ChildrenContextKey";
1905
- var PerfEvent = /** @class */ (function () {
1906
- function PerfEvent(name, payloadDetails, isAsync) {
1907
- var _self = this;
1908
- _self.start = utcNow();
1909
- _self[_DYN_NAME$1 ] = name;
1910
- _self[_DYN_IS_ASYNC ] = isAsync;
1911
- _self[_DYN_IS_CHILD_EVT ] = function () { return false; };
1912
- if (isFunction(payloadDetails)) {
1913
- var theDetails_1;
1914
- objDefineAccessors(_self, "payload", function () {
1915
- if (!theDetails_1 && isFunction(payloadDetails)) {
1916
- theDetails_1 = payloadDetails();
1917
- payloadDetails = null;
1918
- }
1919
- return theDetails_1;
1920
- });
1921
- }
1922
- _self[_DYN_GET_CTX ] = function (key) {
1923
- if (key) {
1924
- if (key === PerfEvent[strParentContextKey] || key === PerfEvent[strChildrenContextKey]) {
1925
- return _self[key];
1926
- }
1927
- return (_self[strExecutionContextKey] || {})[key];
1928
- }
1929
- return null;
1930
- };
1931
- _self[_DYN_SET_CTX ] = function (key, value) {
1932
- if (key) {
1933
- if (key === PerfEvent[strParentContextKey]) {
1934
- if (!_self[key]) {
1935
- _self[_DYN_IS_CHILD_EVT ] = function () { return true; };
1936
- }
1937
- _self[key] = value;
1938
- }
1939
- else if (key === PerfEvent[strChildrenContextKey]) {
1940
- _self[key] = value;
1941
- }
1942
- else {
1943
- var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
1944
- ctx[key] = value;
1945
- }
1946
- }
1947
- };
1948
- _self[_DYN_COMPLETE ] = function () {
1949
- var childTime = 0;
1950
- var childEvts = _self[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
1951
- if (isArray(childEvts)) {
1952
- for (var lp = 0; lp < childEvts[_DYN_LENGTH$2 ]; lp++) {
1953
- var childEvt = childEvts[lp];
1954
- if (childEvt) {
1955
- childTime += childEvt[_DYN_TIME ];
1956
- }
1957
- }
1958
- }
1959
- _self[_DYN_TIME ] = utcNow() - _self.start;
1960
- _self.exTime = _self[_DYN_TIME ] - childTime;
1961
- _self[_DYN_COMPLETE ] = function () { };
1962
- };
1884
+ var _a$2, _b;
1885
+ var strToGMTString = "toGMTString";
1886
+ var strToUTCString = "toUTCString";
1887
+ var strCookie = "cookie";
1888
+ var strExpires = "expires";
1889
+ var strIsCookieUseDisabled = "isCookieUseDisabled";
1890
+ var strDisableCookiesUsage = "disableCookiesUsage";
1891
+ var strConfigCookieMgr = "_ckMgr";
1892
+ var _supportsCookies = null;
1893
+ var _allowUaSameSite = null;
1894
+ var _parsedCookieValue = null;
1895
+ var _doc = getDocument();
1896
+ var _cookieCache = {};
1897
+ var _globalCookieConfig = {};
1898
+ var defaultConfig = objDeepFreeze((_a$2 = {},
1899
+ _a$2[STR_DOMAIN] = { fb: "cookieDomain", dfVal: isNotNullOrUndefined },
1900
+ _a$2.path = { fb: "cookiePath", dfVal: isNotNullOrUndefined },
1901
+ _a$2.enabled = UNDEFINED_VALUE,
1902
+ _a$2));
1903
+ var rootDefaultConfig = (_b = {
1904
+ cookieCfg: {},
1905
+ cookieDomain: UNDEFINED_VALUE,
1906
+ cookiePath: UNDEFINED_VALUE
1907
+ },
1908
+ _b[strDisableCookiesUsage] = UNDEFINED_VALUE,
1909
+ _b);
1910
+ function _gblCookieMgr(config, logger) {
1911
+ var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
1912
+ if (!inst) {
1913
+ inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
1914
+ _globalCookieConfig[strConfigCookieMgr] = inst;
1963
1915
  }
1964
- PerfEvent.ParentContextKey = "parent";
1965
- PerfEvent.ChildrenContextKey = "childEvts";
1966
- return PerfEvent;
1967
- }());
1968
- var doPerfActiveKey = "CoreUtils.doPerf";
1969
- function doPerf(mgrSource, getSource, func, details, isAsync) {
1970
- if (mgrSource) {
1971
- var perfMgr = mgrSource;
1972
- if (perfMgr[STR_GET_PERF_MGR]) {
1973
- perfMgr = perfMgr[STR_GET_PERF_MGR]();
1974
- }
1975
- if (perfMgr) {
1976
- var perfEvt = void 0;
1977
- var currentActive = perfMgr[_DYN_GET_CTX ](doPerfActiveKey);
1978
- try {
1979
- perfEvt = perfMgr.create(getSource(), details, isAsync);
1980
- if (perfEvt) {
1981
- if (currentActive && perfEvt[_DYN_SET_CTX ]) {
1982
- perfEvt[_DYN_SET_CTX ](PerfEvent[strParentContextKey], currentActive);
1983
- if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
1984
- var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
1985
- if (!children) {
1986
- children = [];
1987
- currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
1988
- }
1989
- children[_DYN_PUSH ](perfEvt);
1990
- }
1991
- }
1992
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
1993
- return func(perfEvt);
1994
- }
1995
- }
1996
- catch (ex) {
1997
- if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
1998
- perfEvt[_DYN_SET_CTX ]("exception", ex);
1999
- }
2000
- }
2001
- finally {
2002
- if (perfEvt) {
2003
- perfMgr.fire(perfEvt);
2004
- }
2005
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
2006
- }
2007
- }
2008
- }
2009
- return func();
1916
+ return inst;
2010
1917
  }
2011
-
2012
- function generateW3CId() {
2013
- var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2014
- var oct = STR_EMPTY, tmp;
2015
- for (var a = 0; a < 4; a++) {
2016
- tmp = random32();
2017
- oct +=
2018
- hexValues[tmp & 0xF] +
2019
- hexValues[tmp >> 4 & 0xF] +
2020
- hexValues[tmp >> 8 & 0xF] +
2021
- hexValues[tmp >> 12 & 0xF] +
2022
- hexValues[tmp >> 16 & 0xF] +
2023
- hexValues[tmp >> 20 & 0xF] +
2024
- hexValues[tmp >> 24 & 0xF] +
2025
- hexValues[tmp >> 28 & 0xF];
1918
+ function _isMgrEnabled(cookieMgr) {
1919
+ if (cookieMgr) {
1920
+ return cookieMgr.isEnabled();
2026
1921
  }
2027
- var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2028
- return strSubstr(oct, 0, 8) + strSubstr(oct, 9, 4) + "4" + strSubstr(oct, 13, 3) + clockSequenceHi + strSubstr(oct, 16, 3) + strSubstr(oct, 19, 12);
1922
+ return true;
2029
1923
  }
2030
-
2031
- var INVALID_TRACE_ID = "00000000000000000000000000000000";
2032
- var INVALID_SPAN_ID = "0000000000000000";
2033
- function _isValid(value, len, invalidValue) {
2034
- if (value && value[_DYN_LENGTH$2 ] === len && value !== invalidValue) {
2035
- return !!value.match(/^[\da-f]*$/i);
1924
+ function _isIgnoredCookie(cookieMgrCfg, name) {
1925
+ if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {
1926
+ return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;
2036
1927
  }
2037
1928
  return false;
2038
1929
  }
2039
- function isValidTraceId(value) {
2040
- return _isValid(value, 32, INVALID_TRACE_ID);
2041
- }
2042
- function isValidSpanId(value) {
2043
- return _isValid(value, 16, INVALID_SPAN_ID);
2044
- }
2045
-
2046
- var pluginStateData = createElmNodeData("plugin");
2047
- function _getPluginState(plugin) {
2048
- return pluginStateData.get(plugin, "state", {}, true);
2049
- }
2050
-
2051
- var strTelemetryPluginChain = "TelemetryPluginChain";
2052
- var strHasRunFlags = "_hasRun";
2053
- var strGetTelCtx = "_getTelCtx";
2054
- var _chainId = 0;
2055
- function _getNextProxyStart(proxy, core, startAt) {
2056
- while (proxy) {
2057
- if (proxy[_DYN_GET_PLUGIN ]() === startAt) {
2058
- return proxy;
1930
+ function _isBlockedCookie(cookieMgrCfg, name) {
1931
+ if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {
1932
+ if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {
1933
+ return true;
2059
1934
  }
2060
- proxy = proxy[_DYN_GET_NEXT ]();
2061
1935
  }
2062
- return createTelemetryProxyChain([startAt], core[_DYN_CONFIG ] || {}, core);
1936
+ return _isIgnoredCookie(cookieMgrCfg, name);
2063
1937
  }
2064
- function _createInternalContext(telemetryChain, dynamicHandler, core, startAt) {
2065
- var _nextProxy = null;
2066
- var _onComplete = [];
2067
- if (!dynamicHandler) {
2068
- dynamicHandler = createDynamicConfig({}, null, core[_DYN_LOGGER ]);
2069
- }
2070
- if (startAt !== null) {
2071
- _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
1938
+ function safeGetCookieMgr(core, config) {
1939
+ var cookieMgr;
1940
+ if (core) {
1941
+ cookieMgr = core.getCookieMgr();
2072
1942
  }
2073
- var context = {
2074
- _next: _moveNext,
2075
- ctx: {
2076
- core: function () {
2077
- return core;
2078
- },
2079
- diagLog: function () {
2080
- return safeGetLogger(core, dynamicHandler.cfg);
2081
- },
2082
- getCfg: function () {
2083
- return dynamicHandler.cfg;
2084
- },
2085
- getExtCfg: _resolveExtCfg,
2086
- getConfig: _getConfig,
2087
- hasNext: function () {
2088
- return !!_nextProxy;
2089
- },
2090
- getNext: function () {
2091
- return _nextProxy;
2092
- },
2093
- setNext: function (nextPlugin) {
2094
- _nextProxy = nextPlugin;
2095
- },
2096
- iterate: _iterateChain,
2097
- onComplete: _addOnComplete
2098
- }
2099
- };
2100
- function _addOnComplete(onComplete, that) {
2101
- var args = [];
2102
- for (var _i = 2; _i < arguments.length; _i++) {
2103
- args[_i - 2] = arguments[_i];
1943
+ else if (config) {
1944
+ var cookieCfg = config.cookieCfg;
1945
+ if (cookieCfg && cookieCfg[strConfigCookieMgr]) {
1946
+ cookieMgr = cookieCfg[strConfigCookieMgr];
2104
1947
  }
2105
- if (onComplete) {
2106
- _onComplete[_DYN_PUSH ]({
2107
- func: onComplete,
2108
- self: !isUndefined(that) ? that : context.ctx,
2109
- args: args
2110
- });
1948
+ else {
1949
+ cookieMgr = createCookieMgr(config);
2111
1950
  }
2112
1951
  }
2113
- function _moveNext() {
2114
- var nextProxy = _nextProxy;
2115
- _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT ]() : null;
2116
- if (!nextProxy) {
2117
- var onComplete = _onComplete;
2118
- if (onComplete && onComplete[_DYN_LENGTH$2 ] > 0) {
2119
- arrForEach(onComplete, function (completeDetails) {
2120
- try {
2121
- completeDetails.func[_DYN_CALL ](completeDetails.self, completeDetails.args);
2122
- }
2123
- catch (e) {
2124
- _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
2125
- }
2126
- });
2127
- _onComplete = [];
2128
- }
2129
- }
2130
- return nextProxy;
1952
+ if (!cookieMgr) {
1953
+ cookieMgr = _gblCookieMgr(config, (core || {})[_DYN_LOGGER ]);
2131
1954
  }
2132
- function _getExtCfg(identifier, createIfMissing) {
2133
- var idCfg = null;
2134
- var cfg = dynamicHandler.cfg;
2135
- if (cfg && identifier) {
2136
- var extCfg = cfg[STR_EXTENSION_CONFIG ];
2137
- if (!extCfg && createIfMissing) {
2138
- extCfg = {};
1955
+ return cookieMgr;
1956
+ }
1957
+ function createCookieMgr(rootConfig, logger) {
1958
+ var cookieMgrConfig;
1959
+ var _path;
1960
+ var _domain;
1961
+ var _enabled;
1962
+ var _getCookieFn;
1963
+ var _setCookieFn;
1964
+ var _delCookieFn;
1965
+ rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;
1966
+ onConfigChange(rootConfig, function (details) {
1967
+ details[_DYN_SET_DF ](details.cfg, rootDefaultConfig);
1968
+ cookieMgrConfig = details[_DYN_SET_DF ](details.cfg.cookieCfg, defaultConfig);
1969
+ var isEnabled = cookieMgrConfig.enabled;
1970
+ if (isNullOrUndefined(isEnabled)) {
1971
+ var cookieEnabled = void 0;
1972
+ if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
1973
+ cookieEnabled = !rootConfig[strIsCookieUseDisabled];
2139
1974
  }
2140
- dynamicHandler.set(cfg, STR_EXTENSION_CONFIG, extCfg);
2141
- extCfg = cfg[STR_EXTENSION_CONFIG ];
2142
- if (extCfg) {
2143
- idCfg = extCfg[identifier];
2144
- if (!idCfg && createIfMissing) {
2145
- idCfg = {};
2146
- }
2147
- dynamicHandler.set(extCfg, identifier, idCfg);
2148
- idCfg = extCfg[identifier];
1975
+ if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
1976
+ cookieEnabled = !rootConfig[strDisableCookiesUsage];
2149
1977
  }
1978
+ isEnabled = cookieEnabled;
2150
1979
  }
2151
- return idCfg;
2152
- }
2153
- function _resolveExtCfg(identifier, defaultValues) {
2154
- var newConfig = _getExtCfg(identifier, true);
2155
- if (defaultValues) {
2156
- objForEachKey(defaultValues, function (field, defaultValue) {
2157
- if (isNullOrUndefined(newConfig[field])) {
2158
- var cfgValue = dynamicHandler.cfg[field];
2159
- if (cfgValue || !isNullOrUndefined(cfgValue)) {
2160
- newConfig[field] = cfgValue;
1980
+ _path = cookieMgrConfig[STR_PATH ] || "/";
1981
+ _domain = cookieMgrConfig[STR_DOMAIN ];
1982
+ _enabled = isEnabled !== false;
1983
+ _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;
1984
+ _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
1985
+ _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;
1986
+ }, logger);
1987
+ var cookieMgr = {
1988
+ isEnabled: function () {
1989
+ var enabled = _enabled && areCookiesSupported(logger);
1990
+ var gblManager = _globalCookieConfig[strConfigCookieMgr];
1991
+ if (enabled && gblManager && cookieMgr !== gblManager) {
1992
+ enabled = _isMgrEnabled(gblManager);
1993
+ }
1994
+ return enabled;
1995
+ },
1996
+ setEnabled: function (value) {
1997
+ _enabled = value !== false;
1998
+ },
1999
+ set: function (name, value, maxAgeSec, domain, path) {
2000
+ var result = false;
2001
+ if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {
2002
+ var values = {};
2003
+ var theValue = strTrim(value || STR_EMPTY);
2004
+ var idx = strIndexOf(theValue, ";");
2005
+ if (idx !== -1) {
2006
+ theValue = strTrim(strLeft(value, idx));
2007
+ values = _extractParts(strSubstring(value, idx + 1));
2008
+ }
2009
+ setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
2010
+ if (!isNullOrUndefined(maxAgeSec)) {
2011
+ var _isIE = isIE();
2012
+ if (isUndefined(values[strExpires])) {
2013
+ var nowMs = utcNow();
2014
+ var expireMs = nowMs + (maxAgeSec * 1000);
2015
+ if (expireMs > 0) {
2016
+ var expiry = new Date();
2017
+ expiry.setTime(expireMs);
2018
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
2019
+ }
2020
+ }
2021
+ if (!_isIE) {
2022
+ setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
2161
2023
  }
2162
2024
  }
2163
- _applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
2164
- });
2025
+ var location_1 = getLocation();
2026
+ if (location_1 && location_1.protocol === "https:") {
2027
+ setValue(values, "secure", null, null, isUndefined);
2028
+ if (_allowUaSameSite === null) {
2029
+ _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT ]);
2030
+ }
2031
+ if (_allowUaSameSite) {
2032
+ setValue(values, "SameSite", "None", null, isUndefined);
2033
+ }
2034
+ }
2035
+ setValue(values, STR_PATH, path || _path, null, isUndefined);
2036
+ _setCookieFn(name, _formatCookieValue(theValue, values));
2037
+ result = true;
2038
+ }
2039
+ return result;
2040
+ },
2041
+ get: function (name) {
2042
+ var value = STR_EMPTY;
2043
+ if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {
2044
+ value = _getCookieFn(name);
2045
+ }
2046
+ return value;
2047
+ },
2048
+ del: function (name, path) {
2049
+ var result = false;
2050
+ if (_isMgrEnabled(cookieMgr)) {
2051
+ result = cookieMgr.purge(name, path);
2052
+ }
2053
+ return result;
2054
+ },
2055
+ purge: function (name, path) {
2056
+ var _a;
2057
+ var result = false;
2058
+ if (areCookiesSupported(logger)) {
2059
+ var values = (_a = {},
2060
+ _a[STR_PATH] = path ? path : "/",
2061
+ _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
2062
+ _a);
2063
+ if (!isIE()) {
2064
+ values["max-age"] = "0";
2065
+ }
2066
+ _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));
2067
+ result = true;
2068
+ }
2069
+ return result;
2165
2070
  }
2166
- return dynamicHandler[_DYN_SET_DF ](newConfig, defaultValues);
2167
- }
2168
- function _getConfig(identifier, field, defaultValue) {
2169
- if (defaultValue === void 0) { defaultValue = false; }
2170
- var theValue;
2171
- var extConfig = _getExtCfg(identifier, false);
2172
- var rootConfig = dynamicHandler.cfg;
2173
- if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
2174
- theValue = extConfig[field];
2071
+ };
2072
+ cookieMgr[strConfigCookieMgr] = cookieMgr;
2073
+ return cookieMgr;
2074
+ }
2075
+ function areCookiesSupported(logger) {
2076
+ if (_supportsCookies === null) {
2077
+ _supportsCookies = false;
2078
+ try {
2079
+ var doc = _doc || {};
2080
+ _supportsCookies = doc[strCookie] !== undefined;
2175
2081
  }
2176
- else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
2177
- theValue = rootConfig[field];
2082
+ catch (e) {
2083
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2178
2084
  }
2179
- return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
2180
2085
  }
2181
- function _iterateChain(cb) {
2182
- var nextPlugin;
2183
- while (!!(nextPlugin = context._next())) {
2184
- var plugin = nextPlugin[_DYN_GET_PLUGIN ]();
2185
- if (plugin) {
2186
- cb(plugin);
2086
+ return _supportsCookies;
2087
+ }
2088
+ function _extractParts(theValue) {
2089
+ var values = {};
2090
+ if (theValue && theValue[_DYN_LENGTH$2 ]) {
2091
+ var parts = strTrim(theValue)[_DYN_SPLIT ](";");
2092
+ arrForEach(parts, function (thePart) {
2093
+ thePart = strTrim(thePart || STR_EMPTY);
2094
+ if (thePart) {
2095
+ var idx = strIndexOf(thePart, "=");
2096
+ if (idx === -1) {
2097
+ values[thePart] = null;
2098
+ }
2099
+ else {
2100
+ values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));
2101
+ }
2187
2102
  }
2188
- }
2103
+ });
2189
2104
  }
2190
- return context;
2105
+ return values;
2191
2106
  }
2192
- function createProcessTelemetryContext(telemetryChain, cfg, core, startAt) {
2193
- var config = createDynamicConfig(cfg);
2194
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2195
- var context = internalContext.ctx;
2196
- function _processNext(env) {
2197
- var nextPlugin = internalContext._next();
2198
- if (nextPlugin) {
2199
- nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
2200
- }
2201
- return !nextPlugin;
2107
+ function _formatDate(theDate, func) {
2108
+ if (isFunction(theDate[func])) {
2109
+ return theDate[func]();
2202
2110
  }
2203
- function _createNew(plugins, startAt) {
2204
- if (plugins === void 0) { plugins = null; }
2205
- if (isArray(plugins)) {
2206
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2111
+ return null;
2112
+ }
2113
+ function _formatCookieValue(value, values) {
2114
+ var cookieValue = value || STR_EMPTY;
2115
+ objForEachKey(values, function (name, theValue) {
2116
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
2117
+ });
2118
+ return cookieValue;
2119
+ }
2120
+ function _getCookieValue(name) {
2121
+ var cookieValue = STR_EMPTY;
2122
+ if (_doc) {
2123
+ var theCookie = _doc[strCookie] || STR_EMPTY;
2124
+ if (_parsedCookieValue !== theCookie) {
2125
+ _cookieCache = _extractParts(theCookie);
2126
+ _parsedCookieValue = theCookie;
2207
2127
  }
2208
- return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config.cfg, core, startAt);
2128
+ cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
2209
2129
  }
2210
- context[_DYN_PROCESS_NEXT ] = _processNext;
2211
- context[_DYN_CREATE_NEW ] = _createNew;
2212
- return context;
2130
+ return cookieValue;
2213
2131
  }
2214
- function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
2215
- var config = createDynamicConfig(core[_DYN_CONFIG ]);
2216
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2217
- var context = internalContext.ctx;
2218
- function _processNext(unloadState) {
2219
- var nextPlugin = internalContext._next();
2220
- nextPlugin && nextPlugin.unload(context, unloadState);
2221
- return !nextPlugin;
2222
- }
2223
- function _createNew(plugins, startAt) {
2224
- if (plugins === void 0) { plugins = null; }
2225
- if (isArray(plugins)) {
2226
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2227
- }
2228
- return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2132
+ function _setCookieValue(name, cookieValue) {
2133
+ if (_doc) {
2134
+ _doc[strCookie] = name + "=" + cookieValue;
2229
2135
  }
2230
- context[_DYN_PROCESS_NEXT ] = _processNext;
2231
- context[_DYN_CREATE_NEW ] = _createNew;
2232
- return context;
2233
2136
  }
2234
- function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
2235
- var config = createDynamicConfig(core[_DYN_CONFIG ]);
2236
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2237
- var context = internalContext.ctx;
2238
- function _processNext(updateState) {
2239
- return context.iterate(function (plugin) {
2240
- if (isFunction(plugin[_DYN_UPDATE$1 ])) {
2241
- plugin[_DYN_UPDATE$1 ](context, updateState);
2242
- }
2243
- });
2137
+ function uaDisallowsSameSiteNone(userAgent) {
2138
+ if (!isString(userAgent)) {
2139
+ return false;
2244
2140
  }
2245
- function _createNew(plugins, startAt) {
2246
- if (plugins === void 0) { plugins = null; }
2247
- if (isArray(plugins)) {
2248
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2249
- }
2250
- return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2141
+ if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
2142
+ return true;
2251
2143
  }
2252
- context[_DYN_PROCESS_NEXT ] = _processNext;
2253
- context[_DYN_CREATE_NEW ] = _createNew;
2254
- return context;
2255
- }
2256
- function createTelemetryProxyChain(plugins, config, core, startAt) {
2257
- var firstProxy = null;
2258
- var add = startAt ? false : true;
2259
- if (isArray(plugins) && plugins[_DYN_LENGTH$2 ] > 0) {
2260
- var lastProxy_1 = null;
2261
- arrForEach(plugins, function (thePlugin) {
2262
- if (!add && startAt === thePlugin) {
2263
- add = true;
2264
- }
2265
- if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY ])) {
2266
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
2267
- if (!firstProxy) {
2268
- firstProxy = newProxy;
2269
- }
2270
- if (lastProxy_1) {
2271
- lastProxy_1._setNext(newProxy);
2272
- }
2273
- lastProxy_1 = newProxy;
2274
- }
2275
- });
2144
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
2145
+ return true;
2276
2146
  }
2277
- if (startAt && !firstProxy) {
2278
- return createTelemetryProxyChain([startAt], config, core);
2147
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
2148
+ return true;
2279
2149
  }
2280
- return firstProxy;
2281
- }
2282
- function createTelemetryPluginProxy(plugin, config, core) {
2283
- var nextProxy = null;
2284
- var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY ]);
2285
- var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN ]);
2286
- var chainId;
2287
- if (plugin) {
2288
- chainId = plugin[_DYN_IDENTIFIER ] + "-" + plugin[STR_PRIORITY ] + "-" + _chainId++;
2150
+ if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
2151
+ return true;
2289
2152
  }
2290
- else {
2291
- chainId = "Unknown-0-" + _chainId++;
2153
+ if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
2154
+ return true;
2292
2155
  }
2293
- var proxyChain = {
2294
- getPlugin: function () {
2295
- return plugin;
2296
- },
2297
- getNext: function () {
2298
- return nextProxy;
2299
- },
2300
- processTelemetry: _processTelemetry,
2301
- unload: _unloadPlugin,
2302
- update: _updatePlugin,
2303
- _id: chainId,
2304
- _setNext: function (nextPlugin) {
2305
- nextProxy = nextPlugin;
2306
- }
2307
- };
2308
- function _getTelCtx() {
2309
- var itemCtx;
2310
- if (plugin && isFunction(plugin[strGetTelCtx])) {
2311
- itemCtx = plugin[strGetTelCtx]();
2312
- }
2313
- if (!itemCtx) {
2314
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
2315
- }
2316
- return itemCtx;
2156
+ if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
2157
+ return true;
2317
2158
  }
2318
- function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
2319
- var hasRun = false;
2320
- var identifier = plugin ? plugin[_DYN_IDENTIFIER ] : strTelemetryPluginChain;
2321
- var hasRunContext = itemCtx[strHasRunFlags];
2322
- if (!hasRunContext) {
2323
- hasRunContext = itemCtx[strHasRunFlags] = {};
2324
- }
2325
- itemCtx.setNext(nextProxy);
2326
- if (plugin) {
2327
- doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
2328
- hasRunContext[chainId] = true;
2329
- try {
2330
- var nextId = nextProxy ? nextProxy._id : STR_EMPTY;
2331
- if (nextId) {
2332
- hasRunContext[nextId] = false;
2333
- }
2334
- hasRun = processPluginFn(itemCtx);
2335
- }
2336
- catch (error) {
2337
- var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
2338
- if (hasNextRun) {
2339
- hasRun = true;
2340
- }
2341
- if (!nextProxy || !hasNextRun) {
2342
- _throwInternal(itemCtx[_DYN_DIAG_LOG ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
2343
- }
2159
+ return false;
2160
+ }
2161
+
2162
+ var strExecutionContextKey = "ctx";
2163
+ var strParentContextKey = "ParentContextKey";
2164
+ var strChildrenContextKey = "ChildrenContextKey";
2165
+ var PerfEvent = /** @class */ (function () {
2166
+ function PerfEvent(name, payloadDetails, isAsync) {
2167
+ var _self = this;
2168
+ _self.start = utcNow();
2169
+ _self[_DYN_NAME$1 ] = name;
2170
+ _self[_DYN_IS_ASYNC ] = isAsync;
2171
+ _self[_DYN_IS_CHILD_EVT ] = function () { return false; };
2172
+ if (isFunction(payloadDetails)) {
2173
+ var theDetails_1;
2174
+ objDefineAccessors(_self, "payload", function () {
2175
+ if (!theDetails_1 && isFunction(payloadDetails)) {
2176
+ theDetails_1 = payloadDetails();
2177
+ payloadDetails = null;
2344
2178
  }
2345
- }, details, isAsync);
2179
+ return theDetails_1;
2180
+ });
2346
2181
  }
2347
- return hasRun;
2348
- }
2349
- function _processTelemetry(env, itemCtx) {
2350
- itemCtx = itemCtx || _getTelCtx();
2351
- function _callProcessTelemetry(itemCtx) {
2352
- if (!plugin || !hasProcessTelemetry) {
2353
- return false;
2354
- }
2355
- var pluginState = _getPluginState(plugin);
2356
- if (pluginState[_DYN_TEARDOWN ] || pluginState[STR_DISABLED]) {
2357
- return false;
2182
+ _self[_DYN_GET_CTX ] = function (key) {
2183
+ if (key) {
2184
+ if (key === PerfEvent[strParentContextKey] || key === PerfEvent[strChildrenContextKey]) {
2185
+ return _self[key];
2186
+ }
2187
+ return (_self[strExecutionContextKey] || {})[key];
2358
2188
  }
2359
- if (hasSetNext) {
2360
- plugin[_DYN_SET_NEXT_PLUGIN ](nextProxy);
2189
+ return null;
2190
+ };
2191
+ _self[_DYN_SET_CTX ] = function (key, value) {
2192
+ if (key) {
2193
+ if (key === PerfEvent[strParentContextKey]) {
2194
+ if (!_self[key]) {
2195
+ _self[_DYN_IS_CHILD_EVT ] = function () { return true; };
2196
+ }
2197
+ _self[key] = value;
2198
+ }
2199
+ else if (key === PerfEvent[strChildrenContextKey]) {
2200
+ _self[key] = value;
2201
+ }
2202
+ else {
2203
+ var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
2204
+ ctx[key] = value;
2205
+ }
2361
2206
  }
2362
- plugin[STR_PROCESS_TELEMETRY ](env, itemCtx);
2363
- return true;
2364
- }
2365
- if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
2366
- itemCtx[_DYN_PROCESS_NEXT ](env);
2367
- }
2368
- }
2369
- function _unloadPlugin(unloadCtx, unloadState) {
2370
- function _callTeardown() {
2371
- var hasRun = false;
2372
- if (plugin) {
2373
- var pluginState = _getPluginState(plugin);
2374
- var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2375
- if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2376
- pluginState[STR_CORE ] = null;
2377
- pluginState[_DYN_TEARDOWN ] = true;
2378
- pluginState[_DYN_IS_INITIALIZED ] = false;
2379
- if (plugin[_DYN_TEARDOWN ] && plugin[_DYN_TEARDOWN ](unloadCtx, unloadState) === true) {
2380
- hasRun = true;
2207
+ };
2208
+ _self[_DYN_COMPLETE ] = function () {
2209
+ var childTime = 0;
2210
+ var childEvts = _self[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2211
+ if (isArray(childEvts)) {
2212
+ for (var lp = 0; lp < childEvts[_DYN_LENGTH$2 ]; lp++) {
2213
+ var childEvt = childEvts[lp];
2214
+ if (childEvt) {
2215
+ childTime += childEvt[_DYN_TIME ];
2381
2216
  }
2382
2217
  }
2383
2218
  }
2384
- return hasRun;
2385
- }
2386
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState[_DYN_IS_ASYNC ])) {
2387
- unloadCtx[_DYN_PROCESS_NEXT ](unloadState);
2388
- }
2219
+ _self[_DYN_TIME ] = utcNow() - _self.start;
2220
+ _self.exTime = _self[_DYN_TIME ] - childTime;
2221
+ _self[_DYN_COMPLETE ] = function () { };
2222
+ };
2389
2223
  }
2390
- function _updatePlugin(updateCtx, updateState) {
2391
- function _callUpdate() {
2392
- var hasRun = false;
2393
- if (plugin) {
2394
- var pluginState = _getPluginState(plugin);
2395
- var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2396
- if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2397
- if (plugin[_DYN_UPDATE$1 ] && plugin[_DYN_UPDATE$1 ](updateCtx, updateState) === true) {
2398
- hasRun = true;
2224
+ PerfEvent.ParentContextKey = "parent";
2225
+ PerfEvent.ChildrenContextKey = "childEvts";
2226
+ return PerfEvent;
2227
+ }());
2228
+ var doPerfActiveKey = "CoreUtils.doPerf";
2229
+ function doPerf(mgrSource, getSource, func, details, isAsync) {
2230
+ if (mgrSource) {
2231
+ var perfMgr = mgrSource;
2232
+ if (perfMgr[STR_GET_PERF_MGR]) {
2233
+ perfMgr = perfMgr[STR_GET_PERF_MGR]();
2234
+ }
2235
+ if (perfMgr) {
2236
+ var perfEvt = void 0;
2237
+ var currentActive = perfMgr[_DYN_GET_CTX ](doPerfActiveKey);
2238
+ try {
2239
+ perfEvt = perfMgr.create(getSource(), details, isAsync);
2240
+ if (perfEvt) {
2241
+ if (currentActive && perfEvt[_DYN_SET_CTX ]) {
2242
+ perfEvt[_DYN_SET_CTX ](PerfEvent[strParentContextKey], currentActive);
2243
+ if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
2244
+ var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2245
+ if (!children) {
2246
+ children = [];
2247
+ currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
2248
+ }
2249
+ children[_DYN_PUSH ](perfEvt);
2250
+ }
2399
2251
  }
2252
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
2253
+ return func(perfEvt);
2400
2254
  }
2401
2255
  }
2402
- return hasRun;
2403
- }
2404
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2405
- updateCtx[_DYN_PROCESS_NEXT ](updateState);
2256
+ catch (ex) {
2257
+ if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
2258
+ perfEvt[_DYN_SET_CTX ]("exception", ex);
2259
+ }
2260
+ }
2261
+ finally {
2262
+ if (perfEvt) {
2263
+ perfMgr.fire(perfEvt);
2264
+ }
2265
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
2266
+ }
2406
2267
  }
2407
2268
  }
2408
- return objFreeze(proxyChain);
2269
+ return func();
2409
2270
  }
2410
2271
 
2411
- var _a$2, _b;
2412
- var strToGMTString = "toGMTString";
2413
- var strToUTCString = "toUTCString";
2414
- var strCookie = "cookie";
2415
- var strExpires = "expires";
2416
- var strIsCookieUseDisabled = "isCookieUseDisabled";
2417
- var strDisableCookiesUsage = "disableCookiesUsage";
2418
- var strConfigCookieMgr = "_ckMgr";
2419
- var _supportsCookies = null;
2420
- var _allowUaSameSite = null;
2421
- var _parsedCookieValue = null;
2422
- var _doc = getDocument();
2423
- var _cookieCache = {};
2424
- var _globalCookieConfig = {};
2425
- var defaultConfig = objDeepFreeze((_a$2 = {},
2426
- _a$2[STR_DOMAIN] = { fb: "cookieDomain", dfVal: isNotNullOrUndefined },
2427
- _a$2.path = { fb: "cookiePath", dfVal: isNotNullOrUndefined },
2428
- _a$2.enabled = UNDEFINED_VALUE,
2429
- _a$2));
2430
- var rootDefaultConfig = (_b = {
2431
- cookieCfg: {},
2432
- cookieDomain: UNDEFINED_VALUE,
2433
- cookiePath: UNDEFINED_VALUE
2434
- },
2435
- _b[strDisableCookiesUsage] = UNDEFINED_VALUE,
2436
- _b);
2437
- function _gblCookieMgr(config, logger) {
2438
- var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];
2439
- if (!inst) {
2440
- inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);
2441
- _globalCookieConfig[strConfigCookieMgr] = inst;
2442
- }
2443
- return inst;
2444
- }
2445
- function _isMgrEnabled(cookieMgr) {
2446
- if (cookieMgr) {
2447
- return cookieMgr.isEnabled();
2272
+ function generateW3CId() {
2273
+ var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
2274
+ var oct = STR_EMPTY, tmp;
2275
+ for (var a = 0; a < 4; a++) {
2276
+ tmp = random32();
2277
+ oct +=
2278
+ hexValues[tmp & 0xF] +
2279
+ hexValues[tmp >> 4 & 0xF] +
2280
+ hexValues[tmp >> 8 & 0xF] +
2281
+ hexValues[tmp >> 12 & 0xF] +
2282
+ hexValues[tmp >> 16 & 0xF] +
2283
+ hexValues[tmp >> 20 & 0xF] +
2284
+ hexValues[tmp >> 24 & 0xF] +
2285
+ hexValues[tmp >> 28 & 0xF];
2448
2286
  }
2449
- return true;
2287
+ var clockSequenceHi = hexValues[8 + (random32() & 0x03) | 0];
2288
+ return strSubstr(oct, 0, 8) + strSubstr(oct, 9, 4) + "4" + strSubstr(oct, 13, 3) + clockSequenceHi + strSubstr(oct, 16, 3) + strSubstr(oct, 19, 12);
2450
2289
  }
2451
- function _isIgnoredCookie(cookieMgrCfg, name) {
2452
- if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {
2453
- return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;
2290
+
2291
+ var INVALID_TRACE_ID = "00000000000000000000000000000000";
2292
+ var INVALID_SPAN_ID = "0000000000000000";
2293
+ function _isValid(value, len, invalidValue) {
2294
+ if (value && value[_DYN_LENGTH$2 ] === len && value !== invalidValue) {
2295
+ return !!value.match(/^[\da-f]*$/i);
2454
2296
  }
2455
2297
  return false;
2456
2298
  }
2457
- function _isBlockedCookie(cookieMgrCfg, name) {
2458
- if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {
2459
- if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {
2460
- return true;
2299
+ function isValidTraceId(value) {
2300
+ return _isValid(value, 32, INVALID_TRACE_ID);
2301
+ }
2302
+ function isValidSpanId(value) {
2303
+ return _isValid(value, 16, INVALID_SPAN_ID);
2304
+ }
2305
+
2306
+ var pluginStateData = createElmNodeData("plugin");
2307
+ function _getPluginState(plugin) {
2308
+ return pluginStateData.get(plugin, "state", {}, true);
2309
+ }
2310
+
2311
+ var strTelemetryPluginChain = "TelemetryPluginChain";
2312
+ var strHasRunFlags = "_hasRun";
2313
+ var strGetTelCtx = "_getTelCtx";
2314
+ var _chainId = 0;
2315
+ function _getNextProxyStart(proxy, core, startAt) {
2316
+ while (proxy) {
2317
+ if (proxy[_DYN_GET_PLUGIN ]() === startAt) {
2318
+ return proxy;
2461
2319
  }
2320
+ proxy = proxy[_DYN_GET_NEXT ]();
2462
2321
  }
2463
- return _isIgnoredCookie(cookieMgrCfg, name);
2322
+ return createTelemetryProxyChain([startAt], core.config || {}, core);
2464
2323
  }
2465
- function safeGetCookieMgr(core, config) {
2466
- var cookieMgr;
2467
- if (core) {
2468
- cookieMgr = core.getCookieMgr();
2324
+ function _createInternalContext(telemetryChain, dynamicHandler, core, startAt) {
2325
+ var _nextProxy = null;
2326
+ var _onComplete = [];
2327
+ if (!dynamicHandler) {
2328
+ dynamicHandler = createDynamicConfig({}, null, core[_DYN_LOGGER ]);
2469
2329
  }
2470
- else if (config) {
2471
- var cookieCfg = config.cookieCfg;
2472
- if (cookieCfg && cookieCfg[strConfigCookieMgr]) {
2473
- cookieMgr = cookieCfg[strConfigCookieMgr];
2330
+ if (startAt !== null) {
2331
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
2332
+ }
2333
+ var context = {
2334
+ _next: _moveNext,
2335
+ ctx: {
2336
+ core: function () {
2337
+ return core;
2338
+ },
2339
+ diagLog: function () {
2340
+ return safeGetLogger(core, dynamicHandler.cfg);
2341
+ },
2342
+ getCfg: function () {
2343
+ return dynamicHandler.cfg;
2344
+ },
2345
+ getExtCfg: _resolveExtCfg,
2346
+ getConfig: _getConfig,
2347
+ hasNext: function () {
2348
+ return !!_nextProxy;
2349
+ },
2350
+ getNext: function () {
2351
+ return _nextProxy;
2352
+ },
2353
+ setNext: function (nextPlugin) {
2354
+ _nextProxy = nextPlugin;
2355
+ },
2356
+ iterate: _iterateChain,
2357
+ onComplete: _addOnComplete
2474
2358
  }
2475
- else {
2476
- cookieMgr = createCookieMgr(config);
2359
+ };
2360
+ function _addOnComplete(onComplete, that) {
2361
+ var args = [];
2362
+ for (var _i = 2; _i < arguments.length; _i++) {
2363
+ args[_i - 2] = arguments[_i];
2477
2364
  }
2478
- }
2479
- if (!cookieMgr) {
2480
- cookieMgr = _gblCookieMgr(config, (core || {})[_DYN_LOGGER ]);
2481
- }
2482
- return cookieMgr;
2483
- }
2484
- function createCookieMgr(rootConfig, logger) {
2485
- var cookieMgrConfig;
2486
- var _path;
2487
- var _domain;
2488
- var _enabled;
2489
- var _getCookieFn;
2490
- var _setCookieFn;
2491
- var _delCookieFn;
2492
- rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;
2493
- onConfigChange(rootConfig, function (details) {
2494
- details[_DYN_SET_DF ](details.cfg, rootDefaultConfig);
2495
- cookieMgrConfig = details[_DYN_SET_DF ](details.cfg.cookieCfg, defaultConfig);
2496
- var isEnabled = cookieMgrConfig.enabled;
2497
- if (isNullOrUndefined(isEnabled)) {
2498
- var cookieEnabled = void 0;
2499
- if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
2500
- cookieEnabled = !rootConfig[strIsCookieUseDisabled];
2501
- }
2502
- if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
2503
- cookieEnabled = !rootConfig[strDisableCookiesUsage];
2504
- }
2505
- isEnabled = cookieEnabled;
2365
+ if (onComplete) {
2366
+ _onComplete[_DYN_PUSH ]({
2367
+ func: onComplete,
2368
+ self: !isUndefined(that) ? that : context.ctx,
2369
+ args: args
2370
+ });
2506
2371
  }
2507
- _path = cookieMgrConfig[STR_PATH ] || "/";
2508
- _domain = cookieMgrConfig[STR_DOMAIN ];
2509
- _enabled = isEnabled !== false;
2510
- _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;
2511
- _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
2512
- _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;
2513
- }, logger);
2514
- var cookieMgr = {
2515
- isEnabled: function () {
2516
- var enabled = _enabled && areCookiesSupported(logger);
2517
- var gblManager = _globalCookieConfig[strConfigCookieMgr];
2518
- if (enabled && gblManager && cookieMgr !== gblManager) {
2519
- enabled = _isMgrEnabled(gblManager);
2520
- }
2521
- return enabled;
2522
- },
2523
- setEnabled: function (value) {
2524
- _enabled = value !== false;
2525
- },
2526
- set: function (name, value, maxAgeSec, domain, path) {
2527
- var result = false;
2528
- if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {
2529
- var values = {};
2530
- var theValue = strTrim(value || STR_EMPTY);
2531
- var idx = strIndexOf(theValue, ";");
2532
- if (idx !== -1) {
2533
- theValue = strTrim(strLeft(value, idx));
2534
- values = _extractParts(strSubstring(value, idx + 1));
2535
- }
2536
- setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
2537
- if (!isNullOrUndefined(maxAgeSec)) {
2538
- var _isIE = isIE();
2539
- if (isUndefined(values[strExpires])) {
2540
- var nowMs = utcNow();
2541
- var expireMs = nowMs + (maxAgeSec * 1000);
2542
- if (expireMs > 0) {
2543
- var expiry = new Date();
2544
- expiry.setTime(expireMs);
2545
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
2546
- }
2547
- }
2548
- if (!_isIE) {
2549
- setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
2550
- }
2551
- }
2552
- var location_1 = getLocation();
2553
- if (location_1 && location_1.protocol === "https:") {
2554
- setValue(values, "secure", null, null, isUndefined);
2555
- if (_allowUaSameSite === null) {
2556
- _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT ]);
2372
+ }
2373
+ function _moveNext() {
2374
+ var nextProxy = _nextProxy;
2375
+ _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT ]() : null;
2376
+ if (!nextProxy) {
2377
+ var onComplete = _onComplete;
2378
+ if (onComplete && onComplete[_DYN_LENGTH$2 ] > 0) {
2379
+ arrForEach(onComplete, function (completeDetails) {
2380
+ try {
2381
+ completeDetails.func[_DYN_CALL ](completeDetails.self, completeDetails.args);
2557
2382
  }
2558
- if (_allowUaSameSite) {
2559
- setValue(values, "SameSite", "None", null, isUndefined);
2383
+ catch (e) {
2384
+ _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
2560
2385
  }
2561
- }
2562
- setValue(values, STR_PATH, path || _path, null, isUndefined);
2563
- _setCookieFn(name, _formatCookieValue(theValue, values));
2564
- result = true;
2386
+ });
2387
+ _onComplete = [];
2565
2388
  }
2566
- return result;
2567
- },
2568
- get: function (name) {
2569
- var value = STR_EMPTY;
2570
- if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {
2571
- value = _getCookieFn(name);
2389
+ }
2390
+ return nextProxy;
2391
+ }
2392
+ function _getExtCfg(identifier, createIfMissing) {
2393
+ var idCfg = null;
2394
+ var cfg = dynamicHandler.cfg;
2395
+ if (cfg && identifier) {
2396
+ var extCfg = cfg[STR_EXTENSION_CONFIG ];
2397
+ if (!extCfg && createIfMissing) {
2398
+ extCfg = {};
2572
2399
  }
2573
- return value;
2574
- },
2575
- del: function (name, path) {
2576
- var result = false;
2577
- if (_isMgrEnabled(cookieMgr)) {
2578
- result = cookieMgr.purge(name, path);
2400
+ dynamicHandler.set(cfg, STR_EXTENSION_CONFIG, extCfg);
2401
+ extCfg = cfg[STR_EXTENSION_CONFIG ];
2402
+ if (extCfg) {
2403
+ idCfg = extCfg[identifier];
2404
+ if (!idCfg && createIfMissing) {
2405
+ idCfg = {};
2406
+ }
2407
+ dynamicHandler.set(extCfg, identifier, idCfg);
2408
+ idCfg = extCfg[identifier];
2579
2409
  }
2580
- return result;
2581
- },
2582
- purge: function (name, path) {
2583
- var _a;
2584
- var result = false;
2585
- if (areCookiesSupported(logger)) {
2586
- var values = (_a = {},
2587
- _a[STR_PATH] = path ? path : "/",
2588
- _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
2589
- _a);
2590
- if (!isIE()) {
2591
- values["max-age"] = "0";
2410
+ }
2411
+ return idCfg;
2412
+ }
2413
+ function _resolveExtCfg(identifier, defaultValues) {
2414
+ var newConfig = _getExtCfg(identifier, true);
2415
+ if (defaultValues) {
2416
+ objForEachKey(defaultValues, function (field, defaultValue) {
2417
+ if (isNullOrUndefined(newConfig[field])) {
2418
+ var cfgValue = dynamicHandler.cfg[field];
2419
+ if (cfgValue || !isNullOrUndefined(cfgValue)) {
2420
+ newConfig[field] = cfgValue;
2421
+ }
2592
2422
  }
2593
- _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));
2594
- result = true;
2423
+ _applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
2424
+ });
2425
+ }
2426
+ return dynamicHandler[_DYN_SET_DF ](newConfig, defaultValues);
2427
+ }
2428
+ function _getConfig(identifier, field, defaultValue) {
2429
+ if (defaultValue === void 0) { defaultValue = false; }
2430
+ var theValue;
2431
+ var extConfig = _getExtCfg(identifier, false);
2432
+ var rootConfig = dynamicHandler.cfg;
2433
+ if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
2434
+ theValue = extConfig[field];
2435
+ }
2436
+ else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
2437
+ theValue = rootConfig[field];
2438
+ }
2439
+ return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
2440
+ }
2441
+ function _iterateChain(cb) {
2442
+ var nextPlugin;
2443
+ while (!!(nextPlugin = context._next())) {
2444
+ var plugin = nextPlugin[_DYN_GET_PLUGIN ]();
2445
+ if (plugin) {
2446
+ cb(plugin);
2595
2447
  }
2596
- return result;
2597
2448
  }
2598
- };
2599
- cookieMgr[strConfigCookieMgr] = cookieMgr;
2600
- return cookieMgr;
2449
+ }
2450
+ return context;
2451
+ }
2452
+ function createProcessTelemetryContext(telemetryChain, cfg, core, startAt) {
2453
+ var config = createDynamicConfig(cfg);
2454
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2455
+ var context = internalContext.ctx;
2456
+ function _processNext(env) {
2457
+ var nextPlugin = internalContext._next();
2458
+ if (nextPlugin) {
2459
+ nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
2460
+ }
2461
+ return !nextPlugin;
2462
+ }
2463
+ function _createNew(plugins, startAt) {
2464
+ if (plugins === void 0) { plugins = null; }
2465
+ if (isArray(plugins)) {
2466
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2467
+ }
2468
+ return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config.cfg, core, startAt);
2469
+ }
2470
+ context[_DYN_PROCESS_NEXT ] = _processNext;
2471
+ context[_DYN_CREATE_NEW ] = _createNew;
2472
+ return context;
2601
2473
  }
2602
- function areCookiesSupported(logger) {
2603
- if (_supportsCookies === null) {
2604
- _supportsCookies = false;
2605
- try {
2606
- var doc = _doc || {};
2607
- _supportsCookies = doc[strCookie] !== undefined;
2608
- }
2609
- catch (e) {
2610
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2474
+ function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
2475
+ var config = createDynamicConfig(core.config);
2476
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2477
+ var context = internalContext.ctx;
2478
+ function _processNext(unloadState) {
2479
+ var nextPlugin = internalContext._next();
2480
+ nextPlugin && nextPlugin.unload(context, unloadState);
2481
+ return !nextPlugin;
2482
+ }
2483
+ function _createNew(plugins, startAt) {
2484
+ if (plugins === void 0) { plugins = null; }
2485
+ if (isArray(plugins)) {
2486
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2611
2487
  }
2488
+ return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2612
2489
  }
2613
- return _supportsCookies;
2490
+ context[_DYN_PROCESS_NEXT ] = _processNext;
2491
+ context[_DYN_CREATE_NEW ] = _createNew;
2492
+ return context;
2614
2493
  }
2615
- function _extractParts(theValue) {
2616
- var values = {};
2617
- if (theValue && theValue[_DYN_LENGTH$2 ]) {
2618
- var parts = strTrim(theValue)[_DYN_SPLIT ](";");
2619
- arrForEach(parts, function (thePart) {
2620
- thePart = strTrim(thePart || STR_EMPTY);
2621
- if (thePart) {
2622
- var idx = strIndexOf(thePart, "=");
2623
- if (idx === -1) {
2624
- values[thePart] = null;
2625
- }
2626
- else {
2627
- values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));
2628
- }
2494
+ function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
2495
+ var config = createDynamicConfig(core.config);
2496
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2497
+ var context = internalContext.ctx;
2498
+ function _processNext(updateState) {
2499
+ return context.iterate(function (plugin) {
2500
+ if (isFunction(plugin[_DYN_UPDATE$1 ])) {
2501
+ plugin[_DYN_UPDATE$1 ](context, updateState);
2629
2502
  }
2630
2503
  });
2631
2504
  }
2632
- return values;
2633
- }
2634
- function _formatDate(theDate, func) {
2635
- if (isFunction(theDate[func])) {
2636
- return theDate[func]();
2637
- }
2638
- return null;
2639
- }
2640
- function _formatCookieValue(value, values) {
2641
- var cookieValue = value || STR_EMPTY;
2642
- objForEachKey(values, function (name, theValue) {
2643
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
2644
- });
2645
- return cookieValue;
2646
- }
2647
- function _getCookieValue(name) {
2648
- var cookieValue = STR_EMPTY;
2649
- if (_doc) {
2650
- var theCookie = _doc[strCookie] || STR_EMPTY;
2651
- if (_parsedCookieValue !== theCookie) {
2652
- _cookieCache = _extractParts(theCookie);
2653
- _parsedCookieValue = theCookie;
2505
+ function _createNew(plugins, startAt) {
2506
+ if (plugins === void 0) { plugins = null; }
2507
+ if (isArray(plugins)) {
2508
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2654
2509
  }
2655
- cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
2510
+ return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2656
2511
  }
2657
- return cookieValue;
2512
+ context[_DYN_PROCESS_NEXT ] = _processNext;
2513
+ context[_DYN_CREATE_NEW ] = _createNew;
2514
+ return context;
2658
2515
  }
2659
- function _setCookieValue(name, cookieValue) {
2660
- if (_doc) {
2661
- _doc[strCookie] = name + "=" + cookieValue;
2516
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
2517
+ var firstProxy = null;
2518
+ var add = startAt ? false : true;
2519
+ if (isArray(plugins) && plugins[_DYN_LENGTH$2 ] > 0) {
2520
+ var lastProxy_1 = null;
2521
+ arrForEach(plugins, function (thePlugin) {
2522
+ if (!add && startAt === thePlugin) {
2523
+ add = true;
2524
+ }
2525
+ if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY ])) {
2526
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
2527
+ if (!firstProxy) {
2528
+ firstProxy = newProxy;
2529
+ }
2530
+ if (lastProxy_1) {
2531
+ lastProxy_1._setNext(newProxy);
2532
+ }
2533
+ lastProxy_1 = newProxy;
2534
+ }
2535
+ });
2662
2536
  }
2537
+ if (startAt && !firstProxy) {
2538
+ return createTelemetryProxyChain([startAt], config, core);
2539
+ }
2540
+ return firstProxy;
2663
2541
  }
2664
- function uaDisallowsSameSiteNone(userAgent) {
2665
- if (!isString(userAgent)) {
2666
- return false;
2542
+ function createTelemetryPluginProxy(plugin, config, core) {
2543
+ var nextProxy = null;
2544
+ var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY ]);
2545
+ var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN ]);
2546
+ var chainId;
2547
+ if (plugin) {
2548
+ chainId = plugin[_DYN_IDENTIFIER ] + "-" + plugin[STR_PRIORITY ] + "-" + _chainId++;
2667
2549
  }
2668
- if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
2669
- return true;
2550
+ else {
2551
+ chainId = "Unknown-0-" + _chainId++;
2670
2552
  }
2671
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
2672
- return true;
2553
+ var proxyChain = {
2554
+ getPlugin: function () {
2555
+ return plugin;
2556
+ },
2557
+ getNext: function () {
2558
+ return nextProxy;
2559
+ },
2560
+ processTelemetry: _processTelemetry,
2561
+ unload: _unloadPlugin,
2562
+ update: _updatePlugin,
2563
+ _id: chainId,
2564
+ _setNext: function (nextPlugin) {
2565
+ nextProxy = nextPlugin;
2566
+ }
2567
+ };
2568
+ function _getTelCtx() {
2569
+ var itemCtx;
2570
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
2571
+ itemCtx = plugin[strGetTelCtx]();
2572
+ }
2573
+ if (!itemCtx) {
2574
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
2575
+ }
2576
+ return itemCtx;
2673
2577
  }
2674
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
2675
- return true;
2578
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
2579
+ var hasRun = false;
2580
+ var identifier = plugin ? plugin[_DYN_IDENTIFIER ] : strTelemetryPluginChain;
2581
+ var hasRunContext = itemCtx[strHasRunFlags];
2582
+ if (!hasRunContext) {
2583
+ hasRunContext = itemCtx[strHasRunFlags] = {};
2584
+ }
2585
+ itemCtx.setNext(nextProxy);
2586
+ if (plugin) {
2587
+ doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
2588
+ hasRunContext[chainId] = true;
2589
+ try {
2590
+ var nextId = nextProxy ? nextProxy._id : STR_EMPTY;
2591
+ if (nextId) {
2592
+ hasRunContext[nextId] = false;
2593
+ }
2594
+ hasRun = processPluginFn(itemCtx);
2595
+ }
2596
+ catch (error) {
2597
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
2598
+ if (hasNextRun) {
2599
+ hasRun = true;
2600
+ }
2601
+ if (!nextProxy || !hasNextRun) {
2602
+ _throwInternal(itemCtx[_DYN_DIAG_LOG ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
2603
+ }
2604
+ }
2605
+ }, details, isAsync);
2606
+ }
2607
+ return hasRun;
2676
2608
  }
2677
- if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
2678
- return true;
2609
+ function _processTelemetry(env, itemCtx) {
2610
+ itemCtx = itemCtx || _getTelCtx();
2611
+ function _callProcessTelemetry(itemCtx) {
2612
+ if (!plugin || !hasProcessTelemetry) {
2613
+ return false;
2614
+ }
2615
+ var pluginState = _getPluginState(plugin);
2616
+ if (pluginState[_DYN_TEARDOWN ] || pluginState[STR_DISABLED]) {
2617
+ return false;
2618
+ }
2619
+ if (hasSetNext) {
2620
+ plugin[_DYN_SET_NEXT_PLUGIN ](nextProxy);
2621
+ }
2622
+ plugin[STR_PROCESS_TELEMETRY ](env, itemCtx);
2623
+ return true;
2624
+ }
2625
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
2626
+ itemCtx[_DYN_PROCESS_NEXT ](env);
2627
+ }
2679
2628
  }
2680
- if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
2681
- return true;
2629
+ function _unloadPlugin(unloadCtx, unloadState) {
2630
+ function _callTeardown() {
2631
+ var hasRun = false;
2632
+ if (plugin) {
2633
+ var pluginState = _getPluginState(plugin);
2634
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2635
+ if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2636
+ pluginState[STR_CORE ] = null;
2637
+ pluginState[_DYN_TEARDOWN ] = true;
2638
+ pluginState[_DYN_IS_INITIALIZED ] = false;
2639
+ if (plugin[_DYN_TEARDOWN ] && plugin[_DYN_TEARDOWN ](unloadCtx, unloadState) === true) {
2640
+ hasRun = true;
2641
+ }
2642
+ }
2643
+ }
2644
+ return hasRun;
2645
+ }
2646
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState[_DYN_IS_ASYNC ])) {
2647
+ unloadCtx[_DYN_PROCESS_NEXT ](unloadState);
2648
+ }
2682
2649
  }
2683
- if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
2684
- return true;
2650
+ function _updatePlugin(updateCtx, updateState) {
2651
+ function _callUpdate() {
2652
+ var hasRun = false;
2653
+ if (plugin) {
2654
+ var pluginState = _getPluginState(plugin);
2655
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2656
+ if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2657
+ if (plugin[_DYN_UPDATE$1 ] && plugin[_DYN_UPDATE$1 ](updateCtx, updateState) === true) {
2658
+ hasRun = true;
2659
+ }
2660
+ }
2661
+ }
2662
+ return hasRun;
2663
+ }
2664
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2665
+ updateCtx[_DYN_PROCESS_NEXT ](updateState);
2666
+ }
2685
2667
  }
2686
- return false;
2668
+ return objFreeze(proxyChain);
2687
2669
  }
2688
2670
 
2689
2671
  function createUnloadHandlerContainer() {