@microsoft/applicationinsights-web-basic 3.0.0-beta.2211-03 → 3.0.0-beta.2211-04

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/aib.2.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2211-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  (function (global, factory) {
@@ -1114,6 +1114,7 @@
1114
1114
  var _DYN_INITIALIZE = "initialize";
1115
1115
  var _DYN_IDENTIFIER = "identifier";
1116
1116
  var _DYN_IS_INITIALIZED = "isInitialized";
1117
+ var _DYN_GET_PLUGIN = "getPlugin";
1117
1118
  var _DYN_POLL_INTERNAL_LOGS = "pollInternalLogs";
1118
1119
  var _DYN_NAME$2 = "name";
1119
1120
  var _DYN_TIME = "time";
@@ -1125,10 +1126,9 @@
1125
1126
  var _DYN_STOP_POLLING_INTERNA3 = "stopPollingInternalLogs";
1126
1127
  var _DYN_ON_COMPLETE = "onComplete";
1127
1128
  var _DYN_CALL = "call";
1128
- var _DYN_GET_PLUGIN = "getPlugin";
1129
- var _DYN_FLUSH = "flush";
1130
1129
  var _DYN_VERSION = "version";
1131
1130
  var _DYN_LOGGING_LEVEL_CONSOL4 = "loggingLevelConsole";
1131
+ var _DYN_CREATE_NEW = "createNew";
1132
1132
  var _DYN_TEARDOWN = "teardown";
1133
1133
  var _DYN_MESSAGE_ID = "messageId";
1134
1134
  var _DYN_MESSAGE$1 = "message";
@@ -1138,8 +1138,6 @@
1138
1138
  var _DYN_UPDATE = "update";
1139
1139
  var _DYN_GET_NEXT = "getNext";
1140
1140
  var _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
1141
- var _DYN_CREATE_NEW = "createNew";
1142
- var _DYN_CONFIG = "config";
1143
1141
  var _DYN_USER_AGENT = "userAgent";
1144
1142
  var _DYN_SPLIT$1 = "split";
1145
1143
  var _DYN_NODE_TYPE = "nodeType";
@@ -1565,7 +1563,7 @@
1565
1563
  }
1566
1564
 
1567
1565
  var _objDefineProperty = ObjDefineProperty;
1568
- var version = "3.0.0-beta.2211-03";
1566
+ var version = "3.0.0-beta.2211-04";
1569
1567
  var instanceName = "." + newId(6);
1570
1568
  var _dataUid = 0;
1571
1569
  function _createAccessor(target, prop, value) {
@@ -2059,6 +2057,8 @@
2059
2057
  createDynamicConfig(config, null, logger)[_DYN_WATCH ](configHandler);
2060
2058
  }
2061
2059
 
2060
+ var ChannelControllerPriority = 500;
2061
+
2062
2062
  var listenerFuncs = [STR_EVENTS_SENT, STR_EVENTS_DISCARDED, STR_EVENTS_SEND_REQUEST, STR_PERF_EVENT];
2063
2063
  var _aiNamespace = null;
2064
2064
  var _debugListener;
@@ -2272,1138 +2272,944 @@
2272
2272
  _getLogger(logger)[STR_WARN_TO_CONSOLE ](message);
2273
2273
  }
2274
2274
 
