@microsoft/applicationinsights-web-basic 2.8.0-beta.2203-02 → 2.8.0-beta.2203-05
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.8.0-beta.2203-05.integrity.json +26 -0
- package/browser/{aib.2.8.0-beta.2203-02.js → aib.2.8.0-beta.2203-05.js} +517 -119
- package/browser/aib.2.8.0-beta.2203-05.js.map +1 -0
- package/browser/aib.2.8.0-beta.2203-05.min.js +6 -0
- package/browser/aib.2.8.0-beta.2203-05.min.js.map +1 -0
- package/browser/aib.2.js +516 -118
- package/browser/aib.2.js.map +1 -1
- package/browser/aib.2.min.js +2 -2
- package/browser/aib.2.min.js.map +1 -1
- package/dist/applicationinsights-web-basic.api.json +228 -0
- package/dist/applicationinsights-web-basic.api.md +5 -1
- package/dist/applicationinsights-web-basic.d.ts +163 -4
- package/dist/applicationinsights-web-basic.js +516 -118
- package/dist/applicationinsights-web-basic.js.map +1 -1
- package/dist/applicationinsights-web-basic.min.js +2 -2
- package/dist/applicationinsights-web-basic.min.js.map +1 -1
- package/dist/applicationinsights-web-basic.rollup.d.ts +163 -4
- package/dist-esm/index.js +1 -1
- package/package.json +4 -4
- package/browser/aib.2.8.0-beta.2203-02.integrity.json +0 -26
- package/browser/aib.2.8.0-beta.2203-02.js.map +0 -1
- package/browser/aib.2.8.0-beta.2203-02.min.js +0 -6
- package/browser/aib.2.8.0-beta.2203-02.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-05
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -357,6 +357,7 @@
|
|
|
357
357
|
var strIsInitialized = "isInitialized";
|
|
358
358
|
var strTeardown = "teardown";
|
|
359
359
|
var strCore = "core";
|
|
360
|
+
var strUpdate = "update";
|
|
360
361
|
var strDisabled = "disabled";
|
|
361
362
|
var strDoTeardown = "_doTeardown";
|
|
362
363
|
var strProcessNext = "processNext";
|
|
@@ -786,7 +787,7 @@
|
|
|
786
787
|
objForEachKey(values, function (field, value) {
|
|
787
788
|
enumClass[field] = value;
|
|
788
789
|
if (!isUndefined(enumClass[value])) {
|
|
789
|
-
throwError("
|
|
790
|
+
throwError("[" + value + "] exists for " + field);
|
|
790
791
|
}
|
|
791
792
|
enumClass[value] = field;
|
|
792
793
|
});
|
|
@@ -798,7 +799,7 @@
|
|
|
798
799
|
}
|
|
799
800
|
return theObject;
|
|
800
801
|
}
|
|
801
|
-
function objExtend(
|
|
802
|
+
function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
|
|
802
803
|
var theArgs = arguments;
|
|
803
804
|
var extended = theArgs[0] || {};
|
|
804
805
|
var argLen = theArgs.length;
|
|
@@ -1227,6 +1228,10 @@
|
|
|
1227
1228
|
}
|
|
1228
1229
|
return DiagnosticLogger;
|
|
1229
1230
|
}());
|
|
1231
|
+
function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
|
|
1232
|
+
if (isUserAct === void 0) { isUserAct = false; }
|
|
1233
|
+
(logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
|
|
1234
|
+
}
|
|
1230
1235
|
|
|
1231
1236
|
var strExecutionContextKey = "ctx";
|
|
1232
1237
|
var _defaultPerfManager = null;
|
|
@@ -1597,8 +1602,11 @@
|
|
|
1597
1602
|
return createTelemetryProxyChain([startAt], config, core);
|
|
1598
1603
|
}
|
|
1599
1604
|
function _createInternalContext(telemetryChain, config, core, startAt) {
|
|
1600
|
-
var _nextProxy =
|
|
1605
|
+
var _nextProxy = null;
|
|
1601
1606
|
var _onComplete = [];
|
|
1607
|
+
if (startAt !== null) {
|
|
1608
|
+
_nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
|
|
1609
|
+
}
|
|
1602
1610
|
var context = {
|
|
1603
1611
|
_next: _moveNext,
|
|
1604
1612
|
ctx: {
|
|
@@ -1648,7 +1656,7 @@
|
|
|
1648
1656
|
completeDetails.func.call(completeDetails.self, completeDetails.args);
|
|
1649
1657
|
}
|
|
1650
1658
|
catch (e) {
|
|
1651
|
-
core.logger
|
|
1659
|
+
_throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
|
|
1652
1660
|
}
|
|
1653
1661
|
});
|
|
1654
1662
|
_onComplete = [];
|
|
@@ -1747,6 +1755,27 @@
|
|
|
1747
1755
|
context.createNew = _createNew;
|
|
1748
1756
|
return context;
|
|
1749
1757
|
}
|
|
1758
|
+
function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
|
|
1759
|
+
var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
|
|
1760
|
+
var context = internalContext.ctx;
|
|
1761
|
+
function _processNext(updateState) {
|
|
1762
|
+
return context.iterate(function (plugin) {
|
|
1763
|
+
if (isFunction(plugin[strUpdate])) {
|
|
1764
|
+
plugin[strUpdate](context, updateState);
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
function _createNew(plugins, startAt) {
|
|
1769
|
+
if (plugins === void 0) { plugins = null; }
|
|
1770
|
+
if (isArray(plugins)) {
|
|
1771
|
+
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
|
|
1772
|
+
}
|
|
1773
|
+
return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
|
|
1774
|
+
}
|
|
1775
|
+
context.processNext = _processNext;
|
|
1776
|
+
context.createNew = _createNew;
|
|
1777
|
+
return context;
|
|
1778
|
+
}
|
|
1750
1779
|
function createTelemetryProxyChain(plugins, config, core, startAt) {
|
|
1751
1780
|
var firstProxy = null;
|
|
1752
1781
|
var add = startAt ? false : true;
|
|
@@ -1793,6 +1822,7 @@
|
|
|
1793
1822
|
},
|
|
1794
1823
|
processTelemetry: _processTelemetry,
|
|
1795
1824
|
unload: _unloadPlugin,
|
|
1825
|
+
update: _updatePlugin,
|
|
1796
1826
|
_id: chainId,
|
|
1797
1827
|
_setNext: function (nextPlugin) {
|
|
1798
1828
|
nextProxy = nextPlugin;
|
|
@@ -1832,7 +1862,7 @@
|
|
|
1832
1862
|
hasRun = true;
|
|
1833
1863
|
}
|
|
1834
1864
|
if (!nextProxy || !hasNextRun) {
|
|
1835
|
-
itemCtx.diagLog()
|
|
1865
|
+
_throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
|
|
1836
1866
|
}
|
|
1837
1867
|
}
|
|
1838
1868
|
}, details, isAsync);
|
|
@@ -1880,6 +1910,24 @@
|
|
|
1880
1910
|
unloadCtx.processNext(unloadState);
|
|
1881
1911
|
}
|
|
1882
1912
|
}
|
|
1913
|
+
function _updatePlugin(updateCtx, updateState) {
|
|
1914
|
+
function _callUpdate() {
|
|
1915
|
+
var hasRun = false;
|
|
1916
|
+
if (plugin) {
|
|
1917
|
+
var pluginState = _getPluginState(plugin);
|
|
1918
|
+
var pluginCore = plugin[strCore] || pluginState.core;
|
|
1919
|
+
if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
|
|
1920
|
+
if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
|
|
1921
|
+
hasRun = true;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
return hasRun;
|
|
1926
|
+
}
|
|
1927
|
+
if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
|
|
1928
|
+
updateCtx.processNext(updateState);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1883
1931
|
return objFreeze(proxyChain);
|
|
1884
1932
|
}
|
|
1885
1933
|
|
|
@@ -2030,7 +2078,7 @@
|
|
|
2030
2078
|
_supportsCookies = doc[strCookie] !== undefined;
|
|
2031
2079
|
}
|
|
2032
2080
|
catch (e) {
|
|
2033
|
-
logger
|
|
2081
|
+
_throwInternal(logger, 2 , 68 , "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
|
|
2034
2082
|
}
|
|
2035
2083
|
}
|
|
2036
2084
|
return _supportsCookies;
|
|
@@ -2159,6 +2207,17 @@
|
|
|
2159
2207
|
}
|
|
2160
2208
|
_runChainOnComplete();
|
|
2161
2209
|
}
|
|
2210
|
+
function _doUpdate(updateCtx, updateState) {
|
|
2211
|
+
var theUpdateState = updateState || {
|
|
2212
|
+
reason: 0
|
|
2213
|
+
};
|
|
2214
|
+
_processChannelQueue(channelQueue, updateCtx, function (chainCtx) {
|
|
2215
|
+
chainCtx[strProcessNext](theUpdateState);
|
|
2216
|
+
}, function () {
|
|
2217
|
+
updateCtx[strProcessNext](theUpdateState);
|
|
2218
|
+
});
|
|
2219
|
+
return true;
|
|
2220
|
+
}
|
|
2162
2221
|
function _doTeardown(unloadCtx, unloadState) {
|
|
2163
2222
|
var theUnloadState = unloadState || {
|
|
2164
2223
|
reason: 0 ,
|
|
@@ -2210,7 +2269,8 @@
|
|
|
2210
2269
|
}, function () {
|
|
2211
2270
|
itemCtx[strProcessNext](item);
|
|
2212
2271
|
});
|
|
2213
|
-
}
|
|
2272
|
+
},
|
|
2273
|
+
update: _doUpdate
|
|
2214
2274
|
},
|
|
2215
2275
|
_a[strPause] = function () {
|
|
2216
2276
|
_processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
|
|
@@ -2295,6 +2355,30 @@
|
|
|
2295
2355
|
return channelQueue;
|
|
2296
2356
|
}
|
|
2297
2357
|
|
|
2358
|
+
function createUnloadHandlerContainer() {
|
|
2359
|
+
var handlers = [];
|
|
2360
|
+
function _addHandler(handler) {
|
|
2361
|
+
if (handler) {
|
|
2362
|
+
handlers.push(handler);
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
function _runHandlers(unloadCtx, unloadState) {
|
|
2366
|
+
arrForEach(handlers, function (handler) {
|
|
2367
|
+
try {
|
|
2368
|
+
handler(unloadCtx, unloadState);
|
|
2369
|
+
}
|
|
2370
|
+
catch (e) {
|
|
2371
|
+
_throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
handlers = [];
|
|
2375
|
+
}
|
|
2376
|
+
return {
|
|
2377
|
+
add: _addHandler,
|
|
2378
|
+
run: _runHandlers
|
|
2379
|
+
};
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2298
2382
|
var strGetPlugin = "getPlugin";
|
|
2299
2383
|
var BaseTelemetryPlugin = /** @class */ (function () {
|
|
2300
2384
|
function BaseTelemetryPlugin() {
|
|
@@ -2302,6 +2386,7 @@
|
|
|
2302
2386
|
var _isinitialized;
|
|
2303
2387
|
var _rootCtx;
|
|
2304
2388
|
var _nextPlugin;
|
|
2389
|
+
var _unloadHandlerContainer;
|
|
2305
2390
|
var _hooks;
|
|
2306
2391
|
_initDefaults();
|
|
2307
2392
|
dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
|
|
@@ -2323,6 +2408,7 @@
|
|
|
2323
2408
|
function _unloadCallback() {
|
|
2324
2409
|
if (!unloadDone) {
|
|
2325
2410
|
unloadDone = true;
|
|
2411
|
+
_unloadHandlerContainer.run(theUnloadCtx, unloadState);
|
|
2326
2412
|
arrForEach(_hooks, function (fn) {
|
|
2327
2413
|
fn.rm();
|
|
2328
2414
|
});
|
|
@@ -2341,6 +2427,30 @@
|
|
|
2341
2427
|
}
|
|
2342
2428
|
return result;
|
|
2343
2429
|
};
|
|
2430
|
+
_self.update = function (updateCtx, updateState) {
|
|
2431
|
+
if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
var result;
|
|
2435
|
+
var updateDone = false;
|
|
2436
|
+
var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
|
|
2437
|
+
var theUpdateState = updateState || {
|
|
2438
|
+
reason: 0
|
|
2439
|
+
};
|
|
2440
|
+
function _updateCallback() {
|
|
2441
|
+
if (!updateDone) {
|
|
2442
|
+
updateDone = true;
|
|
2443
|
+
_setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
|
|
2447
|
+
_updateCallback();
|
|
2448
|
+
}
|
|
2449
|
+
else {
|
|
2450
|
+
result = true;
|
|
2451
|
+
}
|
|
2452
|
+
return result;
|
|
2453
|
+
};
|
|
2344
2454
|
_self._addHook = function (hooks) {
|
|
2345
2455
|
if (hooks) {
|
|
2346
2456
|
if (isArray(hooks)) {
|
|
@@ -2351,6 +2461,7 @@
|
|
|
2351
2461
|
}
|
|
2352
2462
|
}
|
|
2353
2463
|
};
|
|
2464
|
+
proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
|
|
2354
2465
|
});
|
|
2355
2466
|
_self.diagLog = function (itemCtx) {
|
|
2356
2467
|
return _getTelCtx(itemCtx).diagLog();
|
|
@@ -2407,6 +2518,7 @@
|
|
|
2407
2518
|
_rootCtx = null;
|
|
2408
2519
|
_nextPlugin = null;
|
|
2409
2520
|
_hooks = [];
|
|
2521
|
+
_unloadHandlerContainer = createUnloadHandlerContainer();
|
|
2410
2522
|
}
|
|
2411
2523
|
}
|
|
2412
2524
|
return BaseTelemetryPlugin;
|
|
@@ -2453,7 +2565,7 @@
|
|
|
2453
2565
|
}
|
|
2454
2566
|
}
|
|
2455
2567
|
catch (e) {
|
|
2456
|
-
itemCtx.diagLog()
|
|
2568
|
+
_throwInternal(itemCtx.diagLog(), 1 , 64 , "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
|
|
2457
2569
|
}
|
|
2458
2570
|
}
|
|
2459
2571
|
}
|
|
@@ -2476,6 +2588,8 @@
|
|
|
2476
2588
|
|
|
2477
2589
|
var strValidationError = "Plugins must provide initialize method";
|
|
2478
2590
|
var strNotificationManager = "_notificationManager";
|
|
2591
|
+
var strSdkUnloadingError = "SDK is still unloading...";
|
|
2592
|
+
var strSdkNotInitialized = "SDK is not initialized";
|
|
2479
2593
|
function _createPerfManager(core, notificationMgr) {
|
|
2480
2594
|
return new PerfManager(notificationMgr);
|
|
2481
2595
|
}
|
|
@@ -2505,6 +2619,16 @@
|
|
|
2505
2619
|
core: coreExtensions
|
|
2506
2620
|
};
|
|
2507
2621
|
}
|
|
2622
|
+
function _isPluginPresent(thePlugin, plugins) {
|
|
2623
|
+
var exists = false;
|
|
2624
|
+
arrForEach(plugins, function (plugin) {
|
|
2625
|
+
if (plugin === thePlugin) {
|
|
2626
|
+
exists = true;
|
|
2627
|
+
return -1;
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
return exists;
|
|
2631
|
+
}
|
|
2508
2632
|
function _createDummyNotificationManager() {
|
|
2509
2633
|
var _a;
|
|
2510
2634
|
return objCreateFn((_a = {},
|
|
@@ -2529,15 +2653,20 @@
|
|
|
2529
2653
|
var _channelControl;
|
|
2530
2654
|
var _channelConfig;
|
|
2531
2655
|
var _channelQueue;
|
|
2656
|
+
var _isUnloading;
|
|
2532
2657
|
var _telemetryInitializerPlugin;
|
|
2533
2658
|
var _internalLogsEventName;
|
|
2534
2659
|
var _evtNamespace;
|
|
2660
|
+
var _unloadHandlers;
|
|
2535
2661
|
var _debugListener;
|
|
2536
2662
|
var _internalLogPoller = 0;
|
|
2537
2663
|
dynamicProto(BaseCore, this, function (_self) {
|
|
2538
2664
|
_initDefaults();
|
|
2539
2665
|
_self.isInitialized = function () { return _isInitialized; };
|
|
2540
2666
|
_self.initialize = function (config, extensions, logger, notificationManager) {
|
|
2667
|
+
if (_isUnloading) {
|
|
2668
|
+
throwError(strSdkUnloadingError);
|
|
2669
|
+
}
|
|
2541
2670
|
if (_self.isInitialized()) {
|
|
2542
2671
|
throwError("Core should not be initialized more than once");
|
|
2543
2672
|
}
|
|
@@ -2550,15 +2679,14 @@
|
|
|
2550
2679
|
_initDebugListener(config);
|
|
2551
2680
|
_initPerfManager(config);
|
|
2552
2681
|
config.extensions = isNullOrUndefined(config.extensions) ? [] : config.extensions;
|
|
2553
|
-
|
|
2554
|
-
extConfig.NotificationManager = notificationManager;
|
|
2682
|
+
_initExtConfig(config);
|
|
2555
2683
|
if (logger) {
|
|
2556
2684
|
_self.logger = logger;
|
|
2557
2685
|
}
|
|
2558
2686
|
_configExtensions = [];
|
|
2559
2687
|
_configExtensions.push.apply(_configExtensions, __spreadArrayFn(__spreadArrayFn([], extensions, false), config.extensions));
|
|
2560
2688
|
_channelConfig = (config || {}).channels;
|
|
2561
|
-
_initPluginChain(config);
|
|
2689
|
+
_initPluginChain(config, null);
|
|
2562
2690
|
if (_self.getTransmissionControls().length === 0) {
|
|
2563
2691
|
throwError("No channels available");
|
|
2564
2692
|
}
|
|
@@ -2576,7 +2704,7 @@
|
|
|
2576
2704
|
setValue(telemetryItem, strIKey, _self.config.instrumentationKey, null, isNotTruthy);
|
|
2577
2705
|
setValue(telemetryItem, "time", toISOString(new Date()), null, isNotTruthy);
|
|
2578
2706
|
setValue(telemetryItem, "ver", "4.0", null, isNullOrUndefined);
|
|
2579
|
-
if (_self.isInitialized()) {
|
|
2707
|
+
if (!_isUnloading && _self.isInitialized()) {
|
|
2580
2708
|
_createTelCtx().processNext(telemetryItem);
|
|
2581
2709
|
}
|
|
2582
2710
|
else {
|
|
@@ -2591,14 +2719,14 @@
|
|
|
2591
2719
|
}
|
|
2592
2720
|
return _notificationManager;
|
|
2593
2721
|
};
|
|
2594
|
-
_self
|
|
2722
|
+
_self[strAddNotificationListener] = function (listener) {
|
|
2595
2723
|
if (_notificationManager) {
|
|
2596
|
-
_notificationManager
|
|
2724
|
+
_notificationManager[strAddNotificationListener](listener);
|
|
2597
2725
|
}
|
|
2598
2726
|
};
|
|
2599
|
-
_self
|
|
2727
|
+
_self[strRemoveNotificationListener] = function (listener) {
|
|
2600
2728
|
if (_notificationManager) {
|
|
2601
|
-
_notificationManager
|
|
2729
|
+
_notificationManager[strRemoveNotificationListener](listener);
|
|
2602
2730
|
}
|
|
2603
2731
|
};
|
|
2604
2732
|
_self.getCookieMgr = function () {
|
|
@@ -2655,10 +2783,86 @@
|
|
|
2655
2783
|
}
|
|
2656
2784
|
};
|
|
2657
2785
|
proxyFunctions(_self, function () { return _telemetryInitializerPlugin; }, ["addTelemetryInitializer"]);
|
|
2786
|
+
_self.unload = function (isAsync, unloadComplete, cbTimeout) {
|
|
2787
|
+
if (isAsync === void 0) { isAsync = true; }
|
|
2788
|
+
if (!_isInitialized) {
|
|
2789
|
+
throwError(strSdkNotInitialized);
|
|
2790
|
+
}
|
|
2791
|
+
if (_isUnloading) {
|
|
2792
|
+
throwError(strSdkUnloadingError);
|
|
2793
|
+
}
|
|
2794
|
+
var unloadState = {
|
|
2795
|
+
reason: 50 ,
|
|
2796
|
+
isAsync: isAsync,
|
|
2797
|
+
flushComplete: false
|
|
2798
|
+
};
|
|
2799
|
+
var processUnloadCtx = createProcessTelemetryUnloadContext(_getPluginChain(), _self.config, _self);
|
|
2800
|
+
processUnloadCtx.onComplete(function () {
|
|
2801
|
+
_initDefaults();
|
|
2802
|
+
unloadComplete && unloadComplete(unloadState);
|
|
2803
|
+
}, _self);
|
|
2804
|
+
function _doUnload(flushComplete) {
|
|
2805
|
+
unloadState.flushComplete = flushComplete;
|
|
2806
|
+
_isUnloading = true;
|
|
2807
|
+
_unloadHandlers.run(processUnloadCtx, unloadState);
|
|
2808
|
+
_self.stopPollingInternalLogs();
|
|
2809
|
+
processUnloadCtx.processNext(unloadState);
|
|
2810
|
+
}
|
|
2811
|
+
if (_channelControl) {
|
|
2812
|
+
_channelControl.flush(isAsync, _doUnload, 6 , cbTimeout);
|
|
2813
|
+
}
|
|
2814
|
+
else {
|
|
2815
|
+
_doUnload(true);
|
|
2816
|
+
}
|
|
2817
|
+
};
|
|
2658
2818
|
_self.getPlugin = _getPlugin;
|
|
2819
|
+
_self.addPlugin = function (plugin, replaceExisting, isAsync, addCb) {
|
|
2820
|
+
if (isAsync === void 0) { isAsync = true; }
|
|
2821
|
+
if (!plugin) {
|
|
2822
|
+
addCb && addCb(false);
|
|
2823
|
+
_logOrThrowError(strValidationError);
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
var existingPlugin = _getPlugin(plugin.identifier);
|
|
2827
|
+
if (existingPlugin && !replaceExisting) {
|
|
2828
|
+
addCb && addCb(false);
|
|
2829
|
+
_logOrThrowError("Plugin [" + plugin.identifier + "] is already loaded!");
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
var updateState = {
|
|
2833
|
+
reason: 16
|
|
2834
|
+
};
|
|
2835
|
+
function _addPlugin(removed) {
|
|
2836
|
+
_configExtensions.push(plugin);
|
|
2837
|
+
updateState.added = [plugin];
|
|
2838
|
+
_initPluginChain(_self.config, updateState);
|
|
2839
|
+
addCb && addCb(true);
|
|
2840
|
+
}
|
|
2841
|
+
if (existingPlugin) {
|
|
2842
|
+
var removedPlugins_1 = [existingPlugin.plugin];
|
|
2843
|
+
var unloadState = {
|
|
2844
|
+
reason: 2 ,
|
|
2845
|
+
isAsync: isAsync
|
|
2846
|
+
};
|
|
2847
|
+
_removePlugins(removedPlugins_1, unloadState, function (removed) {
|
|
2848
|
+
if (!removed) {
|
|
2849
|
+
addCb && addCb(false);
|
|
2850
|
+
}
|
|
2851
|
+
else {
|
|
2852
|
+
updateState.removed = removedPlugins_1;
|
|
2853
|
+
updateState.reason |= 32 ;
|
|
2854
|
+
_addPlugin();
|
|
2855
|
+
}
|
|
2856
|
+
});
|
|
2857
|
+
}
|
|
2858
|
+
else {
|
|
2859
|
+
_addPlugin();
|
|
2860
|
+
}
|
|
2861
|
+
};
|
|
2659
2862
|
_self.evtNamespace = function () {
|
|
2660
2863
|
return _evtNamespace;
|
|
2661
2864
|
};
|
|
2865
|
+
proxyFunctionAs(_self, "addUnloadCb", function () { return _unloadHandlers; }, "add");
|
|
2662
2866
|
function _initDefaults() {
|
|
2663
2867
|
_isInitialized = false;
|
|
2664
2868
|
_self.logger = new DiagnosticLogger({ loggingLevelConsole: 1 });
|
|
@@ -2676,13 +2880,15 @@
|
|
|
2676
2880
|
_channelControl = null;
|
|
2677
2881
|
_channelConfig = null;
|
|
2678
2882
|
_channelQueue = null;
|
|
2883
|
+
_isUnloading = false;
|
|
2679
2884
|
_internalLogsEventName = null;
|
|
2680
2885
|
_evtNamespace = createUniqueNamespace("AIBaseCore", true);
|
|
2886
|
+
_unloadHandlers = createUnloadHandlerContainer();
|
|
2681
2887
|
}
|
|
2682
2888
|
function _createTelCtx() {
|
|
2683
2889
|
return createProcessTelemetryContext(_getPluginChain(), _self.config, _self);
|
|
2684
2890
|
}
|
|
2685
|
-
function _initPluginChain(config) {
|
|
2891
|
+
function _initPluginChain(config, updateState) {
|
|
2686
2892
|
var theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
|
|
2687
2893
|
_coreExtensions = theExtensions.core;
|
|
2688
2894
|
_pluginChain = null;
|
|
@@ -2708,6 +2914,9 @@
|
|
|
2708
2914
|
_channelControl.initialize(config, _self, allExtensions);
|
|
2709
2915
|
initializePlugins(_createTelCtx(), allExtensions);
|
|
2710
2916
|
_self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
|
|
2917
|
+
if (updateState) {
|
|
2918
|
+
_doUpdate(updateState);
|
|
2919
|
+
}
|
|
2711
2920
|
}
|
|
2712
2921
|
function _getPlugin(pluginIdentifier) {
|
|
2713
2922
|
var theExt = null;
|
|
@@ -2730,6 +2939,23 @@
|
|
|
2730
2939
|
isEnabled: function () {
|
|
2731
2940
|
var pluginState = _getPluginState(thePlugin);
|
|
2732
2941
|
return !pluginState[strTeardown] && !pluginState[strDisabled];
|
|
2942
|
+
},
|
|
2943
|
+
remove: function (isAsync, removeCb) {
|
|
2944
|
+
if (isAsync === void 0) { isAsync = true; }
|
|
2945
|
+
var pluginsToRemove = [thePlugin];
|
|
2946
|
+
var unloadState = {
|
|
2947
|
+
reason: 1 ,
|
|
2948
|
+
isAsync: isAsync
|
|
2949
|
+
};
|
|
2950
|
+
_removePlugins(pluginsToRemove, unloadState, function (removed) {
|
|
2951
|
+
if (removed) {
|
|
2952
|
+
_initPluginChain(_self.config, {
|
|
2953
|
+
reason: 32 ,
|
|
2954
|
+
removed: pluginsToRemove
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
removeCb && removeCb(removed);
|
|
2958
|
+
});
|
|
2733
2959
|
}
|
|
2734
2960
|
};
|
|
2735
2961
|
}
|
|
@@ -2745,6 +2971,46 @@
|
|
|
2745
2971
|
}
|
|
2746
2972
|
return _pluginChain;
|
|
2747
2973
|
}
|
|
2974
|
+
function _removePlugins(thePlugins, unloadState, removeComplete) {
|
|
2975
|
+
if (thePlugins && thePlugins.length > 0) {
|
|
2976
|
+
var unloadChain = createTelemetryProxyChain(thePlugins, _self.config, _self);
|
|
2977
|
+
var unloadCtx = createProcessTelemetryUnloadContext(unloadChain, _self.config, _self);
|
|
2978
|
+
unloadCtx.onComplete(function () {
|
|
2979
|
+
var removed = false;
|
|
2980
|
+
var newConfigExtensions = [];
|
|
2981
|
+
arrForEach(_configExtensions, function (plugin, idx) {
|
|
2982
|
+
if (!_isPluginPresent(plugin, thePlugins)) {
|
|
2983
|
+
newConfigExtensions.push(plugin);
|
|
2984
|
+
}
|
|
2985
|
+
else {
|
|
2986
|
+
removed = true;
|
|
2987
|
+
}
|
|
2988
|
+
});
|
|
2989
|
+
_configExtensions = newConfigExtensions;
|
|
2990
|
+
var newChannelConfig = [];
|
|
2991
|
+
if (_channelConfig) {
|
|
2992
|
+
arrForEach(_channelConfig, function (queue, idx) {
|
|
2993
|
+
var newQueue = [];
|
|
2994
|
+
arrForEach(queue, function (channel) {
|
|
2995
|
+
if (!_isPluginPresent(channel, thePlugins)) {
|
|
2996
|
+
newQueue.push(channel);
|
|
2997
|
+
}
|
|
2998
|
+
else {
|
|
2999
|
+
removed = true;
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
newChannelConfig.push(newQueue);
|
|
3003
|
+
});
|
|
3004
|
+
_channelConfig = newChannelConfig;
|
|
3005
|
+
}
|
|
3006
|
+
removeComplete && removeComplete(removed);
|
|
3007
|
+
});
|
|
3008
|
+
unloadCtx.processNext(unloadState);
|
|
3009
|
+
}
|
|
3010
|
+
else {
|
|
3011
|
+
removeComplete(false);
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
2748
3014
|
function _flushInternalLogs() {
|
|
2749
3015
|
var queue = _self.logger ? _self.logger.queue : [];
|
|
2750
3016
|
if (queue) {
|
|
@@ -2779,6 +3045,25 @@
|
|
|
2779
3045
|
setValue(_self.config, "createPerfMgr", _createPerfManager);
|
|
2780
3046
|
}
|
|
2781
3047
|
}
|
|
3048
|
+
function _initExtConfig(config) {
|
|
3049
|
+
var extConfig = getSetValue(config, strExtensionConfig);
|
|
3050
|
+
extConfig.NotificationManager = _notificationManager;
|
|
3051
|
+
}
|
|
3052
|
+
function _doUpdate(updateState) {
|
|
3053
|
+
var updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self.config, _self);
|
|
3054
|
+
if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
|
|
3055
|
+
updateCtx.processNext(updateState);
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
function _logOrThrowError(message) {
|
|
3059
|
+
var logger = _self.logger;
|
|
3060
|
+
if (logger) {
|
|
3061
|
+
_throwInternal(logger, 2 , 73 , message);
|
|
3062
|
+
}
|
|
3063
|
+
else {
|
|
3064
|
+
throwError(message);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
2782
3067
|
});
|
|
2783
3068
|
}
|
|
2784
3069
|
return BaseCore;
|
|
@@ -2888,6 +3173,8 @@
|
|
|
2888
3173
|
var strOnPrefix = "on";
|
|
2889
3174
|
var strAttachEvent = "attachEvent";
|
|
2890
3175
|
var strAddEventHelper = "addEventListener";
|
|
3176
|
+
var strDetachEvent = "detachEvent";
|
|
3177
|
+
var strRemoveEventListener = "removeEventListener";
|
|
2891
3178
|
var strEvents = "events";
|
|
2892
3179
|
createUniqueNamespace("aiEvtPageHide");
|
|
2893
3180
|
createUniqueNamespace("aiEvtPageShow");
|
|
@@ -2900,12 +3187,12 @@
|
|
|
2900
3187
|
}
|
|
2901
3188
|
return name;
|
|
2902
3189
|
}
|
|
2903
|
-
function _getEvtNamespace(eventName,
|
|
2904
|
-
if (
|
|
3190
|
+
function _getEvtNamespace(eventName, evtNamespace) {
|
|
3191
|
+
if (evtNamespace) {
|
|
2905
3192
|
var theNamespace_1 = "";
|
|
2906
|
-
if (isArray(
|
|
3193
|
+
if (isArray(evtNamespace)) {
|
|
2907
3194
|
theNamespace_1 = "";
|
|
2908
|
-
arrForEach(
|
|
3195
|
+
arrForEach(evtNamespace, function (name) {
|
|
2909
3196
|
name = _normalizeNamespace(name);
|
|
2910
3197
|
if (name) {
|
|
2911
3198
|
if (name[0] !== ".") {
|
|
@@ -2916,7 +3203,7 @@
|
|
|
2916
3203
|
});
|
|
2917
3204
|
}
|
|
2918
3205
|
else {
|
|
2919
|
-
theNamespace_1 = _normalizeNamespace(
|
|
3206
|
+
theNamespace_1 = _normalizeNamespace(evtNamespace);
|
|
2920
3207
|
}
|
|
2921
3208
|
if (theNamespace_1) {
|
|
2922
3209
|
if (theNamespace_1[0] !== ".") {
|
|
@@ -2940,6 +3227,16 @@
|
|
|
2940
3227
|
}
|
|
2941
3228
|
return registeredEvents;
|
|
2942
3229
|
}
|
|
3230
|
+
function _doDetach(obj, evtName, handlerRef, useCapture) {
|
|
3231
|
+
if (obj && evtName && evtName.type) {
|
|
3232
|
+
if (obj[strRemoveEventListener]) {
|
|
3233
|
+
obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
|
|
3234
|
+
}
|
|
3235
|
+
else if (obj[strDetachEvent]) {
|
|
3236
|
+
obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
2943
3240
|
function _doAttach(obj, evtName, handlerRef, useCapture) {
|
|
2944
3241
|
var result = false;
|
|
2945
3242
|
if (obj && evtName && evtName.type && handlerRef) {
|
|
@@ -2954,6 +3251,49 @@
|
|
|
2954
3251
|
}
|
|
2955
3252
|
return result;
|
|
2956
3253
|
}
|
|
3254
|
+
function _doUnregister(target, events, evtName, unRegFn) {
|
|
3255
|
+
var idx = events.length;
|
|
3256
|
+
while (idx--) {
|
|
3257
|
+
var theEvent = events[idx];
|
|
3258
|
+
if (theEvent) {
|
|
3259
|
+
if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
|
|
3260
|
+
if (!unRegFn || unRegFn(theEvent)) {
|
|
3261
|
+
_doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
|
|
3262
|
+
events.splice(idx, 1);
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
function _unregisterEvents(target, evtName, unRegFn) {
|
|
3269
|
+
if (evtName.type) {
|
|
3270
|
+
_doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
|
|
3271
|
+
}
|
|
3272
|
+
else {
|
|
3273
|
+
var eventCache = elmNodeData.get(target, strEvents, {});
|
|
3274
|
+
objForEachKey(eventCache, function (evtType, events) {
|
|
3275
|
+
_doUnregister(target, events, evtName, unRegFn);
|
|
3276
|
+
});
|
|
3277
|
+
if (objKeys(eventCache).length === 0) {
|
|
3278
|
+
elmNodeData.kill(target, strEvents);
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
function mergeEvtNamespace(theNamespace, namespaces) {
|
|
3283
|
+
var newNamespaces;
|
|
3284
|
+
if (namespaces) {
|
|
3285
|
+
if (isArray(namespaces)) {
|
|
3286
|
+
newNamespaces = [theNamespace].concat(namespaces);
|
|
3287
|
+
}
|
|
3288
|
+
else {
|
|
3289
|
+
newNamespaces = [theNamespace, namespaces];
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
else {
|
|
3293
|
+
newNamespaces = theNamespace;
|
|
3294
|
+
}
|
|
3295
|
+
return newNamespaces;
|
|
3296
|
+
}
|
|
2957
3297
|
function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
|
|
2958
3298
|
if (useCapture === void 0) { useCapture = false; }
|
|
2959
3299
|
var result = false;
|
|
@@ -2976,9 +3316,26 @@
|
|
|
2976
3316
|
}
|
|
2977
3317
|
return result;
|
|
2978
3318
|
}
|
|
2979
|
-
function
|
|
3319
|
+
function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
|
|
2980
3320
|
if (useCapture === void 0) { useCapture = false; }
|
|
2981
|
-
|
|
3321
|
+
if (target) {
|
|
3322
|
+
try {
|
|
3323
|
+
var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
|
|
3324
|
+
var found_1 = false;
|
|
3325
|
+
_unregisterEvents(target, evtName_1, function (regEvent) {
|
|
3326
|
+
if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
|
|
3327
|
+
found_1 = true;
|
|
3328
|
+
return true;
|
|
3329
|
+
}
|
|
3330
|
+
return false;
|
|
3331
|
+
});
|
|
3332
|
+
if (!found_1) {
|
|
3333
|
+
_doDetach(target, evtName_1, handlerRef, useCapture);
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
catch (e) {
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
2982
3339
|
}
|
|
2983
3340
|
function addEventHandler(eventName, callback, evtNamespace) {
|
|
2984
3341
|
var result = false;
|
|
@@ -3218,7 +3575,7 @@
|
|
|
3218
3575
|
name = strTrim(name.toString());
|
|
3219
3576
|
if (name.length > 150 ) {
|
|
3220
3577
|
nameTrunc = name.substring(0, 150 );
|
|
3221
|
-
logger
|
|
3578
|
+
_throwInternal(logger, 2 , _InternalMessageId.NameTooLong, "name is too long. It has been truncated to " + 150 + " characters.", { name: name }, true);
|
|
3222
3579
|
}
|
|
3223
3580
|
}
|
|
3224
3581
|
return nameTrunc || name;
|
|
@@ -3231,7 +3588,7 @@
|
|
|
3231
3588
|
value = strTrim(value);
|
|
3232
3589
|
if (value.toString().length > maxLength) {
|
|
3233
3590
|
valueTrunc = value.toString().substring(0, maxLength);
|
|
3234
|
-
logger
|
|
3591
|
+
_throwInternal(logger, 2 , _InternalMessageId.StringValueTooLong, "string value is too long. It has been truncated to " + maxLength + " characters.", { value: value }, true);
|
|
3235
3592
|
}
|
|
3236
3593
|
}
|
|
3237
3594
|
return valueTrunc || value;
|
|
@@ -3244,7 +3601,7 @@
|
|
|
3244
3601
|
if (message) {
|
|
3245
3602
|
if (message.length > 32768 ) {
|
|
3246
3603
|
messageTrunc = message.substring(0, 32768 );
|
|
3247
|
-
logger
|
|
3604
|
+
_throwInternal(logger, 2 , _InternalMessageId.MessageTruncated, "message is too long, it has been truncated to " + 32768 + " characters.", { message: message }, true);
|
|
3248
3605
|
}
|
|
3249
3606
|
}
|
|
3250
3607
|
return messageTrunc || message;
|
|
@@ -3255,7 +3612,7 @@
|
|
|
3255
3612
|
var value = "" + exception;
|
|
3256
3613
|
if (value.length > 32768 ) {
|
|
3257
3614
|
exceptionTrunc = value.substring(0, 32768 );
|
|
3258
|
-
logger
|
|
3615
|
+
_throwInternal(logger, 2 , _InternalMessageId.ExceptionTruncated, "exception is too long, it has been truncated to " + 32768 + " characters.", { exception: exception }, true);
|
|
3259
3616
|
}
|
|
3260
3617
|
}
|
|
3261
3618
|
return exceptionTrunc || exception;
|
|
@@ -3269,7 +3626,7 @@
|
|
|
3269
3626
|
value = getJSON().stringify(value);
|
|
3270
3627
|
}
|
|
3271
3628
|
catch (e) {
|
|
3272
|
-
logger
|
|
3629
|
+
_throwInternal(logger, 2 , _InternalMessageId.CannotSerializeObjectNonSerializable, "custom property is not valid", { exception: e }, true);
|
|
3273
3630
|
}
|
|
3274
3631
|
}
|
|
3275
3632
|
value = dataSanitizeString(logger, value, 8192 );
|
|
@@ -3300,7 +3657,7 @@
|
|
|
3300
3657
|
input = strTrim(input);
|
|
3301
3658
|
if (input.length > maxLength) {
|
|
3302
3659
|
inputTrunc = input.substring(0, maxLength);
|
|
3303
|
-
logger
|
|
3660
|
+
_throwInternal(logger, 2 , _msgId, "input is too long, it has been truncated to " + maxLength + " characters.", { data: input }, true);
|
|
3304
3661
|
}
|
|
3305
3662
|
}
|
|
3306
3663
|
return inputTrunc || input;
|
|
@@ -3369,8 +3726,8 @@
|
|
|
3369
3726
|
}
|
|
3370
3727
|
return null;
|
|
3371
3728
|
}
|
|
3372
|
-
function utlCanUseSessionStorage() {
|
|
3373
|
-
if (_canUseSessionStorage === undefined) {
|
|
3729
|
+
function utlCanUseSessionStorage(reset) {
|
|
3730
|
+
if (reset || _canUseSessionStorage === undefined) {
|
|
3374
3731
|
_canUseSessionStorage = !!_getVerifiedStorageObject(StorageType.SessionStorage);
|
|
3375
3732
|
}
|
|
3376
3733
|
return _canUseSessionStorage;
|
|
@@ -3383,7 +3740,7 @@
|
|
|
3383
3740
|
}
|
|
3384
3741
|
catch (e) {
|
|
3385
3742
|
_canUseSessionStorage = false;
|
|
3386
|
-
logger
|
|
3743
|
+
_throwInternal(logger, 2 , _InternalMessageId.BrowserCannotReadSessionStorage, "Browser failed read of session storage. " + getExceptionName(e), { exception: dumpObj(e) });
|
|
3387
3744
|
}
|
|
3388
3745
|
}
|
|
3389
3746
|
return null;
|
|
@@ -3397,7 +3754,7 @@
|
|
|
3397
3754
|
}
|
|
3398
3755
|
catch (e) {
|
|
3399
3756
|
_canUseSessionStorage = false;
|
|
3400
|
-
logger
|
|
3757
|
+
_throwInternal(logger, 2 , _InternalMessageId.BrowserCannotWriteSessionStorage, "Browser failed write to session storage. " + getExceptionName(e), { exception: dumpObj(e) });
|
|
3401
3758
|
}
|
|
3402
3759
|
}
|
|
3403
3760
|
return false;
|
|
@@ -4683,7 +5040,7 @@
|
|
|
4683
5040
|
}
|
|
4684
5041
|
}
|
|
4685
5042
|
var EnvelopeCreator = {
|
|
4686
|
-
Version: "2.8.0-beta.2203-
|
|
5043
|
+
Version: "2.8.0-beta.2203-05"
|
|
4687
5044
|
};
|
|
4688
5045
|
function DependencyEnvelopeCreator(logger, telemetryItem, customUndefinedValue) {
|
|
4689
5046
|
EnvelopeCreatorInit(logger, telemetryItem);
|
|
@@ -4978,65 +5335,81 @@
|
|
|
4978
5335
|
return Serializer;
|
|
4979
5336
|
}());
|
|
4980
5337
|
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
target.onoffline = _setOffline;
|
|
5000
|
-
isListening = true;
|
|
5001
|
-
}
|
|
5002
|
-
}
|
|
5003
|
-
if (isListening) {
|
|
5004
|
-
var _navigator = getNavigator();
|
|
5005
|
-
if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
|
|
5006
|
-
_onlineStatus = _navigator.onLine;
|
|
5007
|
-
}
|
|
5338
|
+
function _disableEvents(target, evtNamespace) {
|
|
5339
|
+
eventOff(target, null, null, evtNamespace);
|
|
5340
|
+
}
|
|
5341
|
+
function createOfflineListener(parentEvtNamespace) {
|
|
5342
|
+
var _document = getDocument();
|
|
5343
|
+
var _navigator = getNavigator();
|
|
5344
|
+
var _isListening = false;
|
|
5345
|
+
var _onlineStatus = true;
|
|
5346
|
+
var _evtNamespace = mergeEvtNamespace(createUniqueNamespace("OfflineListener"), parentEvtNamespace);
|
|
5347
|
+
try {
|
|
5348
|
+
if (_enableEvents(getWindow())) {
|
|
5349
|
+
_isListening = true;
|
|
5350
|
+
}
|
|
5351
|
+
if (_document) {
|
|
5352
|
+
var target = _document.body || _document;
|
|
5353
|
+
if (target.ononline) {
|
|
5354
|
+
if (_enableEvents(target)) {
|
|
5355
|
+
_isListening = true;
|
|
5008
5356
|
}
|
|
5009
5357
|
}
|
|
5010
|
-
|
|
5011
|
-
|
|
5358
|
+
}
|
|
5359
|
+
if (_isListening) {
|
|
5360
|
+
if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
|
|
5361
|
+
_onlineStatus = _navigator.onLine;
|
|
5012
5362
|
}
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
};
|
|
5025
|
-
_self.isOffline = function () {
|
|
5026
|
-
return !_self.isOnline();
|
|
5027
|
-
};
|
|
5028
|
-
function _setOnline() {
|
|
5029
|
-
_onlineStatus = true;
|
|
5363
|
+
}
|
|
5364
|
+
}
|
|
5365
|
+
catch (e) {
|
|
5366
|
+
_isListening = false;
|
|
5367
|
+
}
|
|
5368
|
+
function _enableEvents(target) {
|
|
5369
|
+
var enabled = false;
|
|
5370
|
+
if (target) {
|
|
5371
|
+
enabled = eventOn(target, "online", _setOnline, _evtNamespace);
|
|
5372
|
+
if (enabled) {
|
|
5373
|
+
eventOn(target, "offline", _setOffline, _evtNamespace);
|
|
5030
5374
|
}
|
|
5031
|
-
|
|
5032
|
-
|
|
5375
|
+
}
|
|
5376
|
+
return enabled;
|
|
5377
|
+
}
|
|
5378
|
+
function _setOnline() {
|
|
5379
|
+
_onlineStatus = true;
|
|
5380
|
+
}
|
|
5381
|
+
function _setOffline() {
|
|
5382
|
+
_onlineStatus = false;
|
|
5383
|
+
}
|
|
5384
|
+
function _isOnline() {
|
|
5385
|
+
var result = true;
|
|
5386
|
+
if (_isListening) {
|
|
5387
|
+
result = _onlineStatus;
|
|
5388
|
+
}
|
|
5389
|
+
else if (_navigator && !isNullOrUndefined(_navigator.onLine)) {
|
|
5390
|
+
result = _navigator.onLine;
|
|
5391
|
+
}
|
|
5392
|
+
return result;
|
|
5393
|
+
}
|
|
5394
|
+
function _unload() {
|
|
5395
|
+
var win = getWindow();
|
|
5396
|
+
if (win && _isListening) {
|
|
5397
|
+
_disableEvents(win, _evtNamespace);
|
|
5398
|
+
if (_document) {
|
|
5399
|
+
var target = _document.body || _document;
|
|
5400
|
+
if (!isUndefined(target.ononline)) {
|
|
5401
|
+
_disableEvents(target, _evtNamespace);
|
|
5402
|
+
}
|
|
5033
5403
|
}
|
|
5034
|
-
|
|
5404
|
+
_isListening = false;
|
|
5405
|
+
}
|
|
5035
5406
|
}
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5407
|
+
return {
|
|
5408
|
+
isOnline: _isOnline,
|
|
5409
|
+
isListening: function () { return _isListening; },
|
|
5410
|
+
unload: _unload
|
|
5411
|
+
};
|
|
5412
|
+
}
|
|
5040
5413
|
|
|
5041
5414
|
var MIN_INPUT_LENGTH = 8;
|
|
5042
5415
|
var HashCodeScoreGenerator = /** @class */ (function () {
|
|
@@ -5164,22 +5537,22 @@
|
|
|
5164
5537
|
var _this = _super.call(this) || this;
|
|
5165
5538
|
_this.priority = 1001;
|
|
5166
5539
|
_this.identifier = BreezeChannelIdentifier;
|
|
5540
|
+
_this._senderConfig = _getDefaultAppInsightsChannelConfig();
|
|
5167
5541
|
var _consecutiveErrors;
|
|
5168
5542
|
var _retryAt;
|
|
5169
5543
|
var _lastSend;
|
|
5170
|
-
var _paused
|
|
5544
|
+
var _paused;
|
|
5171
5545
|
var _timeoutHandle;
|
|
5172
5546
|
var _serializer;
|
|
5173
5547
|
var _stamp_specific_redirects;
|
|
5174
|
-
var _headers
|
|
5548
|
+
var _headers;
|
|
5175
5549
|
var _syncFetchPayload = 0;
|
|
5176
5550
|
var _fallbackSender;
|
|
5177
5551
|
var _syncUnloadSender;
|
|
5178
|
-
|
|
5552
|
+
var _offlineListener;
|
|
5553
|
+
var _evtNamespace;
|
|
5179
5554
|
dynamicProto(Sender, _this, function (_self, _base) {
|
|
5180
|
-
|
|
5181
|
-
throwError("Method not implemented.");
|
|
5182
|
-
}
|
|
5555
|
+
_initDefaults();
|
|
5183
5556
|
_self.pause = function () {
|
|
5184
5557
|
_clearScheduledTimer();
|
|
5185
5558
|
_paused = true;
|
|
@@ -5202,7 +5575,7 @@
|
|
|
5202
5575
|
_self.triggerSend(isAsync, null, sendReason || 1 );
|
|
5203
5576
|
}
|
|
5204
5577
|
catch (e) {
|
|
5205
|
-
_self.diagLog()
|
|
5578
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.FlushFailed, "flush failed, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
5206
5579
|
}
|
|
5207
5580
|
}
|
|
5208
5581
|
};
|
|
@@ -5213,7 +5586,7 @@
|
|
|
5213
5586
|
_self.triggerSend(true, _doUnloadSend, 2 );
|
|
5214
5587
|
}
|
|
5215
5588
|
catch (e) {
|
|
5216
|
-
_self.diagLog()
|
|
5589
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.FailedToSendQueuedTelemetry, "failed to flush with beacon sender on page unload, telemetry will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
5217
5590
|
}
|
|
5218
5591
|
}
|
|
5219
5592
|
else {
|
|
@@ -5221,7 +5594,6 @@
|
|
|
5221
5594
|
}
|
|
5222
5595
|
}
|
|
5223
5596
|
};
|
|
5224
|
-
_self.teardown = _notImplemented;
|
|
5225
5597
|
_self.addHeader = function (name, value) {
|
|
5226
5598
|
_headers[name] = value;
|
|
5227
5599
|
};
|
|
@@ -5236,6 +5608,8 @@
|
|
|
5236
5608
|
_self._sender = null;
|
|
5237
5609
|
_stamp_specific_redirects = 0;
|
|
5238
5610
|
var diagLog = _self.diagLog();
|
|
5611
|
+
_evtNamespace = mergeEvtNamespace(createUniqueNamespace("Sender"), core.evtNamespace && core.evtNamespace());
|
|
5612
|
+
_offlineListener = createOfflineListener(_evtNamespace);
|
|
5239
5613
|
var defaultConfig = _getDefaultAppInsightsChannelConfig();
|
|
5240
5614
|
objForEachKey(defaultConfig, function (field, value) {
|
|
5241
5615
|
_self._senderConfig[field] = function () { return ctx.getConfig(identifier, field, value()); };
|
|
@@ -5244,7 +5618,7 @@
|
|
|
5244
5618
|
? new SessionStorageSendBuffer(diagLog, _self._senderConfig) : new ArraySendBuffer(diagLog, _self._senderConfig);
|
|
5245
5619
|
_self._sample = new Sample(_self._senderConfig.samplingPercentage(), diagLog);
|
|
5246
5620
|
if (!_validateInstrumentationKey(config)) {
|
|
5247
|
-
diagLog
|
|
5621
|
+
_throwInternal(diagLog, LoggingSeverity.CRITICAL, _InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key " + config.instrumentationKey);
|
|
5248
5622
|
}
|
|
5249
5623
|
if (!isInternalApplicationInsightsEndpoint(_self._senderConfig.endpointUrl()) && _self._senderConfig.customHeaders() && _self._senderConfig.customHeaders().length > 0) {
|
|
5250
5624
|
arrForEach(_self._senderConfig.customHeaders(), function (customHeader) {
|
|
@@ -5290,22 +5664,22 @@
|
|
|
5290
5664
|
return;
|
|
5291
5665
|
}
|
|
5292
5666
|
if (!telemetryItem) {
|
|
5293
|
-
itemCtx.diagLog()
|
|
5667
|
+
_throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CannotSendEmptyTelemetry, "Cannot send empty telemetry");
|
|
5294
5668
|
return;
|
|
5295
5669
|
}
|
|
5296
5670
|
if (telemetryItem.baseData && !telemetryItem.baseType) {
|
|
5297
|
-
itemCtx.diagLog()
|
|
5671
|
+
_throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.InvalidEvent, "Cannot send telemetry without baseData and baseType");
|
|
5298
5672
|
return;
|
|
5299
5673
|
}
|
|
5300
5674
|
if (!telemetryItem.baseType) {
|
|
5301
5675
|
telemetryItem.baseType = "EventData";
|
|
5302
5676
|
}
|
|
5303
5677
|
if (!_self._sender) {
|
|
5304
|
-
itemCtx.diagLog()
|
|
5678
|
+
_throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender was not initialized");
|
|
5305
5679
|
return;
|
|
5306
5680
|
}
|
|
5307
5681
|
if (!_isSampledIn(telemetryItem)) {
|
|
5308
|
-
itemCtx.diagLog()
|
|
5682
|
+
_throwInternal(itemCtx.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TelemetrySampledAndNotSent, "Telemetry item was sampled out and not sent", { SampleRate: _self._sample.sampleRate });
|
|
5309
5683
|
return;
|
|
5310
5684
|
}
|
|
5311
5685
|
else {
|
|
@@ -5315,7 +5689,7 @@
|
|
|
5315
5689
|
var defaultEnvelopeIkey = telemetryItem.iKey || _self._senderConfig.instrumentationKey();
|
|
5316
5690
|
var aiEnvelope_1 = Sender.constructEnvelope(telemetryItem, defaultEnvelopeIkey, itemCtx.diagLog(), convertUndefined);
|
|
5317
5691
|
if (!aiEnvelope_1) {
|
|
5318
|
-
itemCtx.diagLog()
|
|
5692
|
+
_throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.CreateEnvelopeError, "Unable to create an AppInsights envelope");
|
|
5319
5693
|
return;
|
|
5320
5694
|
}
|
|
5321
5695
|
var doNotSendItem_1 = false;
|
|
@@ -5328,7 +5702,7 @@
|
|
|
5328
5702
|
}
|
|
5329
5703
|
}
|
|
5330
5704
|
catch (e) {
|
|
5331
|
-
itemCtx.diagLog()
|
|
5705
|
+
_throwInternal(itemCtx.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e), { exception: dumpObj(e) }, true);
|
|
5332
5706
|
}
|
|
5333
5707
|
});
|
|
5334
5708
|
delete telemetryItem.tags[ProcessLegacy];
|
|
@@ -5346,7 +5720,7 @@
|
|
|
5346
5720
|
_setupTimer();
|
|
5347
5721
|
}
|
|
5348
5722
|
catch (e) {
|
|
5349
|
-
itemCtx.diagLog()
|
|
5723
|
+
_throwInternal(itemCtx.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.FailedAddingTelemetryToBuffer, "Failed adding telemetry to the sender's buffer, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
5350
5724
|
}
|
|
5351
5725
|
_self.processNext(telemetryItem, itemCtx);
|
|
5352
5726
|
};
|
|
@@ -5381,13 +5755,18 @@
|
|
|
5381
5755
|
catch (e) {
|
|
5382
5756
|
var ieVer = getIEVersion();
|
|
5383
5757
|
if (!ieVer || ieVer > 9) {
|
|
5384
|
-
_self.diagLog()
|
|
5758
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.TransmissionFailed, "Telemetry transmission failed, some telemetry will be lost: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
5385
5759
|
}
|
|
5386
5760
|
}
|
|
5387
5761
|
}
|
|
5388
5762
|
};
|
|
5763
|
+
_self._doTeardown = function (unloadCtx, unloadState) {
|
|
5764
|
+
_self.onunloadFlush();
|
|
5765
|
+
_offlineListener.unload();
|
|
5766
|
+
_initDefaults();
|
|
5767
|
+
};
|
|
5389
5768
|
_self._onError = function (payload, message, event) {
|
|
5390
|
-
_self.diagLog()
|
|
5769
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.OnError, "Failed to send telemetry.", { message: message });
|
|
5391
5770
|
_self._buffer.clearSent(payload);
|
|
5392
5771
|
};
|
|
5393
5772
|
_self._onPartialSuccess = function (payload, results) {
|
|
@@ -5412,7 +5791,7 @@
|
|
|
5412
5791
|
}
|
|
5413
5792
|
if (retry.length > 0) {
|
|
5414
5793
|
_resendPayload(retry);
|
|
5415
|
-
_self.diagLog()
|
|
5794
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, "Partial success. " +
|
|
5416
5795
|
"Delivered: " + payload.length + ", Failed: " + failed.length +
|
|
5417
5796
|
". Will retry to send " + retry.length + " our of " + results.itemsReceived + " items");
|
|
5418
5797
|
}
|
|
@@ -5457,18 +5836,18 @@
|
|
|
5457
5836
|
}
|
|
5458
5837
|
if (!_self._senderConfig.isRetryDisabled() && _isRetriable(status)) {
|
|
5459
5838
|
_resendPayload(payload);
|
|
5460
|
-
_self.diagLog()
|
|
5839
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
|
|
5461
5840
|
"Response code " + status + ". Will retry to send " + payload.length + " items.");
|
|
5462
5841
|
}
|
|
5463
5842
|
else {
|
|
5464
5843
|
_self._onError(payload, errorMessage);
|
|
5465
5844
|
}
|
|
5466
5845
|
}
|
|
5467
|
-
else if (
|
|
5846
|
+
else if (_offlineListener && !_offlineListener.isOnline()) {
|
|
5468
5847
|
if (!_self._senderConfig.isRetryDisabled()) {
|
|
5469
5848
|
var offlineBackOffMultiplier = 10;
|
|
5470
5849
|
_resendPayload(payload, offlineBackOffMultiplier);
|
|
5471
|
-
_self.diagLog()
|
|
5850
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". Offline - Response Code: ".concat(status, ". Offline status: ").concat(!_offlineListener.isOnline(), ". Will retry to send ").concat(payload.length, " items."));
|
|
5472
5851
|
}
|
|
5473
5852
|
}
|
|
5474
5853
|
else {
|
|
@@ -5535,8 +5914,8 @@
|
|
|
5535
5914
|
}
|
|
5536
5915
|
}
|
|
5537
5916
|
if (droppedPayload.length > 0) {
|
|
5538
|
-
_fallbackSender(droppedPayload, true);
|
|
5539
|
-
_self.diagLog()
|
|
5917
|
+
_fallbackSender && _fallbackSender(droppedPayload, true);
|
|
5918
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with normal sender.");
|
|
5540
5919
|
}
|
|
5541
5920
|
}
|
|
5542
5921
|
}
|
|
@@ -5577,7 +5956,7 @@
|
|
|
5577
5956
|
}
|
|
5578
5957
|
else {
|
|
5579
5958
|
_fallbackSender && _fallbackSender(payload, true);
|
|
5580
|
-
_self.diagLog()
|
|
5959
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " + "Failed to send telemetry with Beacon API, retried with xhrSender.");
|
|
5581
5960
|
}
|
|
5582
5961
|
}
|
|
5583
5962
|
}
|
|
@@ -5668,7 +6047,7 @@
|
|
|
5668
6047
|
}
|
|
5669
6048
|
}
|
|
5670
6049
|
catch (e) {
|
|
5671
|
-
_self.diagLog()
|
|
6050
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.InvalidBackendResponse, "Cannot parse the response. " + getExceptionName(e), {
|
|
5672
6051
|
response: response
|
|
5673
6052
|
});
|
|
5674
6053
|
}
|
|
@@ -5739,7 +6118,7 @@
|
|
|
5739
6118
|
xdr.onerror = function (event) { return _self._onError(payload, _formatErrorMessageXdr(xdr), event); };
|
|
5740
6119
|
var hostingProtocol = _window && _window.location && _window.location.protocol || "";
|
|
5741
6120
|
if (_self._senderConfig.endpointUrl().lastIndexOf(hostingProtocol, 0) !== 0) {
|
|
5742
|
-
_self.diagLog()
|
|
6121
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.WARNING, _InternalMessageId.TransmissionFailed, ". " +
|
|
5743
6122
|
"Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");
|
|
5744
6123
|
buffer.clear();
|
|
5745
6124
|
return;
|
|
@@ -5770,7 +6149,7 @@
|
|
|
5770
6149
|
manager.eventsSendRequest(sendRequest, isAsync);
|
|
5771
6150
|
}
|
|
5772
6151
|
catch (e) {
|
|
5773
|
-
_self.diagLog()
|
|
6152
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.NotificationException, "send request notification failed: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
5774
6153
|
}
|
|
5775
6154
|
}
|
|
5776
6155
|
}
|
|
@@ -5783,6 +6162,25 @@
|
|
|
5783
6162
|
var regexp = new RegExp(UUID_Regex);
|
|
5784
6163
|
return regexp.test(config.instrumentationKey);
|
|
5785
6164
|
}
|
|
6165
|
+
function _initDefaults() {
|
|
6166
|
+
_self._sender = null;
|
|
6167
|
+
_self._buffer = null;
|
|
6168
|
+
_self._appId = null;
|
|
6169
|
+
_self._sample = null;
|
|
6170
|
+
_headers = {};
|
|
6171
|
+
_offlineListener = null;
|
|
6172
|
+
_consecutiveErrors = 0;
|
|
6173
|
+
_retryAt = null;
|
|
6174
|
+
_lastSend = null;
|
|
6175
|
+
_paused = false;
|
|
6176
|
+
_timeoutHandle = null;
|
|
6177
|
+
_serializer = null;
|
|
6178
|
+
_stamp_specific_redirects = 0;
|
|
6179
|
+
_syncFetchPayload = 0;
|
|
6180
|
+
_fallbackSender = null;
|
|
6181
|
+
_syncUnloadSender = null;
|
|
6182
|
+
_evtNamespace = null;
|
|
6183
|
+
}
|
|
5786
6184
|
});
|
|
5787
6185
|
return _this;
|
|
5788
6186
|
}
|
|
@@ -5853,4 +6251,4 @@
|
|
|
5853
6251
|
(function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
|
|
5854
6252
|
|
|
5855
6253
|
}));
|
|
5856
|
-
//# sourceMappingURL=aib.2.8.0-beta.2203-
|
|
6254
|
+
//# sourceMappingURL=aib.2.8.0-beta.2203-05.js.map
|