2275
- var strExecutionContextKey = "ctx";
2276
- var strParentContextKey = "ParentContextKey";
2277
- var strChildrenContextKey = "ChildrenContextKey";
2278
- var _defaultPerfManager = null;
2279
- var PerfEvent = /** @class */ (function () {
2280
- function PerfEvent(name, payloadDetails, isAsync) {
2281
- var _self = this;
2282
- _self.start = utcNow();
2283
- _self[_DYN_NAME$2 ] = name;
2284
- _self[_DYN_IS_ASYNC ] = isAsync;
2285
- _self[_DYN_IS_CHILD_EVT ] = function () { return false; };
2286
- if (isFunction(payloadDetails)) {
2287
- var theDetails_1;
2288
- objDefineAccessors(_self, "payload", function () {
2289
- if (!theDetails_1 && isFunction(payloadDetails)) {
2290
- theDetails_1 = payloadDetails();
2291
- payloadDetails = null;
2292
- }
2293
- return theDetails_1;
2294
- });
2275
+ var _a$3, _b$1;
2276
+ var strToGMTString = "toGMTString";
2277
+ var strToUTCString = "toUTCString";
2278
+ var strCookie = "cookie";
2279
+ var strExpires = "expires";
2280
+ var strIsCookieUseDisabled = "isCookieUseDisabled";
2281
+ var strDisableCookiesUsage = "disableCookiesUsage";
2282
+ var strConfigCookieMgr = "_ckMgr";
2283
+ var _supportsCookies = null;
2284
+ var _allowUaSameSite = null;
2285
+ var _parsedCookieValue = null;
2286
+ var _doc = getDocument();
2287
+ var _cookieCache = {};
2288
+ var _globalCookieConfig = {};
2289
+ var defaultConfig$1 = objDeepFreeze((_a$3 = {},
2290
+ _a$3[STR_DOMAIN] = { fb: "cookieDomain", dfVal: isNotNullOrUndefined },
2291
+ _a$3.path = { fb: "cookiePath", dfVal: isNotNullOrUndefined },
2292
+ _a$3.enabled = UNDEFINED_VALUE$1,
2293
+ _a$3));
2294
+ var rootDefaultConfig = (_b$1 = {
2295
+ cookieCfg: {},
2296
+ cookieDomain: UNDEFINED_VALUE$1,
2297
+ cookiePath: UNDEFINED_VALUE$1
2298
+ },
2299
+ _b$1[strDisableCookiesUsage] = UNDEFINED_VALUE$1,
2300
+ _b$1);
2301
+ function _isMgrEnabled(cookieMgr) {
2302
+ if (cookieMgr) {
2303
+ return cookieMgr.isEnabled();
2304
+ }
2305
+ return true;
2306
+ }
2307
+ function _isIgnoredCookie(cookieMgrCfg, name) {
2308
+ if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {
2309
+ return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;
2310
+ }
2311
+ return false;
2312
+ }
2313
+ function _isBlockedCookie(cookieMgrCfg, name) {
2314
+ if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {
2315
+ if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {
2316
+ return true;
2295
2317
  }
2296
- _self[_DYN_GET_CTX ] = function (key) {
2297
- if (key) {
2298
- if (key === PerfEvent[strParentContextKey] || key === PerfEvent[strChildrenContextKey]) {
2299
- return _self[key];
2300
- }
2301
- return (_self[strExecutionContextKey] || {})[key];
2318
+ }
2319
+ return _isIgnoredCookie(cookieMgrCfg, name);
2320
+ }
2321
+ function createCookieMgr(rootConfig, logger) {
2322
+ var cookieMgrConfig;
2323
+ var _path;
2324
+ var _domain;
2325
+ var _enabled;
2326
+ var _getCookieFn;
2327
+ var _setCookieFn;
2328
+ var _delCookieFn;
2329
+ rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;
2330
+ onConfigChange(rootConfig, function (details) {
2331
+ details[_DYN_SET_DF ](details.cfg, rootDefaultConfig);
2332
+ cookieMgrConfig = details[_DYN_SET_DF ](details.cfg.cookieCfg, defaultConfig$1);
2333
+ var isEnabled = cookieMgrConfig.enabled;
2334
+ if (isNullOrUndefined(isEnabled)) {
2335
+ var cookieEnabled = void 0;
2336
+ if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
2337
+ cookieEnabled = !rootConfig[strIsCookieUseDisabled];
2302
2338
  }
2303
- return null;
2304
- };
2305
- _self[_DYN_SET_CTX ] = function (key, value) {
2306
- if (key) {
2307
- if (key === PerfEvent[strParentContextKey]) {
2308
- if (!_self[key]) {
2309
- _self[_DYN_IS_CHILD_EVT ] = function () { return true; };
2310
- }
2311
- _self[key] = value;
2312
- }
2313
- else if (key === PerfEvent[strChildrenContextKey]) {
2314
- _self[key] = value;
2315
- }
2316
- else {
2317
- var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
2318
- ctx[key] = value;
2319
- }
2339
+ if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
2340
+ cookieEnabled = !rootConfig[strDisableCookiesUsage];
2320
2341
  }
2321
- };
2322
- _self[_DYN_COMPLETE ] = function () {
2323
- var childTime = 0;
2324
- var childEvts = _self[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2325
- if (isArray(childEvts)) {
2326
- for (var lp = 0; lp < childEvts[_DYN_LENGTH$2 ]; lp++) {
2327
- var childEvt = childEvts[lp];
2328
- if (childEvt) {
2329
- childTime += childEvt[_DYN_TIME ];
2330
- }
2331
- }
2342
+ isEnabled = cookieEnabled;
2343
+ }
2344
+ _path = cookieMgrConfig[STR_PATH ] || "/";
2345
+ _domain = cookieMgrConfig[STR_DOMAIN ];
2346
+ _enabled = isEnabled !== false;
2347
+ _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;
2348
+ _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
2349
+ _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;
2350
+ }, logger);
2351
+ var cookieMgr = {
2352
+ isEnabled: function () {
2353
+ var enabled = _enabled && areCookiesSupported(logger);
2354
+ var gblManager = _globalCookieConfig[strConfigCookieMgr];
2355
+ if (enabled && gblManager && cookieMgr !== gblManager) {
2356
+ enabled = _isMgrEnabled(gblManager);
2332
2357
  }
2333
- _self[_DYN_TIME ] = utcNow() - _self.start;
2334
- _self.exTime = _self[_DYN_TIME ] - childTime;
2335
- _self[_DYN_COMPLETE ] = function () { };
2336
- };
2337
- }
2338
- PerfEvent.ParentContextKey = "parent";
2339
- PerfEvent.ChildrenContextKey = "childEvts";
2340
- return PerfEvent;
2341
- }());
2342
- var PerfManager = /** @class */ (function () {
2343
- function PerfManager(manager) {
2344
- this.ctx = {};
2345
- dynamicProto(PerfManager, this, function (_self) {
2346
- _self.create = function (src, payloadDetails, isAsync) {
2347
- return new PerfEvent(src, payloadDetails, isAsync);
2348
- };
2349
- _self.fire = function (perfEvent) {
2350
- if (perfEvent) {
2351
- perfEvent[_DYN_COMPLETE ]();
2352
- if (manager && isFunction(manager[STR_PERF_EVENT ])) {
2353
- manager[STR_PERF_EVENT ](perfEvent);
2354
- }
2355
- }
2356
- };
2357
- _self[_DYN_SET_CTX ] = function (key, value) {
2358
- if (key) {
2359
- var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
2360
- ctx[key] = value;
2358
+ return enabled;
2359
+ },
2360
+ setEnabled: function (value) {
2361
+ _enabled = value !== false;
2362
+ },
2363
+ set: function (name, value, maxAgeSec, domain, path) {
2364
+ var result = false;
2365
+ if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {
2366
+ var values = {};
2367
+ var theValue = strTrim(value || STR_EMPTY);
2368
+ var idx = strIndexOf(theValue, ";");
2369
+ if (idx !== -1) {
2370
+ theValue = strTrim(strLeft(value, idx));
2371
+ values = _extractParts(strSubstring(value, idx + 1));
2361
2372
  }
2362
- };
2363
- _self[_DYN_GET_CTX ] = function (key) {
2364
- return (_self[strExecutionContextKey] || {})[key];
2365
- };
2366
- });
2367
- }
2368
- PerfManager.__ieDyn=1;
2369
- return PerfManager;
2370
- }());
2371
- var doPerfActiveKey = "CoreUtils.doPerf";
2372
- function doPerf(mgrSource, getSource, func, details, isAsync) {
2373
- if (mgrSource) {
2374
- var perfMgr = mgrSource;
2375
- if (perfMgr[STR_GET_PERF_MGR]) {
2376
- perfMgr = perfMgr[STR_GET_PERF_MGR]();
2377
- }
2378
- if (perfMgr) {
2379
- var perfEvt = void 0;
2380
- var currentActive = perfMgr[_DYN_GET_CTX ](doPerfActiveKey);
2381
- try {
2382
- perfEvt = perfMgr.create(getSource(), details, isAsync);
2383
- if (perfEvt) {
2384
- if (currentActive && perfEvt[_DYN_SET_CTX ]) {
2385
- perfEvt[_DYN_SET_CTX ](PerfEvent[strParentContextKey], currentActive);
2386
- if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
2387
- var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2388
- if (!children) {
2389
- children = [];
2390
- currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
2391
- }
2392
- children[_DYN_PUSH$1 ](perfEvt);
2373
+ setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
2374
+ if (!isNullOrUndefined(maxAgeSec)) {
2375
+ var _isIE = isIE();
2376
+ if (isUndefined(values[strExpires])) {
2377
+ var nowMs = utcNow();
2378
+ var expireMs = nowMs + (maxAgeSec * 1000);
2379
+ if (expireMs > 0) {
2380
+ var expiry = new Date();
2381
+ expiry.setTime(expireMs);
2382
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
2393
2383
  }
2394
2384
  }
2395
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
2396
- return func(perfEvt);
2385
+ if (!_isIE) {
2386
+ setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
2387
+ }
2397
2388
  }
2398
- }
2399
- catch (ex) {
2400
- if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
2401
- perfEvt[_DYN_SET_CTX ]("exception", ex);
2389
+ var location_1 = getLocation();
2390
+ if (location_1 && location_1.protocol === "https:") {
2391
+ setValue(values, "secure", null, null, isUndefined);
2392
+ if (_allowUaSameSite === null) {
2393
+ _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT ]);
2394
+ }
2395
+ if (_allowUaSameSite) {
2396
+ setValue(values, "SameSite", "None", null, isUndefined);
2397
+ }
2402
2398
  }
2399
+ setValue(values, STR_PATH, path || _path, null, isUndefined);
2400
+ _setCookieFn(name, _formatCookieValue(theValue, values));
2401
+ result = true;
2403
2402
  }
2404
- finally {
2405
- if (perfEvt) {
2406
- perfMgr.fire(perfEvt);
2407
- }
2408
- perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
2403
+ return result;
2404
+ },
2405
+ get: function (name) {
2406
+ var value = STR_EMPTY;
2407
+ if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {
2408
+ value = _getCookieFn(name);
2409
2409
  }
2410
- }
2411
- }
2412
- return func();
2413
- }
2414
- function getGblPerfMgr() {
2415
- return _defaultPerfManager;
2416
- }
2417
-
2418
- var INVALID_TRACE_ID = "00000000000000000000000000000000";
2419
- var INVALID_SPAN_ID = "0000000000000000";
2420
- function _isValid(value, len, invalidValue) {
2421
- if (value && value[_DYN_LENGTH$2 ] === len && value !== invalidValue) {
2422
- return !!value.match(/^[\da-f]*$/i);
2423
- }
2424
- return false;
2425
- }
2426
- function isValidTraceId(value) {
2427
- return _isValid(value, 32, INVALID_TRACE_ID);
2428
- }
2429
- function isValidSpanId(value) {
2430
- return _isValid(value, 16, INVALID_SPAN_ID);
2431
- }
2432
-
2433
- var pluginStateData = createElmNodeData("plugin");
2434
- function _getPluginState(plugin) {
2435
- return pluginStateData.get(plugin, "state", {}, true);
2436
- }
2437
- function initializePlugins(processContext, extensions) {
2438
- var initPlugins = [];
2439
- var lastPlugin = null;
2440
- var proxy = processContext[_DYN_GET_NEXT ]();
2441
- var pluginState;
2442
- while (proxy) {
2443
- var thePlugin = proxy[_DYN_GET_PLUGIN ]();
2444
- if (thePlugin) {
2445
- if (lastPlugin && lastPlugin[_DYN_SET_NEXT_PLUGIN ] && thePlugin[STR_PROCESS_TELEMETRY ]) {
2446
- lastPlugin[_DYN_SET_NEXT_PLUGIN ](thePlugin);
2447
- }
2448
- var isInitialized = false;
2449
- if (isFunction(thePlugin[_DYN_IS_INITIALIZED ])) {
2450
- isInitialized = thePlugin[_DYN_IS_INITIALIZED ]();
2451
- }
2452
- else {
2453
- pluginState = _getPluginState(thePlugin);
2454
- isInitialized = pluginState[_DYN_IS_INITIALIZED ];
2455
- }
2456
- if (!isInitialized) {
2457
- initPlugins[_DYN_PUSH$1 ](thePlugin);
2458
- }
2459
- lastPlugin = thePlugin;
2460
- proxy = proxy[_DYN_GET_NEXT ]();
2461
- }
2462
- }
2463
- arrForEach(initPlugins, function (thePlugin) {
2464
- var core = processContext[STR_CORE ]();
2465
- thePlugin[_DYN_INITIALIZE ](processContext.getCfg(), core, extensions, processContext[_DYN_GET_NEXT ]());
2466
- pluginState = _getPluginState(thePlugin);
2467
- if (!thePlugin[STR_CORE] && !pluginState[STR_CORE]) {
2468
- pluginState[STR_CORE] = core;
2469
- }
2470
- pluginState[_DYN_IS_INITIALIZED ] = true;
2471
- delete pluginState[_DYN_TEARDOWN ];
2472
- });
2473
- }
2474
- function sortPlugins(plugins) {
2475
- return plugins.sort(function (extA, extB) {
2476
- var result = 0;
2477
- if (extB) {
2478
- var bHasProcess = extB[STR_PROCESS_TELEMETRY];
2479
- if (extA[STR_PROCESS_TELEMETRY]) {
2480
- result = bHasProcess ? extA[STR_PRIORITY] - extB[STR_PRIORITY] : 1;
2481
- }
2482
- else if (bHasProcess) {
2483
- result = -1;
2484
- }
2485
- }
2486
- else {
2487
- result = extA ? 1 : -1;
2488
- }
2489
- return result;
2490
- });
2491
- }
2492
- function createDistributedTraceContext(parentCtx) {
2493
- var trace = {};
2494
- return {
2495
- getName: function () {
2496
- return trace[_DYN_NAME$2 ];
2497
- },
2498
- setName: function (newValue) {
2499
- parentCtx && parentCtx.setName(newValue);
2500
- trace[_DYN_NAME$2 ] = newValue;
2501
- },
2502
- getTraceId: function () {
2503
- return trace[_DYN_TRACE_ID$1 ];
2504
- },
2505
- setTraceId: function (newValue) {
2506
- parentCtx && parentCtx.setTraceId(newValue);
2507
- if (isValidTraceId(newValue)) {
2508
- trace[_DYN_TRACE_ID$1 ] = newValue;
2509
- }
2510
- },
2511
- getSpanId: function () {
2512
- return trace[_DYN_SPAN_ID ];
2410
+ return value;
2513
2411
  },
2514
- setSpanId: function (newValue) {
2515
- parentCtx && parentCtx.setSpanId(newValue);
2516
- if (isValidSpanId(newValue)) {
2517
- trace[_DYN_SPAN_ID ] = newValue;
2412
+ del: function (name, path) {
2413
+ var result = false;
2414
+ if (_isMgrEnabled(cookieMgr)) {
2415
+ result = cookieMgr.purge(name, path);
2518
2416
  }
2417
+ return result;
2519
2418
  },
2520
- getTraceFlags: function () {
2521
- return trace[_DYN_TRACE_FLAGS ];
2522
- },
2523
- setTraceFlags: function (newTraceFlags) {
2524
- parentCtx && parentCtx.setTraceFlags(newTraceFlags);
2525
- trace[_DYN_TRACE_FLAGS ] = newTraceFlags;
2526
- }
2527
- };
2528
- }
2529
-
2530
- var strTelemetryPluginChain = "TelemetryPluginChain";
2531
- var strHasRunFlags = "_hasRun";
2532
- var strGetTelCtx = "_getTelCtx";
2533
- var _chainId = 0;
2534
- function _getNextProxyStart(proxy, core, startAt) {
2535
- while (proxy) {
2536
- if (proxy[_DYN_GET_PLUGIN ]() === startAt) {
2537
- return proxy;
2538
- }
2539
- proxy = proxy[_DYN_GET_NEXT ]();
2540
- }
2541
- return createTelemetryProxyChain([startAt], core[_DYN_CONFIG ] || {}, core);
2542
- }
2543
- function _createInternalContext(telemetryChain, dynamicHandler, core, startAt) {
2544
- var _nextProxy = null;
2545
- var _onComplete = [];
2546
- if (!dynamicHandler) {
2547
- dynamicHandler = createDynamicConfig({}, null, core[_DYN_LOGGER ]);
2548
- }
2549
- if (startAt !== null) {
2550
- _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
2551
- }
2552
- var context = {
2553
- _next: _moveNext,
2554
- ctx: {
2555
- core: function () {
2556
- return core;
2557
- },
2558
- diagLog: function () {
2559
- return safeGetLogger(core, dynamicHandler.cfg);
2560
- },
2561
- getCfg: function () {
2562
- return dynamicHandler.cfg;
2563
- },
2564
- getExtCfg: _resolveExtCfg,
2565
- getConfig: _getConfig,
2566
- hasNext: function () {
2567
- return !!_nextProxy;
2568
- },
2569
- getNext: function () {
2570
- return _nextProxy;
2571
- },
2572
- setNext: function (nextPlugin) {
2573
- _nextProxy = nextPlugin;
2574
- },
2575
- iterate: _iterateChain,
2576
- onComplete: _addOnComplete
2577
- }
2578
- };
2579
- function _addOnComplete(onComplete, that) {
2580
- var args = [];
2581
- for (var _i = 2; _i < arguments.length; _i++) {
2582
- args[_i - 2] = arguments[_i];
2583
- }
2584
- if (onComplete) {
2585
- _onComplete[_DYN_PUSH$1 ]({
2586
- func: onComplete,
2587
- self: !isUndefined(that) ? that : context.ctx,
2588
- args: args
2589
- });
2590
- }
2591
- }
2592
- function _moveNext() {
2593
- var nextProxy = _nextProxy;
2594
- _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT ]() : null;
2595
- if (!nextProxy) {
2596
- var onComplete = _onComplete;
2597
- if (onComplete && onComplete[_DYN_LENGTH$2 ] > 0) {
2598
- arrForEach(onComplete, function (completeDetails) {
2599
- try {
2600
- completeDetails.func[_DYN_CALL ](completeDetails.self, completeDetails.args);
2601
- }
2602
- catch (e) {
2603
- _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
2604
- }
2605
- });
2606
- _onComplete = [];
2607
- }
2608
- }
2609
- return nextProxy;
2610
- }
2611
- function _getExtCfg(identifier, createIfMissing) {
2612
- var idCfg = null;
2613
- var cfg = dynamicHandler.cfg;
2614
- if (cfg && identifier) {
2615
- var extCfg = cfg[STR_EXTENSION_CONFIG ];
2616
- if (!extCfg && createIfMissing) {
2617
- extCfg = {};
2618
- }
2619
- dynamicHandler.set(cfg, STR_EXTENSION_CONFIG, extCfg);
2620
- extCfg = cfg[STR_EXTENSION_CONFIG ];
2621
- if (extCfg) {
2622
- idCfg = extCfg[identifier];
2623
- if (!idCfg && createIfMissing) {
2624
- idCfg = {};
2625
- }
2626
- dynamicHandler.set(extCfg, identifier, idCfg);
2627
- idCfg = extCfg[identifier];
2628
- }
2629
- }
2630
- return idCfg;
2631
- }
2632
- function _resolveExtCfg(identifier, defaultValues) {
2633
- var newConfig = _getExtCfg(identifier, true);
2634
- if (defaultValues) {
2635
- objForEachKey(defaultValues, function (field, defaultValue) {
2636
- if (isNullOrUndefined(newConfig[field])) {
2637
- var cfgValue = dynamicHandler.cfg[field];
2638
- if (cfgValue || !isNullOrUndefined(cfgValue)) {
2639
- newConfig[field] = cfgValue;
2640
- }
2419
+ purge: function (name, path) {
2420
+ var _a;
2421
+ var result = false;
2422
+ if (areCookiesSupported(logger)) {
2423
+ var values = (_a = {},
2424
+ _a[STR_PATH] = path ? path : "/",
2425
+ _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
2426
+ _a);
2427
+ if (!isIE()) {
2428
+ values["max-age"] = "0";
2641
2429
  }
2642
- _applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
2643
- });
2644
- }
2645
- return dynamicHandler[_DYN_SET_DF ](newConfig, defaultValues);
2646
- }
2647
- function _getConfig(identifier, field, defaultValue) {
2648
- if (defaultValue === void 0) { defaultValue = false; }
2649
- var theValue;
2650
- var extConfig = _getExtCfg(identifier, false);
2651
- var rootConfig = dynamicHandler.cfg;
2652
- if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
2653
- theValue = extConfig[field];
2654
- }
2655
- else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
2656
- theValue = rootConfig[field];
2657
- }
2658
- return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
2659
- }
2660
- function _iterateChain(cb) {
2661
- var nextPlugin;
2662
- while (!!(nextPlugin = context._next())) {
2663
- var plugin = nextPlugin[_DYN_GET_PLUGIN ]();
2664
- if (plugin) {
2665
- cb(plugin);
2430
+ _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));
2431
+ result = true;
2666
2432
  }
2433
+ return result;
2667
2434
  }
2668
- }
2669
- return context;
2670
- }
2671
- function createProcessTelemetryContext(telemetryChain, cfg, core, startAt) {
2672
- var config = createDynamicConfig(cfg);
2673
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2674
- var context = internalContext.ctx;
2675
- function _processNext(env) {
2676
- var nextPlugin = internalContext._next();
2677
- if (nextPlugin) {
2678
- nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
2679
- }
2680
- return !nextPlugin;
2681
- }
2682
- function _createNew(plugins, startAt) {
2683
- if (plugins === void 0) { plugins = null; }
2684
- if (isArray(plugins)) {
2685
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2686
- }
2687
- return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config.cfg, core, startAt);
2688
- }
2689
- context[_DYN_PROCESS_NEXT ] = _processNext;
2690
- context[_DYN_CREATE_NEW ] = _createNew;
2691
- return context;
2435
+ };
2436
+ cookieMgr[strConfigCookieMgr] = cookieMgr;
2437
+ return cookieMgr;
2692
2438
  }
2693
- function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
2694
- var config = createDynamicConfig(core[_DYN_CONFIG ]);
2695
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2696
- var context = internalContext.ctx;
2697
- function _processNext(unloadState) {
2698
- var nextPlugin = internalContext._next();
2699
- nextPlugin && nextPlugin.unload(context, unloadState);
2700
- return !nextPlugin;
2701
- }
2702
- function _createNew(plugins, startAt) {
2703
- if (plugins === void 0) { plugins = null; }
2704
- if (isArray(plugins)) {
2705
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2439
+ function areCookiesSupported(logger) {
2440
+ if (_supportsCookies === null) {
2441
+ _supportsCookies = false;
2442
+ try {
2443
+ var doc = _doc || {};
2444
+ _supportsCookies = doc[strCookie] !== undefined;
2706
2445
  }
2707
- return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2708
- }
2709
- context[_DYN_PROCESS_NEXT ] = _processNext;
2710
- context[_DYN_CREATE_NEW ] = _createNew;
2711
- return context;
2712
- }
2713
- function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
2714
- var config = createDynamicConfig(core[_DYN_CONFIG ]);
2715
- var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2716
- var context = internalContext.ctx;
2717
- function _processNext(updateState) {
2718
- return context.iterate(function (plugin) {
2719
- if (isFunction(plugin[_DYN_UPDATE ])) {
2720
- plugin[_DYN_UPDATE ](context, updateState);
2721
- }
2722
- });
2723
- }
2724
- function _createNew(plugins, startAt) {
2725
- if (plugins === void 0) { plugins = null; }
2726
- if (isArray(plugins)) {
2727
- plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
2446
+ catch (e) {
2447
+ _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2728
2448
  }
2729
- return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
2730
2449
  }
2731
- context[_DYN_PROCESS_NEXT ] = _processNext;
2732
- context[_DYN_CREATE_NEW ] = _createNew;
2733
- return context;
2734
- }
2735
- function createTelemetryProxyChain(plugins, config, core, startAt) {
2736
- var firstProxy = null;
2737
- var add = startAt ? false : true;
2738
- if (isArray(plugins) && plugins[_DYN_LENGTH$2 ] > 0) {
2739
- var lastProxy_1 = null;
2740
- arrForEach(plugins, function (thePlugin) {
2741
- if (!add && startAt === thePlugin) {
2742
- add = true;
2743
- }
2744
- if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY ])) {
2745
- var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
2746
- if (!firstProxy) {
2747
- firstProxy = newProxy;
2748
- }
2749
- if (lastProxy_1) {
2750
- lastProxy_1._setNext(newProxy);
2751
- }
2752
- lastProxy_1 = newProxy;
2753
- }
2754
- });
2755
- }
2756
- if (startAt && !firstProxy) {
2757
- return createTelemetryProxyChain([startAt], config, core);
2758
- }
2759
- return firstProxy;
2450
+ return _supportsCookies;
2760
2451
  }
2761
- function createTelemetryPluginProxy(plugin, config, core) {
2762
- var nextProxy = null;
2763
- var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY ]);
2764
- var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN ]);
2765
- var chainId;
2766
- if (plugin) {
2767
- chainId = plugin[_DYN_IDENTIFIER ] + "-" + plugin[STR_PRIORITY ] + "-" + _chainId++;
2768
- }
2769
- else {
2770
- chainId = "Unknown-0-" + _chainId++;
2771
- }
2772
- var proxyChain = {
2773
- getPlugin: function () {
2774
- return plugin;
2775
- },
2776
- getNext: function () {
2777
- return nextProxy;
2778
- },
2779
- processTelemetry: _processTelemetry,
2780
- unload: _unloadPlugin,
2781
- update: _updatePlugin,
2782
- _id: chainId,
2783
- _setNext: function (nextPlugin) {
2784
- nextProxy = nextPlugin;
2785
- }
2786
- };
2787
- function _getTelCtx() {
2788
- var itemCtx;
2789
- if (plugin && isFunction(plugin[strGetTelCtx])) {
2790
- itemCtx = plugin[strGetTelCtx]();
2791
- }
2792
- if (!itemCtx) {
2793
- itemCtx = createProcessTelemetryContext(proxyChain, config, core);
2794
- }
2795
- return itemCtx;
2796
- }
2797
- function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
2798
- var hasRun = false;
2799
- var identifier = plugin ? plugin[_DYN_IDENTIFIER ] : strTelemetryPluginChain;
2800
- var hasRunContext = itemCtx[strHasRunFlags];
2801
- if (!hasRunContext) {
2802
- hasRunContext = itemCtx[strHasRunFlags] = {};
2803
- }
2804
- itemCtx.setNext(nextProxy);
2805
- if (plugin) {
2806
- doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
2807
- hasRunContext[chainId] = true;
2808
- try {
2809
- var nextId = nextProxy ? nextProxy._id : STR_EMPTY;
2810
- if (nextId) {
2811
- hasRunContext[nextId] = false;
2812
- }
2813
- hasRun = processPluginFn(itemCtx);
2814
- }
2815
- catch (error) {
2816
- var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
2817
- if (hasNextRun) {
2818
- hasRun = true;
2819
- }
2820
- if (!nextProxy || !hasNextRun) {
2821
- _throwInternal(itemCtx[_DYN_DIAG_LOG$1 ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
2822
- }
2823
- }
2824
- }, details, isAsync);
2825
- }
2826
- return hasRun;
2827
- }
2828
- function _processTelemetry(env, itemCtx) {
2829
- itemCtx = itemCtx || _getTelCtx();
2830
- function _callProcessTelemetry(itemCtx) {
2831
- if (!plugin || !hasProcessTelemetry) {
2832
- return false;
2833
- }
2834
- var pluginState = _getPluginState(plugin);
2835
- if (pluginState[_DYN_TEARDOWN ] || pluginState[STR_DISABLED]) {
2836
- return false;
2837
- }
2838
- if (hasSetNext) {
2839
- plugin[_DYN_SET_NEXT_PLUGIN ](nextProxy);
2840
- }
2841
- plugin[STR_PROCESS_TELEMETRY ](env, itemCtx);
2842
- return true;
2843
- }
2844
- if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
2845
- itemCtx[_DYN_PROCESS_NEXT ](env);
2846
- }
2847
- }
2848
- function _unloadPlugin(unloadCtx, unloadState) {
2849
- function _callTeardown() {
2850
- var hasRun = false;
2851
- if (plugin) {
2852
- var pluginState = _getPluginState(plugin);
2853
- var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2854
- if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2855
- pluginState[STR_CORE ] = null;
2856
- pluginState[_DYN_TEARDOWN ] = true;
2857
- pluginState[_DYN_IS_INITIALIZED ] = false;
2858
- if (plugin[_DYN_TEARDOWN ] && plugin[_DYN_TEARDOWN ](unloadCtx, unloadState) === true) {
2859
- hasRun = true;
2860
- }
2861
- }
2862
- }
2863
- return hasRun;
2864
- }
2865
- if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState[_DYN_IS_ASYNC ])) {
2866
- unloadCtx[_DYN_PROCESS_NEXT ](unloadState);
2867
- }
2868
- }
2869
- function _updatePlugin(updateCtx, updateState) {
2870
- function _callUpdate() {
2871
- var hasRun = false;
2872
- if (plugin) {
2873
- var pluginState = _getPluginState(plugin);
2874
- var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
2875
- if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
2876
- if (plugin[_DYN_UPDATE ] && plugin[_DYN_UPDATE ](updateCtx, updateState) === true) {
2877
- hasRun = true;
2878
- }
2452
+ function _extractParts(theValue) {
2453
+ var values = {};
2454
+ if (theValue && theValue[_DYN_LENGTH$2 ]) {
2455
+ var parts = strTrim(theValue)[_DYN_SPLIT$1 ](";");
2456
+ arrForEach(parts, function (thePart) {
2457
+ thePart = strTrim(thePart || STR_EMPTY);
2458
+ if (thePart) {
2459
+ var idx = strIndexOf(thePart, "=");
2460
+ if (idx === -1) {
2461
+ values[thePart] = null;
2462
+ }
2463
+ else {
2464
+ values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));
2879
2465
  }
2880
2466
  }
2881
- return hasRun;
2882
- }
2883
- if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
2884
- updateCtx[_DYN_PROCESS_NEXT ](updateState);
2467
+ });
2468
+ }
2469
+ return values;
2470
+ }
2471
+ function _formatDate(theDate, func) {
2472
+ if (isFunction(theDate[func])) {
2473
+ return theDate[func]();
2474
+ }
2475
+ return null;
2476
+ }
2477
+ function _formatCookieValue(value, values) {
2478
+ var cookieValue = value || STR_EMPTY;
2479
+ objForEachKey(values, function (name, theValue) {
2480
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
2481
+ });
2482
+ return cookieValue;
2483
+ }
2484
+ function _getCookieValue(name) {
2485
+ var cookieValue = STR_EMPTY;
2486
+ if (_doc) {
2487
+ var theCookie = _doc[strCookie] || STR_EMPTY;
2488
+ if (_parsedCookieValue !== theCookie) {
2489
+ _cookieCache = _extractParts(theCookie);
2490
+ _parsedCookieValue = theCookie;
2885
2491
  }
2492
+ cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
2886
2493
  }
2887
- return objFreeze(proxyChain);
2494
+ return cookieValue;
2888
2495
  }
2889
-
2890
- var ChannelControllerPriority = 500;
2891
- var ChannelValidationMessage = "Channel has invalid priority - ";
2892
- function _addChannelQueue(channelQueue, queue, core) {
2893
- if (queue && isArray(queue) && queue[_DYN_LENGTH$2 ] > 0) {
2894
- queue = queue.sort(function (a, b) {
2895
- return a[STR_PRIORITY ] - b[STR_PRIORITY ];
2896
- });
2897
- arrForEach(queue, function (queueItem) {
2898
- if (queueItem[STR_PRIORITY ] < ChannelControllerPriority) {
2899
- throwError(ChannelValidationMessage + queueItem[_DYN_IDENTIFIER ]);
2900
- }
2901
- });
2902
- channelQueue[_DYN_PUSH$1 ]({
2903
- queue: objFreeze(queue),
2904
- chain: createTelemetryProxyChain(queue, core[_DYN_CONFIG ], core)
2905
- });
2496
+ function _setCookieValue(name, cookieValue) {
2497
+ if (_doc) {
2498
+ _doc[strCookie] = name + "=" + cookieValue;
2906
2499
  }
2907
2500
  }
2908
- function createChannelControllerPlugin(channelQueue, core) {
2909
- function _getTelCtx() {
2910
- return createProcessTelemetryContext(null, core[_DYN_CONFIG ], core, null);
2501
+ function uaDisallowsSameSiteNone(userAgent) {
2502
+ if (!isString(userAgent)) {
2503
+ return false;
2504
+ }
2505
+ if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
2506
+ return true;
2507
+ }
2508
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
2509
+ return true;
2510
+ }
2511
+ if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
2512
+ return true;
2513
+ }
2514
+ if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
2515
+ return true;
2516
+ }
2517
+ if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
2518
+ return true;
2519
+ }
2520
+ if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
2521
+ return true;
2911
2522
  }
2912
- function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
2913
- var waiting = theChannels ? (theChannels[_DYN_LENGTH$2 ] + 1) : 1;
2914
- function _runChainOnComplete() {
2915
- waiting--;
2916
- if (waiting === 0) {
2917
- onComplete && onComplete();
2918
- onComplete = null;
2523
+ return false;
2524
+ }
2525
+
2526
+ var defaultValues$1 = {
2527
+ perfEvtsSendAll: false
2528
+ };
2529
+ function _runListeners(listeners, name, isAsync, callback) {
2530
+ arrForEach(listeners, function (listener) {
2531
+ if (listener && listener[name]) {
2532
+ if (isAsync) {
2533
+ scheduleTimeout(function () { return callback(listener); }, 0);
2919
2534
  }
2920
- }
2921
- if (waiting > 0) {
2922
- arrForEach(theChannels, function (channels) {
2923
- if (channels && channels.queue[_DYN_LENGTH$2 ] > 0) {
2924
- var channelChain = channels.chain;
2925
- var chainCtx = itemCtx[_DYN_CREATE_NEW ](channelChain);
2926
- chainCtx[_DYN_ON_COMPLETE ](_runChainOnComplete);
2927
- processFn(chainCtx);
2535
+ else {
2536
+ try {
2537
+ callback(listener);
2928
2538
  }
2929
- else {
2930
- waiting--;
2539
+ catch (e) {
2931
2540
  }
2932
- });
2541
+ }
2933
2542
  }
2934
- _runChainOnComplete();
2935
- }
2936
- function _doUpdate(updateCtx, updateState) {
2937
- var theUpdateState = updateState || {
2938
- reason: 0
2939
- };
2940
- _processChannelQueue(channelQueue, updateCtx, function (chainCtx) {
2941
- chainCtx[_DYN_PROCESS_NEXT ](theUpdateState);
2942
- }, function () {
2943
- updateCtx[_DYN_PROCESS_NEXT ](theUpdateState);
2543
+ });
2544
+ }
2545
+ var NotificationManager = /** @class */ (function () {
2546
+ function NotificationManager(config) {
2547
+ this.listeners = [];
2548
+ var perfEvtsSendAll;
2549
+ var cfgHandler = createDynamicConfig(config, defaultValues$1);
2550
+ cfgHandler[_DYN_WATCH ](function (details) {
2551
+ perfEvtsSendAll = !!details.cfg.perfEvtsSendAll;
2944
2552
  });
2945
- return true;
2946
- }
2947
- function _doTeardown(unloadCtx, unloadState) {
2948
- var theUnloadState = unloadState || {
2949
- reason: 0 ,
2950
- isAsync: false
2951
- };
2952
- _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
2953
- chainCtx[_DYN_PROCESS_NEXT ](theUnloadState);
2954
- }, function () {
2955
- unloadCtx[_DYN_PROCESS_NEXT ](theUnloadState);
2956
- isInitialized = false;
2553
+ dynamicProto(NotificationManager, this, function (_self) {
2554
+ _self[_DYN_ADD_NOTIFICATION_LIS1 ] = function (listener) {
2555
+ _self.listeners[_DYN_PUSH$1 ](listener);
2556
+ };
2557
+ _self[_DYN_REMOVE_NOTIFICATION_2 ] = function (listener) {
2558
+ var index = arrIndexOf(_self[_DYN_LISTENERS ], listener);
2559
+ while (index > -1) {
2560
+ _self.listeners[_DYN_SPLICE ](index, 1);
2561
+ index = arrIndexOf(_self[_DYN_LISTENERS ], listener);
2562
+ }
2563
+ };
2564
+ _self[STR_EVENTS_SENT ] = function (events) {
2565
+ _runListeners(_self[_DYN_LISTENERS ], STR_EVENTS_SENT, true, function (listener) {
2566
+ listener[STR_EVENTS_SENT ](events);
2567
+ });
2568
+ };
2569
+ _self[STR_EVENTS_DISCARDED ] = function (events, reason) {
2570
+ _runListeners(_self[_DYN_LISTENERS ], STR_EVENTS_DISCARDED, true, function (listener) {
2571
+ listener[STR_EVENTS_DISCARDED ](events, reason);
2572
+ });
2573
+ };
2574
+ _self[STR_EVENTS_SEND_REQUEST ] = function (sendReason, isAsync) {
2575
+ _runListeners(_self[_DYN_LISTENERS ], STR_EVENTS_SEND_REQUEST, isAsync, function (listener) {
2576
+ listener[STR_EVENTS_SEND_REQUEST ](sendReason, isAsync);
2577
+ });
2578
+ };
2579
+ _self[STR_PERF_EVENT ] = function (perfEvent) {
2580
+ if (perfEvent) {
2581
+ if (perfEvtsSendAll || !perfEvent[_DYN_IS_CHILD_EVT ]()) {
2582
+ _runListeners(_self[_DYN_LISTENERS ], STR_PERF_EVENT, false, function (listener) {
2583
+ if (perfEvent[_DYN_IS_ASYNC ]) {
2584
+ scheduleTimeout(function () { return listener[STR_PERF_EVENT ](perfEvent); }, 0);
2585
+ }
2586
+ else {
2587
+ listener[STR_PERF_EVENT ](perfEvent);
2588
+ }
2589
+ });
2590
+ }
2591
+ }
2592
+ };
2957
2593
  });
2958
- return true;
2959
2594
  }
2960
- function _getChannel(pluginIdentifier) {
2961
- var thePlugin = null;
2962
- if (channelQueue && channelQueue[_DYN_LENGTH$2 ] > 0) {
2963
- arrForEach(channelQueue, function (channels) {
2964
- if (channels && channels.queue[_DYN_LENGTH$2 ] > 0) {
2965
- arrForEach(channels.queue, function (ext) {
2966
- if (ext[_DYN_IDENTIFIER ] === pluginIdentifier) {
2967
- thePlugin = ext;
2968
- return -1;
2969
- }
2970
- });
2971
- if (thePlugin) {
2972
- return -1;
2973
- }
2595
+ NotificationManager.__ieDyn=1;
2596
+ return NotificationManager;
2597
+ }());
2598
+
2599
+ var strExecutionContextKey = "ctx";
2600
+ var strParentContextKey = "ParentContextKey";
2601
+ var strChildrenContextKey = "ChildrenContextKey";
2602
+ var _defaultPerfManager = null;
2603
+ var PerfEvent = /** @class */ (function () {
2604
+ function PerfEvent(name, payloadDetails, isAsync) {
2605
+ var _self = this;
2606
+ _self.start = utcNow();
2607
+ _self[_DYN_NAME$2 ] = name;
2608
+ _self[_DYN_IS_ASYNC ] = isAsync;
2609
+ _self[_DYN_IS_CHILD_EVT ] = function () { return false; };
2610
+ if (isFunction(payloadDetails)) {
2611
+ var theDetails_1;
2612
+ objDefineAccessors(_self, "payload", function () {
2613
+ if (!theDetails_1 && isFunction(payloadDetails)) {
2614
+ theDetails_1 = payloadDetails();
2615
+ payloadDetails = null;
2974
2616
  }
2617
+ return theDetails_1;
2975
2618
  });
2976
2619
  }
2977
- return thePlugin;
2620
+ _self[_DYN_GET_CTX ] = function (key) {
2621
+ if (key) {
2622
+ if (key === PerfEvent[strParentContextKey] || key === PerfEvent[strChildrenContextKey]) {
2623
+ return _self[key];
2624
+ }
2625
+ return (_self[strExecutionContextKey] || {})[key];
2626
+ }
2627
+ return null;
2628
+ };
2629
+ _self[_DYN_SET_CTX ] = function (key, value) {
2630
+ if (key) {
2631
+ if (key === PerfEvent[strParentContextKey]) {
2632
+ if (!_self[key]) {
2633
+ _self[_DYN_IS_CHILD_EVT ] = function () { return true; };
2634
+ }
2635
+ _self[key] = value;
2636
+ }
2637
+ else if (key === PerfEvent[strChildrenContextKey]) {
2638
+ _self[key] = value;
2639
+ }
2640
+ else {
2641
+ var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
2642
+ ctx[key] = value;
2643
+ }
2644
+ }
2645
+ };
2646
+ _self[_DYN_COMPLETE ] = function () {
2647
+ var childTime = 0;
2648
+ var childEvts = _self[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2649
+ if (isArray(childEvts)) {
2650
+ for (var lp = 0; lp < childEvts[_DYN_LENGTH$2 ]; lp++) {
2651
+ var childEvt = childEvts[lp];
2652
+ if (childEvt) {
2653
+ childTime += childEvt[_DYN_TIME ];
2654
+ }
2655
+ }
2656
+ }
2657
+ _self[_DYN_TIME ] = utcNow() - _self.start;
2658
+ _self.exTime = _self[_DYN_TIME ] - childTime;
2659
+ _self[_DYN_COMPLETE ] = function () { };
2660
+ };
2978
2661
  }
2979
- var isInitialized = false;
2980
- var channelController = {
2981
- identifier: "ChannelControllerPlugin",
2982
- priority: ChannelControllerPriority,
2983
- initialize: function (config, core, extensions, pluginChain) {
2984
- isInitialized = true;
2985
- arrForEach(channelQueue, function (channels) {
2986
- if (channels && channels.queue[_DYN_LENGTH$2 ] > 0) {
2987
- initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
2662
+ PerfEvent.ParentContextKey = "parent";
2663
+ PerfEvent.ChildrenContextKey = "childEvts";
2664
+ return PerfEvent;
2665
+ }());
2666
+ var PerfManager = /** @class */ (function () {
2667
+ function PerfManager(manager) {
2668
+ this.ctx = {};
2669
+ dynamicProto(PerfManager, this, function (_self) {
2670
+ _self.create = function (src, payloadDetails, isAsync) {
2671
+ return new PerfEvent(src, payloadDetails, isAsync);
2672
+ };
2673
+ _self.fire = function (perfEvent) {
2674
+ if (perfEvent) {
2675
+ perfEvent[_DYN_COMPLETE ]();
2676
+ if (manager && isFunction(manager[STR_PERF_EVENT ])) {
2677
+ manager[STR_PERF_EVENT ](perfEvent);
2678
+ }
2988
2679
  }
2989
- });
2990
- },
2991
- isInitialized: function () {
2992
- return isInitialized;
2993
- },
2994
- processTelemetry: function (item, itemCtx) {
2995
- _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
2996
- chainCtx[_DYN_PROCESS_NEXT ](item);
2997
- }, function () {
2998
- itemCtx[_DYN_PROCESS_NEXT ](item);
2999
- });
3000
- },
3001
- update: _doUpdate,
3002
- pause: function () {
3003
- _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
3004
- chainCtx.iterate(function (plugin) {
3005
- plugin.pause && plugin.pause();
3006
- });
3007
- }, null);
3008
- },
3009
- resume: function () {
3010
- _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
3011
- chainCtx.iterate(function (plugin) {
3012
- plugin.resume && plugin.resume();
3013
- });
3014
- }, null);
3015
- },
3016
- teardown: _doTeardown,
3017
- getChannel: _getChannel,
3018
- flush: function (isAsync, callBack, sendReason, cbTimeout) {
3019
- var waiting = 1;
3020
- var doneIterating = false;
3021
- var cbTimer = null;
3022
- cbTimeout = cbTimeout || 5000;
3023
- function doCallback() {
3024
- waiting--;
3025
- if (doneIterating && waiting === 0) {
3026
- cbTimer && cbTimer[_DYN_CANCEL ]();
3027
- cbTimer = null;
3028
- callBack && callBack(doneIterating);
3029
- callBack = null;
3030
- }
3031
- }
3032
- _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
3033
- chainCtx.iterate(function (plugin) {
3034
- if (plugin[_DYN_FLUSH ]) {
3035
- waiting++;
3036
- var handled_1 = false;
3037
- if (!plugin[_DYN_FLUSH ](isAsync, function () {
3038
- handled_1 = true;
3039
- doCallback();
3040
- }, sendReason)) {
3041
- if (!handled_1) {
3042
- if (isAsync && cbTimer == null) {
3043
- cbTimer = scheduleTimeout(function () {
3044
- cbTimer = null;
3045
- doCallback();
3046
- }, cbTimeout);
3047
- }
3048
- else {
3049
- doCallback();
3050
- }
2680
+ };
2681
+ _self[_DYN_SET_CTX ] = function (key, value) {
2682
+ if (key) {
2683
+ var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
2684
+ ctx[key] = value;
2685
+ }
2686
+ };
2687
+ _self[_DYN_GET_CTX ] = function (key) {
2688
+ return (_self[strExecutionContextKey] || {})[key];
2689
+ };
2690
+ });
2691
+ }
2692
+ PerfManager.__ieDyn=1;
2693
+ return PerfManager;
2694
+ }());
2695
+ var doPerfActiveKey = "CoreUtils.doPerf";
2696
+ function doPerf(mgrSource, getSource, func, details, isAsync) {
2697
+ if (mgrSource) {
2698
+ var perfMgr = mgrSource;
2699
+ if (perfMgr[STR_GET_PERF_MGR]) {
2700
+ perfMgr = perfMgr[STR_GET_PERF_MGR]();
2701
+ }
2702
+ if (perfMgr) {
2703
+ var perfEvt = void 0;
2704
+ var currentActive = perfMgr[_DYN_GET_CTX ](doPerfActiveKey);
2705
+ try {
2706
+ perfEvt = perfMgr.create(getSource(), details, isAsync);
2707
+ if (perfEvt) {
2708
+ if (currentActive && perfEvt[_DYN_SET_CTX ]) {
2709
+ perfEvt[_DYN_SET_CTX ](PerfEvent[strParentContextKey], currentActive);
2710
+ if (currentActive[_DYN_GET_CTX ] && currentActive[_DYN_SET_CTX ]) {
2711
+ var children = currentActive[_DYN_GET_CTX ](PerfEvent[strChildrenContextKey]);
2712
+ if (!children) {
2713
+ children = [];
2714
+ currentActive[_DYN_SET_CTX ](PerfEvent[strChildrenContextKey], children);
3051
2715
  }
2716
+ children[_DYN_PUSH$1 ](perfEvt);
3052
2717
  }
3053
2718
  }
3054
- });
3055
- }, function () {
3056
- doneIterating = true;
3057
- doCallback();
3058
- });
3059
- return true;
3060
- },
3061
- _setQueue: function (queue) {
3062
- channelQueue = queue;
3063
- }
3064
- };
3065
- return channelController;
3066
- }
3067
- function createChannelQueues(channels, extensions, core) {
3068
- var channelQueue = [];
3069
- if (channels) {
3070
- arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, core); });
3071
- }
3072
- if (extensions) {
3073
- var extensionQueue_1 = [];
3074
- arrForEach(extensions, function (plugin) {
3075
- if (plugin[STR_PRIORITY ] > ChannelControllerPriority) {
3076
- extensionQueue_1[_DYN_PUSH$1 ](plugin);
2719
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, perfEvt);
2720
+ return func(perfEvt);
2721
+ }
3077
2722
  }
3078
- });
3079
- _addChannelQueue(channelQueue, extensionQueue_1, core);
2723
+ catch (ex) {
2724
+ if (perfEvt && perfEvt[_DYN_SET_CTX ]) {
2725
+ perfEvt[_DYN_SET_CTX ]("exception", ex);
2726
+ }
2727
+ }
2728
+ finally {
2729
+ if (perfEvt) {
2730
+ perfMgr.fire(perfEvt);
2731
+ }
2732
+ perfMgr[_DYN_SET_CTX ](doPerfActiveKey, currentActive);
2733
+ }
2734
+ }
3080
2735
  }
3081
- return channelQueue;
2736
+ return func();
3082
2737
  }
3083
-
3084
- var _a$3, _b$1;
3085
- var strToGMTString = "toGMTString";
3086
- var strToUTCString = "toUTCString";
3087
- var strCookie = "cookie";
3088
- var strExpires = "expires";
3089
- var strIsCookieUseDisabled = "isCookieUseDisabled";
3090
- var strDisableCookiesUsage = "disableCookiesUsage";
3091
- var strConfigCookieMgr = "_ckMgr";
3092
- var _supportsCookies = null;
3093
- var _allowUaSameSite = null;
3094
- var _parsedCookieValue = null;
3095
- var _doc = getDocument();
3096
- var _cookieCache = {};
3097
- var _globalCookieConfig = {};
3098
- var defaultConfig$1 = objDeepFreeze((_a$3 = {},
3099
- _a$3[STR_DOMAIN] = { fb: "cookieDomain", dfVal: isNotNullOrUndefined },
3100
- _a$3.path = { fb: "cookiePath", dfVal: isNotNullOrUndefined },
3101
- _a$3.enabled = UNDEFINED_VALUE$1,
3102
- _a$3));
3103
- var rootDefaultConfig = (_b$1 = {
3104
- cookieCfg: {},
3105
- cookieDomain: UNDEFINED_VALUE$1,
3106
- cookiePath: UNDEFINED_VALUE$1
3107
- },
3108
- _b$1[strDisableCookiesUsage] = UNDEFINED_VALUE$1,
3109
- _b$1);
3110
- function _isMgrEnabled(cookieMgr) {
3111
- if (cookieMgr) {
3112
- return cookieMgr.isEnabled();
3113
- }
3114
- return true;
2738
+ function getGblPerfMgr() {
2739
+ return _defaultPerfManager;
3115
2740
  }
3116
- function _isIgnoredCookie(cookieMgrCfg, name) {
3117
- if (name && cookieMgrCfg && isArray(cookieMgrCfg.ignoreCookies)) {
3118
- return arrIndexOf(cookieMgrCfg.ignoreCookies, name) !== -1;
2741
+
2742
+ var INVALID_TRACE_ID = "00000000000000000000000000000000";
2743
+ var INVALID_SPAN_ID = "0000000000000000";
2744
+ function _isValid(value, len, invalidValue) {
2745
+ if (value && value[_DYN_LENGTH$2 ] === len && value !== invalidValue) {
2746
+ return !!value.match(/^[\da-f]*$/i);
3119
2747
  }
3120
2748
  return false;
3121
2749
  }
3122
- function _isBlockedCookie(cookieMgrCfg, name) {
3123
- if (name && cookieMgrCfg && isArray(cookieMgrCfg.blockedCookies)) {
3124
- if (arrIndexOf(cookieMgrCfg.blockedCookies, name) !== -1) {
3125
- return true;
2750
+ function isValidTraceId(value) {
2751
+ return _isValid(value, 32, INVALID_TRACE_ID);
2752
+ }
2753
+ function isValidSpanId(value) {
2754
+ return _isValid(value, 16, INVALID_SPAN_ID);
2755
+ }
2756
+
2757
+ var pluginStateData = createElmNodeData("plugin");
2758
+ function _getPluginState(plugin) {
2759
+ return pluginStateData.get(plugin, "state", {}, true);
2760
+ }
2761
+ function initializePlugins(processContext, extensions) {
2762
+ var initPlugins = [];
2763
+ var lastPlugin = null;
2764
+ var proxy = processContext[_DYN_GET_NEXT ]();
2765
+ var pluginState;
2766
+ while (proxy) {
2767
+ var thePlugin = proxy[_DYN_GET_PLUGIN ]();
2768
+ if (thePlugin) {
2769
+ if (lastPlugin && lastPlugin[_DYN_SET_NEXT_PLUGIN ] && thePlugin[STR_PROCESS_TELEMETRY ]) {
2770
+ lastPlugin[_DYN_SET_NEXT_PLUGIN ](thePlugin);
2771
+ }
2772
+ var isInitialized = false;
2773
+ if (isFunction(thePlugin[_DYN_IS_INITIALIZED ])) {
2774
+ isInitialized = thePlugin[_DYN_IS_INITIALIZED ]();
2775
+ }
2776
+ else {
2777
+ pluginState = _getPluginState(thePlugin);
2778
+ isInitialized = pluginState[_DYN_IS_INITIALIZED ];
2779
+ }
2780
+ if (!isInitialized) {
2781
+ initPlugins[_DYN_PUSH$1 ](thePlugin);
2782
+ }
2783
+ lastPlugin = thePlugin;
2784
+ proxy = proxy[_DYN_GET_NEXT ]();
3126
2785
  }
3127
2786
  }
3128
- return _isIgnoredCookie(cookieMgrCfg, name);
2787
+ arrForEach(initPlugins, function (thePlugin) {
2788
+ var core = processContext[STR_CORE ]();
2789
+ thePlugin[_DYN_INITIALIZE ](processContext.getCfg(), core, extensions, processContext[_DYN_GET_NEXT ]());
2790
+ pluginState = _getPluginState(thePlugin);
2791
+ if (!thePlugin[STR_CORE] && !pluginState[STR_CORE]) {
2792
+ pluginState[STR_CORE] = core;
2793
+ }
2794
+ pluginState[_DYN_IS_INITIALIZED ] = true;
2795
+ delete pluginState[_DYN_TEARDOWN ];
2796
+ });
3129
2797
  }
3130
- function createCookieMgr(rootConfig, logger) {
3131
- var cookieMgrConfig;
3132
- var _path;
3133
- var _domain;
3134
- var _enabled;
3135
- var _getCookieFn;
3136
- var _setCookieFn;
3137
- var _delCookieFn;
3138
- rootConfig = createDynamicConfig(rootConfig || _globalCookieConfig, null, logger).cfg;
3139
- onConfigChange(rootConfig, function (details) {
3140
- details[_DYN_SET_DF ](details.cfg, rootDefaultConfig);
3141
- cookieMgrConfig = details[_DYN_SET_DF ](details.cfg.cookieCfg, defaultConfig$1);
3142
- var isEnabled = cookieMgrConfig.enabled;
3143
- if (isNullOrUndefined(isEnabled)) {
3144
- var cookieEnabled = void 0;
3145
- if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {
3146
- cookieEnabled = !rootConfig[strIsCookieUseDisabled];
2798
+ function sortPlugins(plugins) {
2799
+ return plugins.sort(function (extA, extB) {
2800
+ var result = 0;
2801
+ if (extB) {
2802
+ var bHasProcess = extB[STR_PROCESS_TELEMETRY];
2803
+ if (extA[STR_PROCESS_TELEMETRY]) {
2804
+ result = bHasProcess ? extA[STR_PRIORITY] - extB[STR_PRIORITY] : 1;
3147
2805
  }
3148
- if (!isUndefined(rootConfig[strDisableCookiesUsage])) {
3149
- cookieEnabled = !rootConfig[strDisableCookiesUsage];
2806
+ else if (bHasProcess) {
2807
+ result = -1;
3150
2808
  }
3151
- isEnabled = cookieEnabled;
3152
2809
  }
3153
- _path = cookieMgrConfig[STR_PATH ] || "/";
3154
- _domain = cookieMgrConfig[STR_DOMAIN ];
3155
- _enabled = isEnabled !== false;
3156
- _getCookieFn = cookieMgrConfig.getCookie || _getCookieValue;
3157
- _setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;
3158
- _delCookieFn = cookieMgrConfig.delCookie || _setCookieValue;
3159
- }, logger);
3160
- var cookieMgr = {
3161
- isEnabled: function () {
3162
- var enabled = _enabled && areCookiesSupported(logger);
3163
- var gblManager = _globalCookieConfig[strConfigCookieMgr];
3164
- if (enabled && gblManager && cookieMgr !== gblManager) {
3165
- enabled = _isMgrEnabled(gblManager);
3166
- }
3167
- return enabled;
3168
- },
3169
- setEnabled: function (value) {
3170
- _enabled = value !== false;
2810
+ else {
2811
+ result = extA ? 1 : -1;
2812
+ }
2813
+ return result;
2814
+ });
2815
+ }
2816
+ function createDistributedTraceContext(parentCtx) {
2817
+ var trace = {};
2818
+ return {
2819
+ getName: function () {
2820
+ return trace[_DYN_NAME$2 ];
3171
2821
  },
3172
- set: function (name, value, maxAgeSec, domain, path) {
3173
- var result = false;
3174
- if (_isMgrEnabled(cookieMgr) && !_isBlockedCookie(cookieMgrConfig, name)) {
3175
- var values = {};
3176
- var theValue = strTrim(value || STR_EMPTY);
3177
- var idx = strIndexOf(theValue, ";");
3178
- if (idx !== -1) {
3179
- theValue = strTrim(strLeft(value, idx));
3180
- values = _extractParts(strSubstring(value, idx + 1));
3181
- }
3182
- setValue(values, STR_DOMAIN, domain || _domain, isTruthy, isUndefined);
3183
- if (!isNullOrUndefined(maxAgeSec)) {
3184
- var _isIE = isIE();
3185
- if (isUndefined(values[strExpires])) {
3186
- var nowMs = utcNow();
3187
- var expireMs = nowMs + (maxAgeSec * 1000);
3188
- if (expireMs > 0) {
3189
- var expiry = new Date();
3190
- expiry.setTime(expireMs);
3191
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
3192
- }
3193
- }
3194
- if (!_isIE) {
3195
- setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
3196
- }
3197
- }
3198
- var location_1 = getLocation();
3199
- if (location_1 && location_1.protocol === "https:") {
3200
- setValue(values, "secure", null, null, isUndefined);
3201
- if (_allowUaSameSite === null) {
3202
- _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT ]);
3203
- }
3204
- if (_allowUaSameSite) {
3205
- setValue(values, "SameSite", "None", null, isUndefined);
3206
- }
3207
- }
3208
- setValue(values, STR_PATH, path || _path, null, isUndefined);
3209
- _setCookieFn(name, _formatCookieValue(theValue, values));
3210
- result = true;
3211
- }
3212
- return result;
2822
+ setName: function (newValue) {
2823
+ parentCtx && parentCtx.setName(newValue);
2824
+ trace[_DYN_NAME$2 ] = newValue;
3213
2825
  },
3214
- get: function (name) {
3215
- var value = STR_EMPTY;
3216
- if (_isMgrEnabled(cookieMgr) && !_isIgnoredCookie(cookieMgrConfig, name)) {
3217
- value = _getCookieFn(name);
3218
- }
3219
- return value;
2826
+ getTraceId: function () {
2827
+ return trace[_DYN_TRACE_ID$1 ];
3220
2828
  },
3221
- del: function (name, path) {
3222
- var result = false;
3223
- if (_isMgrEnabled(cookieMgr)) {
3224
- result = cookieMgr.purge(name, path);
2829
+ setTraceId: function (newValue) {
2830
+ parentCtx && parentCtx.setTraceId(newValue);
2831
+ if (isValidTraceId(newValue)) {
2832
+ trace[_DYN_TRACE_ID$1 ] = newValue;
3225
2833
  }
3226
- return result;
3227
2834
  },
3228
- purge: function (name, path) {
3229
- var _a;
3230
- var result = false;
3231
- if (areCookiesSupported(logger)) {
3232
- var values = (_a = {},
3233
- _a[STR_PATH] = path ? path : "/",
3234
- _a[strExpires] = "Thu, 01 Jan 1970 00:00:01 GMT",
3235
- _a);
3236
- if (!isIE()) {
3237
- values["max-age"] = "0";
3238
- }
3239
- _delCookieFn(name, _formatCookieValue(STR_EMPTY, values));
3240
- result = true;
2835
+ getSpanId: function () {
2836
+ return trace[_DYN_SPAN_ID ];
2837
+ },
2838
+ setSpanId: function (newValue) {
2839
+ parentCtx && parentCtx.setSpanId(newValue);
2840
+ if (isValidSpanId(newValue)) {
2841
+ trace[_DYN_SPAN_ID ] = newValue;
3241
2842
  }
3242
- return result;
2843
+ },
2844
+ getTraceFlags: function () {
2845
+ return trace[_DYN_TRACE_FLAGS ];
2846
+ },
2847
+ setTraceFlags: function (newTraceFlags) {
2848
+ parentCtx && parentCtx.setTraceFlags(newTraceFlags);
2849
+ trace[_DYN_TRACE_FLAGS ] = newTraceFlags;
3243
2850
  }
3244
2851
  };
3245
- cookieMgr[strConfigCookieMgr] = cookieMgr;
3246
- return cookieMgr;
3247
2852
  }
3248
- function areCookiesSupported(logger) {
3249
- if (_supportsCookies === null) {
3250
- _supportsCookies = false;
3251
- try {
3252
- var doc = _doc || {};
3253
- _supportsCookies = doc[strCookie] !== undefined;
3254
- }
3255
- catch (e) {
3256
- _throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
2853
+
2854
+ var strTelemetryPluginChain = "TelemetryPluginChain";
2855
+ var strHasRunFlags = "_hasRun";
2856
+ var strGetTelCtx = "_getTelCtx";
2857
+ var _chainId = 0;
2858
+ function _getNextProxyStart(proxy, core, startAt) {
2859
+ while (proxy) {
2860
+ if (proxy[_DYN_GET_PLUGIN ]() === startAt) {
2861
+ return proxy;
3257
2862
  }
2863
+ proxy = proxy[_DYN_GET_NEXT ]();
3258
2864
  }
3259
- return _supportsCookies;
2865
+ return createTelemetryProxyChain([startAt], core.config || {}, core);
3260
2866
  }
3261
- function _extractParts(theValue) {
3262
- var values = {};
3263
- if (theValue && theValue[_DYN_LENGTH$2 ]) {
3264
- var parts = strTrim(theValue)[_DYN_SPLIT$1 ](";");
3265
- arrForEach(parts, function (thePart) {
3266
- thePart = strTrim(thePart || STR_EMPTY);
3267
- if (thePart) {
3268
- var idx = strIndexOf(thePart, "=");
3269
- if (idx === -1) {
3270
- values[thePart] = null;
2867
+ function _createInternalContext(telemetryChain, dynamicHandler, core, startAt) {
2868
+ var _nextProxy = null;
2869
+ var _onComplete = [];
2870
+ if (!dynamicHandler) {
2871
+ dynamicHandler = createDynamicConfig({}, null, core[_DYN_LOGGER ]);
2872
+ }
2873
+ if (startAt !== null) {
2874
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
2875
+ }
2876
+ var context = {
2877
+ _next: _moveNext,
2878
+ ctx: {
2879
+ core: function () {
2880
+ return core;
2881
+ },
2882
+ diagLog: function () {
2883
+ return safeGetLogger(core, dynamicHandler.cfg);
2884
+ },
2885
+ getCfg: function () {
2886
+ return dynamicHandler.cfg;
2887
+ },
2888
+ getExtCfg: _resolveExtCfg,
2889
+ getConfig: _getConfig,
2890
+ hasNext: function () {
2891
+ return !!_nextProxy;
2892
+ },
2893
+ getNext: function () {
2894
+ return _nextProxy;
2895
+ },
2896
+ setNext: function (nextPlugin) {
2897
+ _nextProxy = nextPlugin;
2898
+ },
2899
+ iterate: _iterateChain,
2900
+ onComplete: _addOnComplete
2901
+ }
2902
+ };
2903
+ function _addOnComplete(onComplete, that) {
2904
+ var args = [];
2905
+ for (var _i = 2; _i < arguments.length; _i++) {
2906
+ args[_i - 2] = arguments[_i];
2907
+ }
2908
+ if (onComplete) {
2909
+ _onComplete[_DYN_PUSH$1 ]({
2910
+ func: onComplete,
2911
+ self: !isUndefined(that) ? that : context.ctx,
2912
+ args: args
2913
+ });
2914
+ }
2915
+ }
2916
+ function _moveNext() {
2917
+ var nextProxy = _nextProxy;
2918
+ _nextProxy = nextProxy ? nextProxy[_DYN_GET_NEXT ]() : null;
2919
+ if (!nextProxy) {
2920
+ var onComplete = _onComplete;
2921
+ if (onComplete && onComplete[_DYN_LENGTH$2 ] > 0) {
2922
+ arrForEach(onComplete, function (completeDetails) {
2923
+ try {
2924
+ completeDetails.func[_DYN_CALL ](completeDetails.self, completeDetails.args);
2925
+ }
2926
+ catch (e) {
2927
+ _throwInternal(core[_DYN_LOGGER ], 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
2928
+ }
2929
+ });
2930
+ _onComplete = [];
2931
+ }
2932
+ }
2933
+ return nextProxy;
2934
+ }
2935
+ function _getExtCfg(identifier, createIfMissing) {
2936
+ var idCfg = null;
2937
+ var cfg = dynamicHandler.cfg;
2938
+ if (cfg && identifier) {
2939
+ var extCfg = cfg[STR_EXTENSION_CONFIG ];
2940
+ if (!extCfg && createIfMissing) {
2941
+ extCfg = {};
2942
+ }
2943
+ dynamicHandler.set(cfg, STR_EXTENSION_CONFIG, extCfg);
2944
+ extCfg = cfg[STR_EXTENSION_CONFIG ];
2945
+ if (extCfg) {
2946
+ idCfg = extCfg[identifier];
2947
+ if (!idCfg && createIfMissing) {
2948
+ idCfg = {};
3271
2949
  }
3272
- else {
3273
- values[strTrim(strLeft(thePart, idx))] = strTrim(strSubstring(thePart, idx + 1));
2950
+ dynamicHandler.set(extCfg, identifier, idCfg);
2951
+ idCfg = extCfg[identifier];
2952
+ }
2953
+ }
2954
+ return idCfg;
2955
+ }
2956
+ function _resolveExtCfg(identifier, defaultValues) {
2957
+ var newConfig = _getExtCfg(identifier, true);
2958
+ if (defaultValues) {
2959
+ objForEachKey(defaultValues, function (field, defaultValue) {
2960
+ if (isNullOrUndefined(newConfig[field])) {
2961
+ var cfgValue = dynamicHandler.cfg[field];
2962
+ if (cfgValue || !isNullOrUndefined(cfgValue)) {
2963
+ newConfig[field] = cfgValue;
2964
+ }
3274
2965
  }
2966
+ _applyDefaultValue(dynamicHandler, newConfig, field, defaultValue);
2967
+ });
2968
+ }
2969
+ return dynamicHandler[_DYN_SET_DF ](newConfig, defaultValues);
2970
+ }
2971
+ function _getConfig(identifier, field, defaultValue) {
2972
+ if (defaultValue === void 0) { defaultValue = false; }
2973
+ var theValue;
2974
+ var extConfig = _getExtCfg(identifier, false);
2975
+ var rootConfig = dynamicHandler.cfg;
2976
+ if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
2977
+ theValue = extConfig[field];
2978
+ }
2979
+ else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
2980
+ theValue = rootConfig[field];
2981
+ }
2982
+ return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
2983
+ }
2984
+ function _iterateChain(cb) {
2985
+ var nextPlugin;
2986
+ while (!!(nextPlugin = context._next())) {
2987
+ var plugin = nextPlugin[_DYN_GET_PLUGIN ]();
2988
+ if (plugin) {
2989
+ cb(plugin);
3275
2990
  }
3276
- });
2991
+ }
3277
2992
  }
3278
- return values;
2993
+ return context;
3279
2994
  }
3280
- function _formatDate(theDate, func) {
3281
- if (isFunction(theDate[func])) {
3282
- return theDate[func]();
2995
+ function createProcessTelemetryContext(telemetryChain, cfg, core, startAt) {
2996
+ var config = createDynamicConfig(cfg);
2997
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
2998
+ var context = internalContext.ctx;
2999
+ function _processNext(env) {
3000
+ var nextPlugin = internalContext._next();
3001
+ if (nextPlugin) {
3002
+ nextPlugin[STR_PROCESS_TELEMETRY ](env, context);
3003
+ }
3004
+ return !nextPlugin;
3283
3005
  }
3284
- return null;
3285
- }
3286
- function _formatCookieValue(value, values) {
3287
- var cookieValue = value || STR_EMPTY;
3288
- objForEachKey(values, function (name, theValue) {
3289
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
3290
- });
3291
- return cookieValue;
3292
- }
3293
- function _getCookieValue(name) {
3294
- var cookieValue = STR_EMPTY;
3295
- if (_doc) {
3296
- var theCookie = _doc[strCookie] || STR_EMPTY;
3297
- if (_parsedCookieValue !== theCookie) {
3298
- _cookieCache = _extractParts(theCookie);
3299
- _parsedCookieValue = theCookie;
3006
+ function _createNew(plugins, startAt) {
3007
+ if (plugins === void 0) { plugins = null; }
3008
+ if (isArray(plugins)) {
3009
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
3300
3010
  }
3301
- cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
3011
+ return createProcessTelemetryContext(plugins || context[_DYN_GET_NEXT ](), config.cfg, core, startAt);
3302
3012
  }
3303
- return cookieValue;
3013
+ context[_DYN_PROCESS_NEXT ] = _processNext;
3014
+ context[_DYN_CREATE_NEW ] = _createNew;
3015
+ return context;
3304
3016
  }
3305
- function _setCookieValue(name, cookieValue) {
3306
- if (_doc) {
3307
- _doc[strCookie] = name + "=" + cookieValue;
3017
+ function createProcessTelemetryUnloadContext(telemetryChain, core, startAt) {
3018
+ var config = createDynamicConfig(core.config);
3019
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
3020
+ var context = internalContext.ctx;
3021
+ function _processNext(unloadState) {
3022
+ var nextPlugin = internalContext._next();
3023
+ nextPlugin && nextPlugin.unload(context, unloadState);
3024
+ return !nextPlugin;
3025
+ }
3026
+ function _createNew(plugins, startAt) {
3027
+ if (plugins === void 0) { plugins = null; }
3028
+ if (isArray(plugins)) {
3029
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
3030
+ }
3031
+ return createProcessTelemetryUnloadContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
3308
3032
  }
3033
+ context[_DYN_PROCESS_NEXT ] = _processNext;
3034
+ context[_DYN_CREATE_NEW ] = _createNew;
3035
+ return context;
3309
3036
  }
3310
- function uaDisallowsSameSiteNone(userAgent) {
3311
- if (!isString(userAgent)) {
3312
- return false;
3037
+ function createProcessTelemetryUpdateContext(telemetryChain, core, startAt) {
3038
+ var config = createDynamicConfig(core.config);
3039
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
3040
+ var context = internalContext.ctx;
3041
+ function _processNext(updateState) {
3042
+ return context.iterate(function (plugin) {
3043
+ if (isFunction(plugin[_DYN_UPDATE ])) {
3044
+ plugin[_DYN_UPDATE ](context, updateState);
3045
+ }
3046
+ });
3313
3047
  }
3314
- if (strContains(userAgent, "CPU iPhone OS 12") || strContains(userAgent, "iPad; CPU OS 12")) {
3315
- return true;
3048
+ function _createNew(plugins, startAt) {
3049
+ if (plugins === void 0) { plugins = null; }
3050
+ if (isArray(plugins)) {
3051
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
3052
+ }
3053
+ return createProcessTelemetryUpdateContext(plugins || context[_DYN_GET_NEXT ](), core, startAt);
3316
3054
  }
3317
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strContains(userAgent, "Version/") && strContains(userAgent, "Safari")) {
3318
- return true;
3055
+ context[_DYN_PROCESS_NEXT ] = _processNext;
3056
+ context[_DYN_CREATE_NEW ] = _createNew;
3057
+ return context;
3058
+ }
3059
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
3060
+ var firstProxy = null;
3061
+ var add = startAt ? false : true;
3062
+ if (isArray(plugins) && plugins[_DYN_LENGTH$2 ] > 0) {
3063
+ var lastProxy_1 = null;
3064
+ arrForEach(plugins, function (thePlugin) {
3065
+ if (!add && startAt === thePlugin) {
3066
+ add = true;
3067
+ }
3068
+ if (add && thePlugin && isFunction(thePlugin[STR_PROCESS_TELEMETRY ])) {
3069
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
3070
+ if (!firstProxy) {
3071
+ firstProxy = newProxy;
3072
+ }
3073
+ if (lastProxy_1) {
3074
+ lastProxy_1._setNext(newProxy);
3075
+ }
3076
+ lastProxy_1 = newProxy;
3077
+ }
3078
+ });
3319
3079
  }
3320
- if (strContains(userAgent, "Macintosh; Intel Mac OS X 10_14") && strEndsWith(userAgent, "AppleWebKit/605.1.15 (KHTML, like Gecko)")) {
3321
- return true;
3080
+ if (startAt && !firstProxy) {
3081
+ return createTelemetryProxyChain([startAt], config, core);
3322
3082
  }
3323
- if (strContains(userAgent, "Chrome/5") || strContains(userAgent, "Chrome/6")) {
3324
- return true;
3083
+ return firstProxy;
3084
+ }
3085
+ function createTelemetryPluginProxy(plugin, config, core) {
3086
+ var nextProxy = null;
3087
+ var hasProcessTelemetry = isFunction(plugin[STR_PROCESS_TELEMETRY ]);
3088
+ var hasSetNext = isFunction(plugin[_DYN_SET_NEXT_PLUGIN ]);
3089
+ var chainId;
3090
+ if (plugin) {
3091
+ chainId = plugin[_DYN_IDENTIFIER ] + "-" + plugin[STR_PRIORITY ] + "-" + _chainId++;
3325
3092
  }
3326
- if (strContains(userAgent, "UnrealEngine") && !strContains(userAgent, "Chrome")) {
3327
- return true;
3093
+ else {
3094
+ chainId = "Unknown-0-" + _chainId++;
3328
3095
  }
3329
- if (strContains(userAgent, "UCBrowser/12") || strContains(userAgent, "UCBrowser/11")) {
3330
- return true;
3096
+ var proxyChain = {
3097
+ getPlugin: function () {
3098
+ return plugin;
3099
+ },
3100
+ getNext: function () {
3101
+ return nextProxy;
3102
+ },
3103
+ processTelemetry: _processTelemetry,
3104
+ unload: _unloadPlugin,
3105
+ update: _updatePlugin,
3106
+ _id: chainId,
3107
+ _setNext: function (nextPlugin) {
3108
+ nextProxy = nextPlugin;
3109
+ }
3110
+ };
3111
+ function _getTelCtx() {
3112
+ var itemCtx;
3113
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
3114
+ itemCtx = plugin[strGetTelCtx]();
3115
+ }
3116
+ if (!itemCtx) {
3117
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
3118
+ }
3119
+ return itemCtx;
3331
3120
  }
3332
- return false;
3333
- }
3334
-
3335
- var defaultValues$1 = {
3336
- perfEvtsSendAll: false
3337
- };
3338
- function _runListeners(listeners, name, isAsync, callback) {
3339
- arrForEach(listeners, function (listener) {
3340
- if (listener && listener[name]) {
3341
- if (isAsync) {
3342
- scheduleTimeout(function () { return callback(listener); }, 0);
3343
- }
3344
- else {
3121
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
3122
+ var hasRun = false;
3123
+ var identifier = plugin ? plugin[_DYN_IDENTIFIER ] : strTelemetryPluginChain;
3124
+ var hasRunContext = itemCtx[strHasRunFlags];
3125
+ if (!hasRunContext) {
3126
+ hasRunContext = itemCtx[strHasRunFlags] = {};
3127
+ }
3128
+ itemCtx.setNext(nextProxy);
3129
+ if (plugin) {
3130
+ doPerf(itemCtx[STR_CORE ](), function () { return identifier + ":" + name; }, function () {
3131
+ hasRunContext[chainId] = true;
3345
3132
  try {
3346
- callback(listener);
3133
+ var nextId = nextProxy ? nextProxy._id : STR_EMPTY;
3134
+ if (nextId) {
3135
+ hasRunContext[nextId] = false;
3136
+ }
3137
+ hasRun = processPluginFn(itemCtx);
3347
3138
  }
3348
- catch (e) {
3139
+ catch (error) {
3140
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
3141
+ if (hasNextRun) {
3142
+ hasRun = true;
3143
+ }
3144
+ if (!nextProxy || !hasNextRun) {
3145
+ _throwInternal(itemCtx[_DYN_DIAG_LOG$1 ](), 1 , 73 , "Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
3146
+ }
3349
3147
  }
3148
+ }, details, isAsync);
3149
+ }
3150
+ return hasRun;
3151
+ }
3152
+ function _processTelemetry(env, itemCtx) {
3153
+ itemCtx = itemCtx || _getTelCtx();
3154
+ function _callProcessTelemetry(itemCtx) {
3155
+ if (!plugin || !hasProcessTelemetry) {
3156
+ return false;
3157
+ }
3158
+ var pluginState = _getPluginState(plugin);
3159
+ if (pluginState[_DYN_TEARDOWN ] || pluginState[STR_DISABLED]) {
3160
+ return false;
3161
+ }
3162
+ if (hasSetNext) {
3163
+ plugin[_DYN_SET_NEXT_PLUGIN ](nextProxy);
3350
3164
  }
3165
+ plugin[STR_PROCESS_TELEMETRY ](env, itemCtx);
3166
+ return true;
3351
3167
  }
3352
- });
3353
- }
3354
- var NotificationManager = /** @class */ (function () {
3355
- function NotificationManager(config) {
3356
- this.listeners = [];
3357
- var perfEvtsSendAll;
3358
- var cfgHandler = createDynamicConfig(config, defaultValues$1);
3359
- cfgHandler[_DYN_WATCH ](function (details) {
3360
- perfEvtsSendAll = !!details.cfg.perfEvtsSendAll;
3361
- });
3362
- dynamicProto(NotificationManager, this, function (_self) {
3363
- _self[_DYN_ADD_NOTIFICATION_LIS1 ] = function (listener) {
3364
- _self.listeners[_DYN_PUSH$1 ](listener);
3365
- };
3366
- _self[_DYN_REMOVE_NOTIFICATION_2 ] = function (listener) {
3367
- var index = arrIndexOf(_self[_DYN_LISTENERS ], listener);
3368
- while (index > -1) {
3369
- _self.listeners[_DYN_SPLICE ](index, 1);
3370
- index = arrIndexOf(_self[_DYN_LISTENERS ], listener);
3168
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
3169
+ itemCtx[_DYN_PROCESS_NEXT ](env);
3170
+ }
3171
+ }
3172
+ function _unloadPlugin(unloadCtx, unloadState) {
3173
+ function _callTeardown() {
3174
+ var hasRun = false;
3175
+ if (plugin) {
3176
+ var pluginState = _getPluginState(plugin);
3177
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
3178
+ if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
3179
+ pluginState[STR_CORE ] = null;
3180
+ pluginState[_DYN_TEARDOWN ] = true;
3181
+ pluginState[_DYN_IS_INITIALIZED ] = false;
3182
+ if (plugin[_DYN_TEARDOWN ] && plugin[_DYN_TEARDOWN ](unloadCtx, unloadState) === true) {
3183
+ hasRun = true;
3184
+ }
3371
3185
  }
3372
- };
3373
- _self[STR_EVENTS_SENT ] = function (events) {
3374
- _runListeners(_self[_DYN_LISTENERS ], STR_EVENTS_SENT, true, function (listener) {
3375
- listener[STR_EVENTS_SENT ](events);
3376
- });
3377
- };
3378
- _self[STR_EVENTS_DISCARDED ] = function (events, reason) {
3379
- _runListeners(_self[_DYN_LISTENERS ], STR_EVENTS_DISCARDED, true, function (listener) {
3380
- listener[STR_EVENTS_DISCARDED ](events, reason);
3381
- });
3382
- };
3383
- _self[STR_EVENTS_SEND_REQUEST ] = function (sendReason, isAsync) {
3384
- _runListeners(_self[_DYN_LISTENERS ], STR_EVENTS_SEND_REQUEST, isAsync, function (listener) {
3385
- listener[STR_EVENTS_SEND_REQUEST ](sendReason, isAsync);
3386
- });
3387
- };
3388
- _self[STR_PERF_EVENT ] = function (perfEvent) {
3389
- if (perfEvent) {
3390
- if (perfEvtsSendAll || !perfEvent[_DYN_IS_CHILD_EVT ]()) {
3391
- _runListeners(_self[_DYN_LISTENERS ], STR_PERF_EVENT, false, function (listener) {
3392
- if (perfEvent[_DYN_IS_ASYNC ]) {
3393
- scheduleTimeout(function () { return listener[STR_PERF_EVENT ](perfEvent); }, 0);
3394
- }
3395
- else {
3396
- listener[STR_PERF_EVENT ](perfEvent);
3397
- }
3398
- });
3186
+ }
3187
+ return hasRun;
3188
+ }
3189
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState[_DYN_IS_ASYNC ])) {
3190
+ unloadCtx[_DYN_PROCESS_NEXT ](unloadState);
3191
+ }
3192
+ }
3193
+ function _updatePlugin(updateCtx, updateState) {
3194
+ function _callUpdate() {
3195
+ var hasRun = false;
3196
+ if (plugin) {
3197
+ var pluginState = _getPluginState(plugin);
3198
+ var pluginCore = plugin[STR_CORE] || pluginState[STR_CORE ];
3199
+ if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState[_DYN_TEARDOWN ]) {
3200
+ if (plugin[_DYN_UPDATE ] && plugin[_DYN_UPDATE ](updateCtx, updateState) === true) {
3201
+ hasRun = true;
3399
3202
  }
3400
3203
  }
3401
- };
3402
- });
3204
+ }
3205
+ return hasRun;
3206
+ }
3207
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
3208
+ updateCtx[_DYN_PROCESS_NEXT ](updateState);
3209
+ }
3403
3210
  }
3404
- NotificationManager.__ieDyn=1;
3405
- return NotificationManager;
3406
- }());
3211
+ return objFreeze(proxyChain);
3212
+ }
3407
3213
 
3408
3214
  function createUnloadHandlerContainer() {
3409
3215
  var handlers = [];
@@ -3666,6 +3472,7 @@
3666
3472
  function _validateExtensions(logger, channelPriority, allExtensions) {
3667
3473
  var _a;
3668
3474
  var coreExtensions = [];
3475
+ var channels = [];
3669
3476
  var extPriorities = {};
3670
3477
  arrForEach(allExtensions, function (ext) {
3671
3478
  if (isNullOrUndefined(ext) || isNullOrUndefined(ext[_DYN_INITIALIZE ])) {
@@ -3684,11 +3491,13 @@
3684
3491
  if (!extPriority || extPriority < channelPriority) {
3685
3492
  coreExtensions[_DYN_PUSH$1 ](ext);
3686
3493
  }
3494
+ else {
3495
+ channels[_DYN_PUSH$1 ](ext);
3496
+ }
3687
3497
  });
3688
- return _a = {
3689
- all: allExtensions
3690
- },
3498
+ return _a = {},
3691
3499
  _a[STR_CORE ] = coreExtensions,
3500
+ _a[STR_CHANNELS ] = channels,
3692
3501
  _a;
3693
3502
  }
3694
3503
  function _isPluginPresent(thePlugin, plugins) {
@@ -3766,10 +3575,8 @@
3766
3575
  var _cookieManager;
3767
3576
  var _pluginChain;
3768
3577
  var _configExtensions;
3769
- var _coreExtensions;
3770
- var _channelControl;
3771
3578
  var _channelConfig;
3772
- var _channelQueue;
3579
+ var _channels;
3773
3580
  var _isUnloading;
3774
3581
  var _telemetryInitializerPlugin;
3775
3582
  var _internalLogsEventName;
@@ -3816,20 +3623,26 @@
3816
3623
  _configExtensions[_DYN_PUSH$1 ].apply(_configExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), cfgExtensions));
3817
3624
  _channelConfig = config[STR_CHANNELS ];
3818
3625
  _initPluginChain(null);
3819
- if (!_channelQueue || _channelQueue[_DYN_LENGTH$2 ] === 0) {
3626
+ if (!_channels || _channels[_DYN_LENGTH$2 ] === 0) {
3820
3627
  throwError("No " + STR_CHANNELS + " available");
3821
3628
  }
3629
+ if (_channels[_DYN_LENGTH$2 ] > 1) {
3630
+ var teeController = _self[_DYN_GET_PLUGIN ]("TeeChannelController");
3631
+ if (!teeController || !teeController.plugin) {
3632
+ _throwInternal(_self[_DYN_LOGGER ], 1 , 28 , "TeeChannel required");
3633
+ }
3634
+ }
3822
3635
  _registerDelayedCfgListener(config, _cfgListeners, _self[_DYN_LOGGER ]);
3823
3636
  _cfgListeners = null;
3824
3637
  _isInitialized = true;
3825
3638
  _self.releaseQueue();
3826
3639
  _self[_DYN_POLL_INTERNAL_LOGS ]();
3827
3640
  };
3828
- _self.getTransmissionControls = function () {
3641
+ _self.getChannels = function () {
3829
3642
  var controls = [];
3830
- if (_channelQueue) {
3831
- arrForEach(_channelQueue, function (channels) {
3832
- controls[_DYN_PUSH$1 ](channels.queue);
3643
+ if (_channels) {
3644
+ arrForEach(_channels, function (channel) {
3645
+ controls[_DYN_PUSH$1 ](channel);
3833
3646
  });
3834
3647
  }
3835
3648
  return objFreeze(controls);
@@ -3980,9 +3793,7 @@
3980
3793
  _self[_DYN_STOP_POLLING_INTERNA3 ]();
3981
3794
  processUnloadCtx[_DYN_PROCESS_NEXT ](unloadState);
3982
3795
  }
3983
- if (!_flushChannels(isAsync, _doUnload, 6 , cbTimeout)) {
3984
- _doUnload(false);
3985
- }
3796
+ if (!_flushChannels(isAsync, _doUnload, 6 , cbTimeout)) ;
3986
3797
  };
3987
3798
  _self[_DYN_GET_PLUGIN ] = _getPlugin;
3988
3799
  _self.addPlugin = function (plugin, replaceExisting, isAsync, addCb) {
@@ -4063,7 +3874,7 @@
4063
3874
  _self.evtNamespace = function () {
4064
3875
  return _evtNamespace;
4065
3876
  };
4066
- _self[_DYN_FLUSH ] = _flushChannels;
3877
+ _self.flush = _flushChannels;
4067
3878
  _self.getTraceCtx = function (createNew) {
4068
3879
  if (!_traceCtx) {
4069
3880
  _traceCtx = createDistributedTraceContext();
@@ -4160,11 +3971,9 @@
4160
3971
  _cfgPerfManager = null;
4161
3972
  _cookieManager = null;
4162
3973
  _pluginChain = null;
4163
- _coreExtensions = null;
4164
3974
  _configExtensions = [];
4165
- _channelControl = null;
4166
3975
  _channelConfig = null;
4167
- _channelQueue = null;
3976
+ _channels = null;
4168
3977
  _isUnloading = false;
4169
3978
  _internalLogsEventName = null;
4170
3979
  _evtNamespace = createUniqueNamespace("AIBaseCore", true);
@@ -4181,32 +3990,19 @@
4181
3990
  }
4182
3991
  function _initPluginChain(updateState) {
4183
3992
  var theExtensions = _validateExtensions(_self[_DYN_LOGGER ], ChannelControllerPriority, _configExtensions);
4184
- _coreExtensions = theExtensions[STR_CORE ];
4185
3993
  _pluginChain = null;
4186
3994
  _pluginVersionString = null;
4187
3995
  _pluginVersionStringArr = null;
4188
- var allExtensions = theExtensions.all;
4189
- _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, _self));
4190
- if (_channelControl) {
4191
- var idx = arrIndexOf(allExtensions, _channelControl);
4192
- if (idx !== -1) {
4193
- allExtensions[_DYN_SPLICE ](idx, 1);
4194
- }
4195
- idx = arrIndexOf(_coreExtensions, _channelControl);
4196
- if (idx !== -1) {
4197
- _coreExtensions[_DYN_SPLICE ](idx, 1);
4198
- }
4199
- _channelControl._setQueue(_channelQueue);
4200
- }
4201
- else {
4202
- _channelControl = createChannelControllerPlugin(_channelQueue, _self);
4203
- }
4204
- allExtensions[_DYN_PUSH$1 ](_channelControl);
4205
- _coreExtensions[_DYN_PUSH$1 ](_channelControl);
4206
- _extensions = sortPlugins(allExtensions);
4207
- _channelControl[_DYN_INITIALIZE ](_configHandler.cfg, _self, allExtensions);
4208
- initializePlugins(_createTelCtx(), allExtensions);
4209
- _extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
3996
+ _channels = (_channelConfig || [])[0] || [];
3997
+ _channels = sortPlugins(arrAppend(_channels, theExtensions[STR_CHANNELS ]));
3998
+ var allExtensions = sortPlugins(theExtensions[STR_CORE ]);
3999
+ arrAppend(allExtensions, _channels);
4000
+ _extensions = objFreeze(allExtensions);
4001
+ var rootCtx = _createTelCtx();
4002
+ if (_channels && _channels[_DYN_LENGTH$2 ] > 0) {
4003
+ initializePlugins(rootCtx[_DYN_CREATE_NEW ](_channels), allExtensions);
4004
+ }
4005
+ initializePlugins(rootCtx, allExtensions);
4210
4006
  if (updateState) {
4211
4007
  _doUpdate(updateState);
4212
4008
  }
@@ -4215,14 +4011,11 @@
4215
4011
  var theExt = null;
4216
4012
  var thePlugin = null;
4217
4013
  arrForEach(_extensions, function (ext) {
4218
- if (ext[_DYN_IDENTIFIER ] === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
4014
+ if (ext[_DYN_IDENTIFIER ] === pluginIdentifier && ext !== _telemetryInitializerPlugin) {
4219
4015
  thePlugin = ext;
4220
4016
  return -1;
4221
4017
  }
4222
4018
  });
4223
- if (!thePlugin && _channelControl) {
4224
- thePlugin = _channelControl.getChannel(pluginIdentifier);
4225
- }
4226
4019
  if (thePlugin) {
4227
4020
  theExt = {
4228
4021
  plugin: thePlugin,
@@ -4258,7 +4051,7 @@
4258
4051
  }
4259
4052
  function _getPluginChain() {
4260
4053
  if (!_pluginChain) {
4261
- var extensions = (_coreExtensions || []).slice();
4054
+ var extensions = (_extensions || []).slice();
4262
4055
  if (arrIndexOf(extensions, _telemetryInitializerPlugin) === -1) {
4263
4056
  extensions[_DYN_PUSH$1 ](_telemetryInitializerPlugin);
4264
4057
  }
@@ -4326,10 +4119,46 @@
4326
4119
  }
4327
4120
  }
4328
4121
  function _flushChannels(isAsync, callBack, sendReason, cbTimeout) {
4329
- if (_channelControl) {
4330
- return _channelControl[_DYN_FLUSH ](isAsync, callBack, sendReason || 6 , cbTimeout);
4122
+ var waiting = 1;
4123
+ var doneIterating = false;
4124
+ var cbTimer = null;
4125
+ cbTimeout = cbTimeout || 5000;
4126
+ function doCallback() {
4127
+ waiting--;
4128
+ if (doneIterating && waiting === 0) {
4129
+ cbTimer && cbTimer[_DYN_CANCEL ]();
4130
+ cbTimer = null;
4131
+ callBack && callBack(doneIterating);
4132
+ callBack = null;
4133
+ }
4134
+ }
4135
+ if (_channels && _channels[_DYN_LENGTH$2 ] > 0) {
4136
+ var flushCtx = _createTelCtx()[_DYN_CREATE_NEW ](_channels);
4137
+ flushCtx.iterate(function (plugin) {
4138
+ if (plugin.flush) {
4139
+ waiting++;
4140
+ var handled_1 = false;
4141
+ if (!plugin.flush(isAsync, function () {
4142
+ handled_1 = true;
4143
+ doCallback();
4144
+ }, sendReason)) {
4145
+ if (!handled_1) {
4146
+ if (isAsync && cbTimer == null) {
4147
+ cbTimer = scheduleTimeout(function () {
4148
+ cbTimer = null;
4149
+ doCallback();
4150
+ }, cbTimeout);
4151
+ }
4152
+ else {
4153
+ doCallback();
4154
+ }
4155
+ }
4156
+ }
4157
+ }
4158
+ });
4331
4159
  }
4332
- callBack && callBack(false);
4160
+ doneIterating = true;
4161
+ doCallback();
4333
4162
  return true;
4334
4163
  }
4335
4164
  function _initDebugListener() {
@@ -5852,7 +5681,7 @@
5852
5681
  }
5853
5682
  }
5854
5683
  var EnvelopeCreator = {
5855
- Version: "3.0.0-beta.2211-03"
5684
+ Version: "3.0.0-beta.2211-04"
5856
5685
  };
5857
5686
  function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
5858
5687
  EnvelopeCreatorInit(logger, telemetryItem);