@microsoft/applicationinsights-core-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-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.
Files changed (160) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1999 -793
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +16363 -9167
  7. package/dist/applicationinsights-core-js.api.md +425 -48
  8. package/dist/applicationinsights-core-js.d.ts +784 -123
  9. package/dist/applicationinsights-core-js.js +1999 -793
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +784 -123
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +3 -69
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  16. package/dist-esm/JavaScriptSDK/BaseCore.js +496 -99
  17. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +120 -21
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/ChannelController.js +202 -87
  21. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js +4 -4
  24. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js +7 -148
  26. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +93 -0
  28. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -0
  29. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  30. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +25 -12
  31. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/EnvUtils.js +13 -12
  33. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/EventHelpers.js +477 -0
  35. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -0
  36. package/dist-esm/JavaScriptSDK/HelperFuncs.js +89 -86
  37. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +3 -1
  39. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  40. package/dist-esm/JavaScriptSDK/InternalConstants.js +28 -0
  41. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -0
  42. package/dist-esm/JavaScriptSDK/NotificationManager.js +37 -42
  43. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  44. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  45. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +430 -119
  46. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/RandomHelper.js +30 -4
  48. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +60 -14
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  51. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +81 -0
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -0
  53. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +33 -0
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -0
  55. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +90 -96
  57. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +8 -0
  60. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js.map +1 -0
  61. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +8 -0
  62. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
  63. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -2
  64. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +6 -0
  77. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +1 -0
  78. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -2
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js.map +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +8 -0
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js.map +1 -0
  84. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
  85. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
  86. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +6 -0
  87. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -0
  88. package/dist-esm/applicationinsights-core-js.js +12 -7
  89. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  90. package/package.json +2 -2
  91. package/src/JavaScriptSDK/AppInsightsCore.ts +2 -101
  92. package/src/JavaScriptSDK/BaseCore.ts +696 -120
  93. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +205 -31
  94. package/src/JavaScriptSDK/ChannelController.ts +242 -103
  95. package/src/JavaScriptSDK/CookieMgr.ts +7 -5
  96. package/src/JavaScriptSDK/CoreUtils.ts +8 -172
  97. package/src/JavaScriptSDK/DataCacheHelper.ts +106 -0
  98. package/src/JavaScriptSDK/DiagnosticLogger.ts +27 -12
  99. package/src/JavaScriptSDK/EnvUtils.ts +13 -12
  100. package/src/JavaScriptSDK/EventHelpers.ts +550 -0
  101. package/src/JavaScriptSDK/HelperFuncs.ts +123 -97
  102. package/src/JavaScriptSDK/InstrumentHooks.ts +4 -2
  103. package/src/JavaScriptSDK/InternalConstants.ts +26 -0
  104. package/src/JavaScriptSDK/NotificationManager.ts +34 -37
  105. package/src/JavaScriptSDK/PerfManager.ts +4 -7
  106. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +543 -134
  107. package/src/JavaScriptSDK/RandomHelper.ts +35 -3
  108. package/src/JavaScriptSDK/TelemetryHelpers.ts +83 -21
  109. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +111 -0
  110. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +46 -0
  111. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +184 -87
  112. package/src/JavaScriptSDK.Enums/SendRequestReason.ts +5 -0
  113. package/src/JavaScriptSDK.Enums/TelemetryUnloadReason.ts +27 -0
  114. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +27 -0
  115. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +82 -2
  116. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +16 -5
  117. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +16 -6
  118. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +94 -14
  119. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +16 -0
  120. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +28 -10
  121. package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +9 -11
  122. package/src/JavaScriptSDK.Interfaces/ITelemetryUnloadState.ts +10 -0
  123. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
  124. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +17 -0
  125. package/types/JavaScriptSDK/AppInsightsCore.d.ts +0 -21
  126. package/types/JavaScriptSDK/BaseCore.d.ts +81 -3
  127. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +53 -10
  128. package/types/JavaScriptSDK/ChannelController.d.ts +16 -17
  129. package/types/JavaScriptSDK/CoreUtils.d.ts +1 -48
  130. package/types/JavaScriptSDK/DataCacheHelper.d.ts +13 -0
  131. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +10 -0
  132. package/types/JavaScriptSDK/EventHelpers.d.ts +154 -0
  133. package/types/JavaScriptSDK/HelperFuncs.d.ts +33 -32
  134. package/types/JavaScriptSDK/InternalConstants.d.ts +20 -0
  135. package/types/JavaScriptSDK/PerfManager.d.ts +1 -1
  136. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +69 -6
  137. package/types/JavaScriptSDK/RandomHelper.d.ts +6 -0
  138. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +23 -3
  139. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +16 -0
  140. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +11 -0
  141. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +91 -2
  142. package/types/JavaScriptSDK.Enums/SendRequestReason.d.ts +4 -0
  143. package/types/JavaScriptSDK.Enums/TelemetryUnloadReason.d.ts +21 -0
  144. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +20 -0
  145. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +72 -1
  146. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +16 -5
  147. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +9 -0
  148. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +82 -11
  149. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +13 -0
  150. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +25 -8
  151. package/types/JavaScriptSDK.Interfaces/ITelemetryPluginChain.d.ts +9 -10
  152. package/types/JavaScriptSDK.Interfaces/ITelemetryUnloadState.d.ts +6 -0
  153. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
  154. package/types/JavaScriptSDK.Interfaces/IUnloadableComponent.d.ts +13 -0
  155. package/types/applicationinsights-core-js.d.ts +18 -9
  156. package/types/tsdoc-metadata.json +1 -1
  157. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +0 -76
  158. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +0 -1
  159. package/src/JavaScriptSDK/TelemetryPluginChain.ts +0 -120
  160. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +0 -32
@@ -1,105 +1,220 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.8.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - Core, 2.8.0-nightly.2204-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
-
7
- "use strict";
8
- import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
9
- import dynamicProto from "@microsoft/dynamicproto-js";
10
- import { BaseTelemetryPlugin } from "./BaseTelemetryPlugin";
11
- import { ProcessTelemetryContext } from "./ProcessTelemetryContext";
6
+ //
7
+ import { arrForEach, isArray, objFreeze, throwError } from "./HelperFuncs";
8
+ import { strPause, strProcessNext, strResume, strTeardown } from "./InternalConstants";
9
+ import { createProcessTelemetryContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
12
10
  import { initializePlugins } from "./TelemetryHelpers";
13
- import { arrForEach, objDefineAccessors, throwError } from "./HelperFuncs";
14
- var ChannelControllerPriority = 500;
15
- var ChannelValidationMessage = "Channel has invalid priority";
16
- var ChannelController = /** @class */ (function (_super) {
17
- __extends(ChannelController, _super);
18
- function ChannelController() {
19
- var _this = _super.call(this) || this;
20
- _this.identifier = "ChannelControllerPlugin";
21
- _this.priority = ChannelControllerPriority; // in reserved range 100 to 200
22
- var _channelQueue;
23
- dynamicProto(ChannelController, _this, function (_self, _base) {
24
- _self.setNextPlugin = function (next) {
25
- // The Channel controller is last in pipeline
26
- };
27
- _self.processTelemetry = function (item, itemCtx) {
28
- if (_channelQueue) {
29
- arrForEach(_channelQueue, function (queues) {
30
- // pass on to first item in queue
31
- if (queues.length > 0) {
32
- // Copying the item context as we could have mutiple chains that are executing asynchronously
33
- // and calling _getDefTelCtx as it's possible that the caller doesn't pass any context
34
- var chainCtx = _this._getTelCtx(itemCtx).createNew(queues);
35
- chainCtx.processNext(item);
36
- }
37
- });
11
+ export var ChannelControllerPriority = 500;
12
+ var ChannelValidationMessage = "Channel has invalid priority - ";
13
+ function _addChannelQueue(channelQueue, queue, config, core) {
14
+ if (queue && isArray(queue) && queue.length > 0) {
15
+ queue = queue.sort(function (a, b) {
16
+ return a.priority - b.priority;
17
+ });
18
+ arrForEach(queue, function (queueItem) {
19
+ if (queueItem.priority < ChannelControllerPriority) {
20
+ throwError(ChannelValidationMessage + queueItem.identifier);
21
+ }
22
+ });
23
+ channelQueue.push({
24
+ queue: objFreeze(queue),
25
+ chain: createTelemetryProxyChain(queue, config, core)
26
+ });
27
+ }
28
+ }
29
+ export function createChannelControllerPlugin(channelQueue, core) {
30
+ var _a;
31
+ function _getTelCtx() {
32
+ return createProcessTelemetryContext(null, core.config, core, null);
33
+ }
34
+ function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
35
+ var waiting = theChannels ? (theChannels.length + 1) : 1;
36
+ function _runChainOnComplete() {
37
+ waiting--;
38
+ if (waiting === 0) {
39
+ onComplete && onComplete();
40
+ onComplete = null;
41
+ }
42
+ }
43
+ if (waiting > 0) {
44
+ arrForEach(theChannels, function (channels) {
45
+ // pass on to first item in queue
46
+ if (channels && channels.queue.length > 0) {
47
+ var channelChain = channels.chain;
48
+ var chainCtx = itemCtx.createNew(channelChain);
49
+ chainCtx.onComplete(_runChainOnComplete);
50
+ // Cause this chain to start processing
51
+ processFn(chainCtx);
38
52
  }
39
- };
40
- _self.getChannelControls = function () {
41
- return _channelQueue;
42
- };
43
- _self.initialize = function (config, core, extensions) {
44
- if (_self.isInitialized()) {
45
- // already initialized
46
- return;
53
+ else {
54
+ waiting--;
47
55
  }
48
- _base.initialize(config, core, extensions);
49
- _createChannelQueues((config || {}).channels, extensions);
50
- // Initialize the Queues
51
- arrForEach(_channelQueue, function (queue) { return initializePlugins(new ProcessTelemetryContext(queue, config, core), extensions); });
52
- };
56
+ });
57
+ }
58
+ _runChainOnComplete();
59
+ }
60
+ function _doUpdate(updateCtx, updateState) {
61
+ var theUpdateState = updateState || {
62
+ reason: 0 /* Unknown */
63
+ };
64
+ _processChannelQueue(channelQueue, updateCtx, function (chainCtx) {
65
+ chainCtx[strProcessNext](theUpdateState);
66
+ }, function () {
67
+ updateCtx[strProcessNext](theUpdateState);
68
+ });
69
+ return true;
70
+ }
71
+ function _doTeardown(unloadCtx, unloadState) {
72
+ var theUnloadState = unloadState || {
73
+ reason: 0 /* ManualTeardown */,
74
+ isAsync: false
75
+ };
76
+ _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
77
+ chainCtx[strProcessNext](theUnloadState);
78
+ }, function () {
79
+ unloadCtx[strProcessNext](theUnloadState);
80
+ isInitialized = false;
53
81
  });
54
- function _checkQueuePriority(queue) {
55
- arrForEach(queue, function (queueItem) {
56
- if (queueItem.priority < ChannelControllerPriority) {
57
- throwError(ChannelValidationMessage + queueItem.identifier);
82
+ return true;
83
+ }
84
+ function _getChannel(pluginIdentifier) {
85
+ var thePlugin = null;
86
+ if (channelQueue && channelQueue.length > 0) {
87
+ arrForEach(channelQueue, function (channels) {
88
+ // pass on to first item in queue
89
+ if (channels && channels.queue.length > 0) {
90
+ arrForEach(channels.queue, function (ext) {
91
+ if (ext.identifier === pluginIdentifier) {
92
+ thePlugin = ext;
93
+ // Cause arrForEach to stop iterating
94
+ return -1;
95
+ }
96
+ });
97
+ if (thePlugin) {
98
+ // Cause arrForEach to stop iterating
99
+ return -1;
100
+ }
58
101
  }
59
102
  });
60
103
  }
61
- function _addChannelQueue(queue) {
62
- if (queue && queue.length > 0) {
63
- queue = queue.sort(function (a, b) {
64
- return a.priority - b.priority;
104
+ return thePlugin;
105
+ }
106
+ var isInitialized = false;
107
+ var channelController = (_a = {
108
+ identifier: "ChannelControllerPlugin",
109
+ priority: ChannelControllerPriority,
110
+ initialize: function (config, core, extensions, pluginChain) {
111
+ isInitialized = true;
112
+ arrForEach(channelQueue, function (channels) {
113
+ if (channels && channels.queue.length > 0) {
114
+ initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
115
+ }
65
116
  });
66
- _checkQueuePriority(queue);
67
- _channelQueue.push(queue);
68
- }
69
- }
70
- function _createChannelQueues(channels, extensions) {
71
- _channelQueue = [];
72
- if (channels) {
73
- // Add and sort the configuration channel queues
74
- arrForEach(channels, function (queue) { return _addChannelQueue(queue); });
117
+ },
118
+ isInitialized: function () {
119
+ return isInitialized;
120
+ },
121
+ processTelemetry: function (item, itemCtx) {
122
+ _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
123
+ chainCtx[strProcessNext](item);
124
+ }, function () {
125
+ itemCtx[strProcessNext](item);
126
+ });
127
+ },
128
+ update: _doUpdate
129
+ },
130
+ _a[strPause] = function () {
131
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
132
+ chainCtx.iterate(function (plugin) {
133
+ plugin[strPause] && plugin[strPause]();
134
+ });
135
+ }, null);
136
+ },
137
+ _a[strResume] = function () {
138
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
139
+ chainCtx.iterate(function (plugin) {
140
+ plugin[strResume] && plugin[strResume]();
141
+ });
142
+ }, null);
143
+ },
144
+ _a[strTeardown] = _doTeardown,
145
+ _a.getChannel = _getChannel,
146
+ _a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
147
+ // Setting waiting to one so that we don't call the callBack until we finish iterating
148
+ var waiting = 1;
149
+ var doneIterating = false;
150
+ var cbTimer = null;
151
+ cbTimeout = cbTimeout || 5000;
152
+ function doCallback() {
153
+ waiting--;
154
+ if (doneIterating && waiting === 0) {
155
+ if (cbTimer) {
156
+ clearTimeout(cbTimer);
157
+ cbTimer = null;
158
+ }
159
+ callBack && callBack(doneIterating);
160
+ callBack = null;
161
+ }
75
162
  }
76
- if (extensions) {
77
- // Create a new channel queue for any extensions with a priority > the ChannelControllerPriority
78
- var extensionQueue_1 = [];
79
- arrForEach(extensions, function (plugin) {
80
- if (plugin.priority > ChannelControllerPriority) {
81
- extensionQueue_1.push(plugin);
163
+ _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
164
+ chainCtx.iterate(function (plugin) {
165
+ if (plugin.flush) {
166
+ waiting++;
167
+ var handled_1 = false;
168
+ // Not all channels will call this callback for every scenario
169
+ if (!plugin.flush(isAsync, function () {
170
+ handled_1 = true;
171
+ doCallback();
172
+ }, sendReason)) {
173
+ if (!handled_1) {
174
+ // If any channel doesn't return true and it didn't call the callback, then we should assume that the callback
175
+ // will never be called, so use a timeout to allow the channel(s) some time to "finish" before triggering any
176
+ // followup function (such as unloading)
177
+ if (isAsync && cbTimer == null) {
178
+ cbTimer = setTimeout(function () {
179
+ cbTimer = null;
180
+ doCallback();
181
+ }, cbTimeout);
182
+ }
183
+ else {
184
+ doCallback();
185
+ }
186
+ }
187
+ }
82
188
  }
83
189
  });
84
- _addChannelQueue(extensionQueue_1);
190
+ }, function () {
191
+ doneIterating = true;
192
+ doCallback();
193
+ });
194
+ return true;
195
+ },
196
+ _a._setQueue = function (queue) {
197
+ channelQueue = queue;
198
+ },
199
+ _a);
200
+ return channelController;
201
+ }
202
+ export function createChannelQueues(channels, extensions, config, core) {
203
+ var channelQueue = [];
204
+ if (channels) {
205
+ // Add and sort the configuration channel queues
206
+ arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });
207
+ }
208
+ if (extensions) {
209
+ // Create a new channel queue for any extensions with a priority > the ChannelControllerPriority
210
+ var extensionQueue_1 = [];
211
+ arrForEach(extensions, function (plugin) {
212
+ if (plugin.priority > ChannelControllerPriority) {
213
+ extensionQueue_1.push(plugin);
85
214
  }
86
- }
87
- return _this;
215
+ });
216
+ _addChannelQueue(channelQueue, extensionQueue_1, config, core);
88
217
  }
89
- // Removed Stub for ChannelController.prototype.processTelemetry.
90
- // Removed Stub for ChannelController.prototype.getChannelControls.
91
- // Removed Stub for ChannelController.prototype.initialize.
92
- /**
93
- * Static constructor, attempt to create accessors
94
- */
95
- // tslint:disable-next-line
96
- ChannelController._staticInit = (function () {
97
- var proto = ChannelController.prototype;
98
- // Dynamically create get/set property accessors
99
- objDefineAccessors(proto, "ChannelControls", proto.getChannelControls);
100
- objDefineAccessors(proto, "channelQueue", proto.getChannelControls);
101
- })();
102
- return ChannelController;
103
- }(BaseTelemetryPlugin));
104
- export { ChannelController };
218
+ return channelQueue;
219
+ }
105
220
  //# sourceMappingURL=ChannelController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChannelController.js.map","sources":["ChannelController.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n\"use strict\";\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseTelemetryPlugin } from \"./BaseTelemetryPlugin\";\r\nimport { ProcessTelemetryContext } from \"./ProcessTelemetryContext\";\r\nimport { initializePlugins } from \"./TelemetryHelpers\";\r\nimport { arrForEach, objDefineAccessors, throwError } from \"./HelperFuncs\";\r\nvar ChannelControllerPriority = 500;\r\nvar ChannelValidationMessage = \"Channel has invalid priority\";\r\nvar ChannelController = /** @class */ (function (_super) {\r\n __extends(ChannelController, _super);\r\n function ChannelController() {\r\n var _this = _super.call(this) || this;\r\n _this.identifier = \"ChannelControllerPlugin\";\r\n _this.priority = ChannelControllerPriority; // in reserved range 100 to 200\r\n var _channelQueue;\r\n dynamicProto(ChannelController, _this, function (_self, _base) {\r\n _self.setNextPlugin = function (next) {\r\n // The Channel controller is last in pipeline\r\n };\r\n _self.processTelemetry = function (item, itemCtx) {\r\n if (_channelQueue) {\r\n arrForEach(_channelQueue, function (queues) {\r\n // pass on to first item in queue\r\n if (queues.length > 0) {\r\n // Copying the item context as we could have mutiple chains that are executing asynchronously\r\n // and calling _getDefTelCtx as it's possible that the caller doesn't pass any context\r\n var chainCtx = _this._getTelCtx(itemCtx).createNew(queues);\r\n chainCtx.processNext(item);\r\n }\r\n });\r\n }\r\n };\r\n _self.getChannelControls = function () {\r\n return _channelQueue;\r\n };\r\n _self.initialize = function (config, core, extensions) {\r\n if (_self.isInitialized()) {\r\n // already initialized\r\n return;\r\n }\r\n _base.initialize(config, core, extensions);\r\n _createChannelQueues((config || {}).channels, extensions);\r\n // Initialize the Queues\r\n arrForEach(_channelQueue, function (queue) { return initializePlugins(new ProcessTelemetryContext(queue, config, core), extensions); });\r\n };\r\n });\r\n function _checkQueuePriority(queue) {\r\n arrForEach(queue, function (queueItem) {\r\n if (queueItem.priority < ChannelControllerPriority) {\r\n throwError(ChannelValidationMessage + queueItem.identifier);\r\n }\r\n });\r\n }\r\n function _addChannelQueue(queue) {\r\n if (queue && queue.length > 0) {\r\n queue = queue.sort(function (a, b) {\r\n return a.priority - b.priority;\r\n });\r\n _checkQueuePriority(queue);\r\n _channelQueue.push(queue);\r\n }\r\n }\r\n function _createChannelQueues(channels, extensions) {\r\n _channelQueue = [];\r\n if (channels) {\r\n // Add and sort the configuration channel queues\r\n arrForEach(channels, function (queue) { return _addChannelQueue(queue); });\r\n }\r\n if (extensions) {\r\n // Create a new channel queue for any extensions with a priority > the ChannelControllerPriority\r\n var extensionQueue_1 = [];\r\n arrForEach(extensions, function (plugin) {\r\n if (plugin.priority > ChannelControllerPriority) {\r\n extensionQueue_1.push(plugin);\r\n }\r\n });\r\n _addChannelQueue(extensionQueue_1);\r\n }\r\n }\r\n return _this;\r\n }\r\n ChannelController.prototype.processTelemetry = function (item, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ChannelController.prototype.getChannelControls = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n ChannelController.prototype.initialize = function (config, core, extensions) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Static constructor, attempt to create accessors\r\n */\r\n // tslint:disable-next-line\r\n ChannelController._staticInit = (function () {\r\n var proto = ChannelController.prototype;\r\n // Dynamically create get/set property accessors\r\n objDefineAccessors(proto, \"ChannelControls\", proto.getChannelControls);\r\n objDefineAccessors(proto, \"channelQueue\", proto.getChannelControls);\r\n })();\r\n return ChannelController;\r\n}(BaseTelemetryPlugin));\r\nexport { ChannelController };\r\n//# sourceMappingURL=ChannelController.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;2DASM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"ChannelController.js.map","sources":["ChannelController.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// // Licensed under the MIT License.\r\nimport { arrForEach, isArray, objFreeze, throwError } from \"./HelperFuncs\";\r\nimport { strPause, strProcessNext, strResume, strTeardown } from \"./InternalConstants\";\r\nimport { createProcessTelemetryContext, createTelemetryProxyChain } from \"./ProcessTelemetryContext\";\r\nimport { initializePlugins } from \"./TelemetryHelpers\";\r\nexport var ChannelControllerPriority = 500;\r\nvar ChannelValidationMessage = \"Channel has invalid priority - \";\r\nfunction _addChannelQueue(channelQueue, queue, config, core) {\r\n if (queue && isArray(queue) && queue.length > 0) {\r\n queue = queue.sort(function (a, b) {\r\n return a.priority - b.priority;\r\n });\r\n arrForEach(queue, function (queueItem) {\r\n if (queueItem.priority < ChannelControllerPriority) {\r\n throwError(ChannelValidationMessage + queueItem.identifier);\r\n }\r\n });\r\n channelQueue.push({\r\n queue: objFreeze(queue),\r\n chain: createTelemetryProxyChain(queue, config, core)\r\n });\r\n }\r\n}\r\nexport function createChannelControllerPlugin(channelQueue, core) {\r\n var _a;\r\n function _getTelCtx() {\r\n return createProcessTelemetryContext(null, core.config, core, null);\r\n }\r\n function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {\r\n var waiting = theChannels ? (theChannels.length + 1) : 1;\r\n function _runChainOnComplete() {\r\n waiting--;\r\n if (waiting === 0) {\r\n onComplete && onComplete();\r\n onComplete = null;\r\n }\r\n }\r\n if (waiting > 0) {\r\n arrForEach(theChannels, function (channels) {\r\n // pass on to first item in queue\r\n if (channels && channels.queue.length > 0) {\r\n var channelChain = channels.chain;\r\n var chainCtx = itemCtx.createNew(channelChain);\r\n chainCtx.onComplete(_runChainOnComplete);\r\n // Cause this chain to start processing\r\n processFn(chainCtx);\r\n }\r\n else {\r\n waiting--;\r\n }\r\n });\r\n }\r\n _runChainOnComplete();\r\n }\r\n function _doUpdate(updateCtx, updateState) {\r\n var theUpdateState = updateState || {\r\n reason: 0 /* Unknown */\r\n };\r\n _processChannelQueue(channelQueue, updateCtx, function (chainCtx) {\r\n chainCtx[strProcessNext](theUpdateState);\r\n }, function () {\r\n updateCtx[strProcessNext](theUpdateState);\r\n });\r\n return true;\r\n }\r\n function _doTeardown(unloadCtx, unloadState) {\r\n var theUnloadState = unloadState || {\r\n reason: 0 /* ManualTeardown */,\r\n isAsync: false\r\n };\r\n _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {\r\n chainCtx[strProcessNext](theUnloadState);\r\n }, function () {\r\n unloadCtx[strProcessNext](theUnloadState);\r\n isInitialized = false;\r\n });\r\n return true;\r\n }\r\n function _getChannel(pluginIdentifier) {\r\n var thePlugin = null;\r\n if (channelQueue && channelQueue.length > 0) {\r\n arrForEach(channelQueue, function (channels) {\r\n // pass on to first item in queue\r\n if (channels && channels.queue.length > 0) {\r\n arrForEach(channels.queue, function (ext) {\r\n if (ext.identifier === pluginIdentifier) {\r\n thePlugin = ext;\r\n // Cause arrForEach to stop iterating\r\n return -1;\r\n }\r\n });\r\n if (thePlugin) {\r\n // Cause arrForEach to stop iterating\r\n return -1;\r\n }\r\n }\r\n });\r\n }\r\n return thePlugin;\r\n }\r\n var isInitialized = false;\r\n var channelController = (_a = {\r\n identifier: \"ChannelControllerPlugin\",\r\n priority: ChannelControllerPriority,\r\n initialize: function (config, core, extensions, pluginChain) {\r\n isInitialized = true;\r\n arrForEach(channelQueue, function (channels) {\r\n if (channels && channels.queue.length > 0) {\r\n initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);\r\n }\r\n });\r\n },\r\n isInitialized: function () {\r\n return isInitialized;\r\n },\r\n processTelemetry: function (item, itemCtx) {\r\n _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {\r\n chainCtx[strProcessNext](item);\r\n }, function () {\r\n itemCtx[strProcessNext](item);\r\n });\r\n },\r\n update: _doUpdate\r\n },\r\n _a[strPause] = function () {\r\n _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {\r\n chainCtx.iterate(function (plugin) {\r\n plugin[strPause] && plugin[strPause]();\r\n });\r\n }, null);\r\n },\r\n _a[strResume] = function () {\r\n _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {\r\n chainCtx.iterate(function (plugin) {\r\n plugin[strResume] && plugin[strResume]();\r\n });\r\n }, null);\r\n },\r\n _a[strTeardown] = _doTeardown,\r\n _a.getChannel = _getChannel,\r\n _a.flush = function (isAsync, callBack, sendReason, cbTimeout) {\r\n // Setting waiting to one so that we don't call the callBack until we finish iterating\r\n var waiting = 1;\r\n var doneIterating = false;\r\n var cbTimer = null;\r\n cbTimeout = cbTimeout || 5000;\r\n function doCallback() {\r\n waiting--;\r\n if (doneIterating && waiting === 0) {\r\n if (cbTimer) {\r\n clearTimeout(cbTimer);\r\n cbTimer = null;\r\n }\r\n callBack && callBack(doneIterating);\r\n callBack = null;\r\n }\r\n }\r\n _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {\r\n chainCtx.iterate(function (plugin) {\r\n if (plugin.flush) {\r\n waiting++;\r\n var handled_1 = false;\r\n // Not all channels will call this callback for every scenario\r\n if (!plugin.flush(isAsync, function () {\r\n handled_1 = true;\r\n doCallback();\r\n }, sendReason)) {\r\n if (!handled_1) {\r\n // If any channel doesn't return true and it didn't call the callback, then we should assume that the callback\r\n // will never be called, so use a timeout to allow the channel(s) some time to \"finish\" before triggering any\r\n // followup function (such as unloading)\r\n if (isAsync && cbTimer == null) {\r\n cbTimer = setTimeout(function () {\r\n cbTimer = null;\r\n doCallback();\r\n }, cbTimeout);\r\n }\r\n else {\r\n doCallback();\r\n }\r\n }\r\n }\r\n }\r\n });\r\n }, function () {\r\n doneIterating = true;\r\n doCallback();\r\n });\r\n return true;\r\n },\r\n _a._setQueue = function (queue) {\r\n channelQueue = queue;\r\n },\r\n _a);\r\n return channelController;\r\n}\r\nexport function createChannelQueues(channels, extensions, config, core) {\r\n var channelQueue = [];\r\n if (channels) {\r\n // Add and sort the configuration channel queues\r\n arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });\r\n }\r\n if (extensions) {\r\n // Create a new channel queue for any extensions with a priority > the ChannelControllerPriority\r\n var extensionQueue_1 = [];\r\n arrForEach(extensions, function (plugin) {\r\n if (plugin.priority > ChannelControllerPriority) {\r\n extensionQueue_1.push(plugin);\r\n }\r\n });\r\n _addChannelQueue(channelQueue, extensionQueue_1, config, core);\r\n }\r\n return channelQueue;\r\n}\r\n//# sourceMappingURL=ChannelController.js.map"],"names":[],"mappings":";;;;AAA4D;AAC5D,GAAqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.8.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - Core, 2.8.0-nightly.2204-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,10 +1,11 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.8.0-nightly.2202-06
2
+ * Application Insights JavaScript SDK - Core, 2.8.0-nightly.2204-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
- import { _InternalMessageId, LoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
6
5
  import { dumpObj, getDocument, getLocation, getNavigator, isIE } from "./EnvUtils";
7
6
  import { arrForEach, dateNow, getExceptionName, isFunction, isNotNullOrUndefined, isNullOrUndefined, isString, isTruthy, isUndefined, objForEachKey, setValue, strContains, strEndsWith, strTrim } from "./HelperFuncs";
7
+ import { strEmpty } from "./InternalConstants";
8
+ import { _throwInternal } from "./DiagnosticLogger";
8
9
  var strToGMTString = "toGMTString";
9
10
  var strToUTCString = "toUTCString";
10
11
  var strCookie = "cookie";
@@ -13,7 +14,6 @@ var strEnabled = "enabled";
13
14
  var strIsCookieUseDisabled = "isCookieUseDisabled";
14
15
  var strDisableCookiesUsage = "disableCookiesUsage";
15
16
  var strConfigCookieMgr = "_ckMgr";
16
- var strEmpty = "";
17
17
  var _supportsCookies = null;
18
18
  var _allowUaSameSite = null;
19
19
  var _parsedCookieValue = null;
@@ -213,7 +213,7 @@ export function areCookiesSupported(logger) {
213
213
  _supportsCookies = doc[strCookie] !== undefined;
214
214
  }
215
215
  catch (e) {
216
- logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
216
+ _throwInternal(logger, 2 /* WARNING */, 68 /* CannotAccessCookie */, "Cannot access document.cookie - " + getExceptionName(e), { exception: dumpObj(e) });
217
217
  }
218
218
  }
219
219
  return _supportsCookies;
@@ -1 +1 @@
1
- {"version":3,"file":"CookieMgr.js.map","sources":["CookieMgr.js"],"sourcesContent":["import { _InternalMessageId, LoggingSeverity } from \"../JavaScriptSDK.Enums/LoggingEnums\";\r\nimport { dumpObj, getDocument, getLocation, getNavigator, isIE } from \"./EnvUtils\";\r\nimport { arrForEach, dateNow, getExceptionName, isFunction, isNotNullOrUndefined, isNullOrUndefined, isString, isTruthy, isUndefined, objForEachKey, setValue, strContains, strEndsWith, strTrim } from \"./HelperFuncs\";\r\nvar strToGMTString = \"toGMTString\";\r\nvar strToUTCString = \"toUTCString\";\r\nvar strCookie = \"cookie\";\r\nvar strExpires = \"expires\";\r\nvar strEnabled = \"enabled\";\r\nvar strIsCookieUseDisabled = \"isCookieUseDisabled\";\r\nvar strDisableCookiesUsage = \"disableCookiesUsage\";\r\nvar strConfigCookieMgr = \"_ckMgr\";\r\nvar strEmpty = \"\";\r\nvar _supportsCookies = null;\r\nvar _allowUaSameSite = null;\r\nvar _parsedCookieValue = null;\r\nvar _doc = getDocument();\r\nvar _cookieCache = {};\r\nvar _globalCookieConfig = {};\r\n/**\r\n * @ignore\r\n * DO NOT USE or export from the module, this is exposed as public to support backward compatibility of previous static utility methods only.\r\n * If you want to manager cookies either use the ICookieMgr available from the core instance via getCookieMgr() or create\r\n * your own instance of the CookieMgr and use that.\r\n * Using this directly for enabling / disabling cookie handling will not only affect your usage but EVERY user of cookies.\r\n * Example, if you are using a shared component that is also using Application Insights you will affect their cookie handling.\r\n * @param logger - The DiagnosticLogger to use for reporting errors.\r\n */\r\nexport function _gblCookieMgr(config, logger) {\r\n // Stash the global instance against the BaseCookieMgr class\r\n var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];\r\n if (!inst) {\r\n // Note: not using the getSetValue() helper as that would require always creating a temporary cookieMgr\r\n // that ultimately is never used\r\n inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);\r\n _globalCookieConfig[strConfigCookieMgr] = inst;\r\n }\r\n return inst;\r\n}\r\nfunction _isMgrEnabled(cookieMgr) {\r\n if (cookieMgr) {\r\n return cookieMgr.isEnabled();\r\n }\r\n return true;\r\n}\r\nfunction _createCookieMgrConfig(rootConfig) {\r\n var cookieMgrCfg = rootConfig.cookieCfg = rootConfig.cookieCfg || {};\r\n // Sets the values from the root config if not already present on the cookieMgrCfg\r\n setValue(cookieMgrCfg, \"domain\", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);\r\n setValue(cookieMgrCfg, \"path\", rootConfig.cookiePath || \"/\", null, isNullOrUndefined);\r\n if (isNullOrUndefined(cookieMgrCfg[strEnabled])) {\r\n // Set the enabled from the provided setting or the legacy root values\r\n var cookieEnabled = void 0;\r\n if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {\r\n cookieEnabled = !rootConfig[strIsCookieUseDisabled];\r\n }\r\n if (!isUndefined(rootConfig[strDisableCookiesUsage])) {\r\n cookieEnabled = !rootConfig[strDisableCookiesUsage];\r\n }\r\n cookieMgrCfg[strEnabled] = cookieEnabled;\r\n }\r\n return cookieMgrCfg;\r\n}\r\n/**\r\n * Helper to return the ICookieMgr from the core (if not null/undefined) or a default implementation\r\n * associated with the configuration or a legacy default.\r\n * @param core\r\n * @param config\r\n * @returns\r\n */\r\nexport function safeGetCookieMgr(core, config) {\r\n var cookieMgr;\r\n if (core) {\r\n // Always returns an instance\r\n cookieMgr = core.getCookieMgr();\r\n }\r\n else if (config) {\r\n var cookieCfg = config.cookieCfg;\r\n if (cookieCfg[strConfigCookieMgr]) {\r\n cookieMgr = cookieCfg[strConfigCookieMgr];\r\n }\r\n else {\r\n cookieMgr = createCookieMgr(config);\r\n }\r\n }\r\n if (!cookieMgr) {\r\n // Get or initialize the default global (legacy) cookie manager if we couldn't find one\r\n cookieMgr = _gblCookieMgr(config, (core || {}).logger);\r\n }\r\n return cookieMgr;\r\n}\r\nexport function createCookieMgr(rootConfig, logger) {\r\n var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);\r\n var _path = cookieMgrConfig.path || \"/\";\r\n var _domain = cookieMgrConfig.domain;\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n var _enabled = cookieMgrConfig[strEnabled] !== false;\r\n var cookieMgr = {\r\n isEnabled: function () {\r\n var enabled = _enabled && areCookiesSupported(logger);\r\n // Using an indirect lookup for any global cookie manager to support tree shaking for SDK's\r\n // that don't use the \"applicationinsights-core\" version of the default cookie function\r\n var gblManager = _globalCookieConfig[strConfigCookieMgr];\r\n if (enabled && gblManager && cookieMgr !== gblManager) {\r\n // Make sure the GlobalCookie Manager instance (if not this instance) is also enabled.\r\n // As the global (deprecated) functions may have been called (for backward compatibility)\r\n enabled = _isMgrEnabled(gblManager);\r\n }\r\n return enabled;\r\n },\r\n setEnabled: function (value) {\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n _enabled = value !== false;\r\n },\r\n set: function (name, value, maxAgeSec, domain, path) {\r\n var result = false;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n var values = {};\r\n var theValue = strTrim(value || strEmpty);\r\n var idx = theValue.indexOf(\";\");\r\n if (idx !== -1) {\r\n theValue = strTrim(value.substring(0, idx));\r\n values = _extractParts(value.substring(idx + 1));\r\n }\r\n // Only update domain if not already present (isUndefined) and the value is truthy (not null, undefined or empty string)\r\n setValue(values, \"domain\", domain || _domain, isTruthy, isUndefined);\r\n if (!isNullOrUndefined(maxAgeSec)) {\r\n var _isIE = isIE();\r\n if (isUndefined(values[strExpires])) {\r\n var nowMs = dateNow();\r\n // Only add expires if not already present\r\n var expireMs = nowMs + (maxAgeSec * 1000);\r\n // Sanity check, if zero or -ve then ignore\r\n if (expireMs > 0) {\r\n var expiry = new Date();\r\n expiry.setTime(expireMs);\r\n setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);\r\n }\r\n }\r\n if (!_isIE) {\r\n // Only replace if not already present\r\n setValue(values, \"max-age\", strEmpty + maxAgeSec, null, isUndefined);\r\n }\r\n }\r\n var location_1 = getLocation();\r\n if (location_1 && location_1.protocol === \"https:\") {\r\n setValue(values, \"secure\", null, null, isUndefined);\r\n // Only set same site if not also secure\r\n if (_allowUaSameSite === null) {\r\n _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);\r\n }\r\n if (_allowUaSameSite) {\r\n setValue(values, \"SameSite\", \"None\", null, isUndefined);\r\n }\r\n }\r\n setValue(values, \"path\", path || _path, null, isUndefined);\r\n var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;\r\n setCookieFn(name, _formatCookieValue(theValue, values));\r\n result = true;\r\n }\r\n return result;\r\n },\r\n get: function (name) {\r\n var value = strEmpty;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n value = (cookieMgrConfig.getCookie || _getCookieValue)(name);\r\n }\r\n return value;\r\n },\r\n del: function (name, path) {\r\n var result = false;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n // Only remove the cookie if the manager and cookie support has not been disabled\r\n result = cookieMgr.purge(name, path);\r\n }\r\n return result;\r\n },\r\n purge: function (name, path) {\r\n var _a;\r\n var result = false;\r\n if (areCookiesSupported(logger)) {\r\n // Setting the expiration date in the past immediately removes the cookie\r\n var values = (_a = {},\r\n _a[\"path\"] = path ? path : \"/\",\r\n _a[strExpires] = \"Thu, 01 Jan 1970 00:00:01 GMT\",\r\n _a);\r\n if (!isIE()) {\r\n // Set max age to expire now\r\n values[\"max-age\"] = \"0\";\r\n }\r\n var delCookie = cookieMgrConfig.delCookie || _setCookieValue;\r\n delCookie(name, _formatCookieValue(strEmpty, values));\r\n result = true;\r\n }\r\n return result;\r\n }\r\n };\r\n // Associated this cookie manager with the config\r\n cookieMgr[strConfigCookieMgr] = cookieMgr;\r\n return cookieMgr;\r\n}\r\n/*\r\n* Helper method to tell if document.cookie object is supported by the runtime\r\n*/\r\nexport function areCookiesSupported(logger) {\r\n if (_supportsCookies === null) {\r\n _supportsCookies = false;\r\n try {\r\n var doc = _doc || {};\r\n _supportsCookies = doc[strCookie] !== undefined;\r\n }\r\n catch (e) {\r\n logger && logger.throwInternal(LoggingSeverity.WARNING, _InternalMessageId.CannotAccessCookie, \"Cannot access document.cookie - \" + getExceptionName(e), { exception: dumpObj(e) });\r\n }\r\n }\r\n return _supportsCookies;\r\n}\r\nfunction _extractParts(theValue) {\r\n var values = {};\r\n if (theValue && theValue.length) {\r\n var parts = strTrim(theValue).split(\";\");\r\n arrForEach(parts, function (thePart) {\r\n thePart = strTrim(thePart || strEmpty);\r\n if (thePart) {\r\n var idx = thePart.indexOf(\"=\");\r\n if (idx === -1) {\r\n values[thePart] = null;\r\n }\r\n else {\r\n values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));\r\n }\r\n }\r\n });\r\n }\r\n return values;\r\n}\r\nfunction _formatDate(theDate, func) {\r\n if (isFunction(theDate[func])) {\r\n return theDate[func]();\r\n }\r\n return null;\r\n}\r\nfunction _formatCookieValue(value, values) {\r\n var cookieValue = value || strEmpty;\r\n objForEachKey(values, function (name, theValue) {\r\n cookieValue += \"; \" + name + (!isNullOrUndefined(theValue) ? \"=\" + theValue : strEmpty);\r\n });\r\n return cookieValue;\r\n}\r\nfunction _getCookieValue(name) {\r\n var cookieValue = strEmpty;\r\n if (_doc) {\r\n var theCookie = _doc[strCookie] || strEmpty;\r\n if (_parsedCookieValue !== theCookie) {\r\n _cookieCache = _extractParts(theCookie);\r\n _parsedCookieValue = theCookie;\r\n }\r\n cookieValue = strTrim(_cookieCache[name] || strEmpty);\r\n }\r\n return cookieValue;\r\n}\r\nfunction _setCookieValue(name, cookieValue) {\r\n if (_doc) {\r\n _doc[strCookie] = name + \"=\" + cookieValue;\r\n }\r\n}\r\nexport function uaDisallowsSameSiteNone(userAgent) {\r\n if (!isString(userAgent)) {\r\n return false;\r\n }\r\n // Cover all iOS based browsers here. This includes:\r\n // - Safari on iOS 12 for iPhone, iPod Touch, iPad\r\n // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad\r\n // - Chrome on iOS 12 for iPhone, iPod Touch, iPad\r\n // All of which are broken by SameSite=None, because they use the iOS networking stack\r\n if (strContains(userAgent, \"CPU iPhone OS 12\") || strContains(userAgent, \"iPad; CPU OS 12\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X based browsers that use the Mac OS networking stack. This includes:\r\n // - Safari on Mac OS X\r\n // This does not include:\r\n // - Internal browser on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strContains(userAgent, \"Version/\") && strContains(userAgent, \"Safari\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X internal browsers that use the Mac OS networking stack. This includes:\r\n // - Internal browser on Mac OS X\r\n // This does not include:\r\n // - Safari on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strEndsWith(userAgent, \"AppleWebKit/605.1.15 (KHTML, like Gecko)\")) {\r\n return true;\r\n }\r\n // Cover Chrome 50-69, because some versions are broken by SameSite=None, and none in this range require it.\r\n // Note: this covers some pre-Chromium Edge versions, but pre-Chromim Edge does not require SameSite=None, so this is fine.\r\n // Note: this regex applies to Windows, Mac OS X, and Linux, deliberately.\r\n if (strContains(userAgent, \"Chrome/5\") || strContains(userAgent, \"Chrome/6\")) {\r\n return true;\r\n }\r\n // Unreal Engine runs Chromium 59, but does not advertise as Chrome until 4.23. Treat versions of Unreal\r\n // that don't specify their Chrome version as lacking support for SameSite=None.\r\n if (strContains(userAgent, \"UnrealEngine\") && !strContains(userAgent, \"Chrome\")) {\r\n return true;\r\n }\r\n // UCBrowser < 12.13.2 ignores Set-Cookie headers with SameSite=None\r\n // NB: this rule isn't complete - you need regex to make a complete rule.\r\n // See: https://www.chromium.org/updates/same-site/incompatible-clients\r\n if (strContains(userAgent, \"UCBrowser/12\") || strContains(userAgent, \"UCBrowser/11\")) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n//# sourceMappingURL=CookieMgr.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"CookieMgr.js.map","sources":["CookieMgr.js"],"sourcesContent":["import { dumpObj, getDocument, getLocation, getNavigator, isIE } from \"./EnvUtils\";\r\nimport { arrForEach, dateNow, getExceptionName, isFunction, isNotNullOrUndefined, isNullOrUndefined, isString, isTruthy, isUndefined, objForEachKey, setValue, strContains, strEndsWith, strTrim } from \"./HelperFuncs\";\r\nimport { strEmpty } from \"./InternalConstants\";\r\nimport { _throwInternal } from \"./DiagnosticLogger\";\r\nvar strToGMTString = \"toGMTString\";\r\nvar strToUTCString = \"toUTCString\";\r\nvar strCookie = \"cookie\";\r\nvar strExpires = \"expires\";\r\nvar strEnabled = \"enabled\";\r\nvar strIsCookieUseDisabled = \"isCookieUseDisabled\";\r\nvar strDisableCookiesUsage = \"disableCookiesUsage\";\r\nvar strConfigCookieMgr = \"_ckMgr\";\r\nvar _supportsCookies = null;\r\nvar _allowUaSameSite = null;\r\nvar _parsedCookieValue = null;\r\nvar _doc = getDocument();\r\nvar _cookieCache = {};\r\nvar _globalCookieConfig = {};\r\n/**\r\n * @ignore\r\n * DO NOT USE or export from the module, this is exposed as public to support backward compatibility of previous static utility methods only.\r\n * If you want to manager cookies either use the ICookieMgr available from the core instance via getCookieMgr() or create\r\n * your own instance of the CookieMgr and use that.\r\n * Using this directly for enabling / disabling cookie handling will not only affect your usage but EVERY user of cookies.\r\n * Example, if you are using a shared component that is also using Application Insights you will affect their cookie handling.\r\n * @param logger - The DiagnosticLogger to use for reporting errors.\r\n */\r\nexport function _gblCookieMgr(config, logger) {\r\n // Stash the global instance against the BaseCookieMgr class\r\n var inst = createCookieMgr[strConfigCookieMgr] || _globalCookieConfig[strConfigCookieMgr];\r\n if (!inst) {\r\n // Note: not using the getSetValue() helper as that would require always creating a temporary cookieMgr\r\n // that ultimately is never used\r\n inst = createCookieMgr[strConfigCookieMgr] = createCookieMgr(config, logger);\r\n _globalCookieConfig[strConfigCookieMgr] = inst;\r\n }\r\n return inst;\r\n}\r\nfunction _isMgrEnabled(cookieMgr) {\r\n if (cookieMgr) {\r\n return cookieMgr.isEnabled();\r\n }\r\n return true;\r\n}\r\nfunction _createCookieMgrConfig(rootConfig) {\r\n var cookieMgrCfg = rootConfig.cookieCfg = rootConfig.cookieCfg || {};\r\n // Sets the values from the root config if not already present on the cookieMgrCfg\r\n setValue(cookieMgrCfg, \"domain\", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);\r\n setValue(cookieMgrCfg, \"path\", rootConfig.cookiePath || \"/\", null, isNullOrUndefined);\r\n if (isNullOrUndefined(cookieMgrCfg[strEnabled])) {\r\n // Set the enabled from the provided setting or the legacy root values\r\n var cookieEnabled = void 0;\r\n if (!isUndefined(rootConfig[strIsCookieUseDisabled])) {\r\n cookieEnabled = !rootConfig[strIsCookieUseDisabled];\r\n }\r\n if (!isUndefined(rootConfig[strDisableCookiesUsage])) {\r\n cookieEnabled = !rootConfig[strDisableCookiesUsage];\r\n }\r\n cookieMgrCfg[strEnabled] = cookieEnabled;\r\n }\r\n return cookieMgrCfg;\r\n}\r\n/**\r\n * Helper to return the ICookieMgr from the core (if not null/undefined) or a default implementation\r\n * associated with the configuration or a legacy default.\r\n * @param core\r\n * @param config\r\n * @returns\r\n */\r\nexport function safeGetCookieMgr(core, config) {\r\n var cookieMgr;\r\n if (core) {\r\n // Always returns an instance\r\n cookieMgr = core.getCookieMgr();\r\n }\r\n else if (config) {\r\n var cookieCfg = config.cookieCfg;\r\n if (cookieCfg[strConfigCookieMgr]) {\r\n cookieMgr = cookieCfg[strConfigCookieMgr];\r\n }\r\n else {\r\n cookieMgr = createCookieMgr(config);\r\n }\r\n }\r\n if (!cookieMgr) {\r\n // Get or initialize the default global (legacy) cookie manager if we couldn't find one\r\n cookieMgr = _gblCookieMgr(config, (core || {}).logger);\r\n }\r\n return cookieMgr;\r\n}\r\nexport function createCookieMgr(rootConfig, logger) {\r\n var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);\r\n var _path = cookieMgrConfig.path || \"/\";\r\n var _domain = cookieMgrConfig.domain;\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n var _enabled = cookieMgrConfig[strEnabled] !== false;\r\n var cookieMgr = {\r\n isEnabled: function () {\r\n var enabled = _enabled && areCookiesSupported(logger);\r\n // Using an indirect lookup for any global cookie manager to support tree shaking for SDK's\r\n // that don't use the \"applicationinsights-core\" version of the default cookie function\r\n var gblManager = _globalCookieConfig[strConfigCookieMgr];\r\n if (enabled && gblManager && cookieMgr !== gblManager) {\r\n // Make sure the GlobalCookie Manager instance (if not this instance) is also enabled.\r\n // As the global (deprecated) functions may have been called (for backward compatibility)\r\n enabled = _isMgrEnabled(gblManager);\r\n }\r\n return enabled;\r\n },\r\n setEnabled: function (value) {\r\n // Explicitly checking against false, so that setting to undefined will === true\r\n _enabled = value !== false;\r\n },\r\n set: function (name, value, maxAgeSec, domain, path) {\r\n var result = false;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n var values = {};\r\n var theValue = strTrim(value || strEmpty);\r\n var idx = theValue.indexOf(\";\");\r\n if (idx !== -1) {\r\n theValue = strTrim(value.substring(0, idx));\r\n values = _extractParts(value.substring(idx + 1));\r\n }\r\n // Only update domain if not already present (isUndefined) and the value is truthy (not null, undefined or empty string)\r\n setValue(values, \"domain\", domain || _domain, isTruthy, isUndefined);\r\n if (!isNullOrUndefined(maxAgeSec)) {\r\n var _isIE = isIE();\r\n if (isUndefined(values[strExpires])) {\r\n var nowMs = dateNow();\r\n // Only add expires if not already present\r\n var expireMs = nowMs + (maxAgeSec * 1000);\r\n // Sanity check, if zero or -ve then ignore\r\n if (expireMs > 0) {\r\n var expiry = new Date();\r\n expiry.setTime(expireMs);\r\n setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);\r\n }\r\n }\r\n if (!_isIE) {\r\n // Only replace if not already present\r\n setValue(values, \"max-age\", strEmpty + maxAgeSec, null, isUndefined);\r\n }\r\n }\r\n var location_1 = getLocation();\r\n if (location_1 && location_1.protocol === \"https:\") {\r\n setValue(values, \"secure\", null, null, isUndefined);\r\n // Only set same site if not also secure\r\n if (_allowUaSameSite === null) {\r\n _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);\r\n }\r\n if (_allowUaSameSite) {\r\n setValue(values, \"SameSite\", \"None\", null, isUndefined);\r\n }\r\n }\r\n setValue(values, \"path\", path || _path, null, isUndefined);\r\n var setCookieFn = cookieMgrConfig.setCookie || _setCookieValue;\r\n setCookieFn(name, _formatCookieValue(theValue, values));\r\n result = true;\r\n }\r\n return result;\r\n },\r\n get: function (name) {\r\n var value = strEmpty;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n value = (cookieMgrConfig.getCookie || _getCookieValue)(name);\r\n }\r\n return value;\r\n },\r\n del: function (name, path) {\r\n var result = false;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n // Only remove the cookie if the manager and cookie support has not been disabled\r\n result = cookieMgr.purge(name, path);\r\n }\r\n return result;\r\n },\r\n purge: function (name, path) {\r\n var _a;\r\n var result = false;\r\n if (areCookiesSupported(logger)) {\r\n // Setting the expiration date in the past immediately removes the cookie\r\n var values = (_a = {},\r\n _a[\"path\"] = path ? path : \"/\",\r\n _a[strExpires] = \"Thu, 01 Jan 1970 00:00:01 GMT\",\r\n _a);\r\n if (!isIE()) {\r\n // Set max age to expire now\r\n values[\"max-age\"] = \"0\";\r\n }\r\n var delCookie = cookieMgrConfig.delCookie || _setCookieValue;\r\n delCookie(name, _formatCookieValue(strEmpty, values));\r\n result = true;\r\n }\r\n return result;\r\n }\r\n };\r\n // Associated this cookie manager with the config\r\n cookieMgr[strConfigCookieMgr] = cookieMgr;\r\n return cookieMgr;\r\n}\r\n/*\r\n* Helper method to tell if document.cookie object is supported by the runtime\r\n*/\r\nexport function areCookiesSupported(logger) {\r\n if (_supportsCookies === null) {\r\n _supportsCookies = false;\r\n try {\r\n var doc = _doc || {};\r\n _supportsCookies = doc[strCookie] !== undefined;\r\n }\r\n catch (e) {\r\n _throwInternal(logger, 2 /* WARNING */, 68 /* CannotAccessCookie */, \"Cannot access document.cookie - \" + getExceptionName(e), { exception: dumpObj(e) });\r\n }\r\n }\r\n return _supportsCookies;\r\n}\r\nfunction _extractParts(theValue) {\r\n var values = {};\r\n if (theValue && theValue.length) {\r\n var parts = strTrim(theValue).split(\";\");\r\n arrForEach(parts, function (thePart) {\r\n thePart = strTrim(thePart || strEmpty);\r\n if (thePart) {\r\n var idx = thePart.indexOf(\"=\");\r\n if (idx === -1) {\r\n values[thePart] = null;\r\n }\r\n else {\r\n values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));\r\n }\r\n }\r\n });\r\n }\r\n return values;\r\n}\r\nfunction _formatDate(theDate, func) {\r\n if (isFunction(theDate[func])) {\r\n return theDate[func]();\r\n }\r\n return null;\r\n}\r\nfunction _formatCookieValue(value, values) {\r\n var cookieValue = value || strEmpty;\r\n objForEachKey(values, function (name, theValue) {\r\n cookieValue += \"; \" + name + (!isNullOrUndefined(theValue) ? \"=\" + theValue : strEmpty);\r\n });\r\n return cookieValue;\r\n}\r\nfunction _getCookieValue(name) {\r\n var cookieValue = strEmpty;\r\n if (_doc) {\r\n var theCookie = _doc[strCookie] || strEmpty;\r\n if (_parsedCookieValue !== theCookie) {\r\n _cookieCache = _extractParts(theCookie);\r\n _parsedCookieValue = theCookie;\r\n }\r\n cookieValue = strTrim(_cookieCache[name] || strEmpty);\r\n }\r\n return cookieValue;\r\n}\r\nfunction _setCookieValue(name, cookieValue) {\r\n if (_doc) {\r\n _doc[strCookie] = name + \"=\" + cookieValue;\r\n }\r\n}\r\nexport function uaDisallowsSameSiteNone(userAgent) {\r\n if (!isString(userAgent)) {\r\n return false;\r\n }\r\n // Cover all iOS based browsers here. This includes:\r\n // - Safari on iOS 12 for iPhone, iPod Touch, iPad\r\n // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad\r\n // - Chrome on iOS 12 for iPhone, iPod Touch, iPad\r\n // All of which are broken by SameSite=None, because they use the iOS networking stack\r\n if (strContains(userAgent, \"CPU iPhone OS 12\") || strContains(userAgent, \"iPad; CPU OS 12\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X based browsers that use the Mac OS networking stack. This includes:\r\n // - Safari on Mac OS X\r\n // This does not include:\r\n // - Internal browser on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strContains(userAgent, \"Version/\") && strContains(userAgent, \"Safari\")) {\r\n return true;\r\n }\r\n // Cover Mac OS X internal browsers that use the Mac OS networking stack. This includes:\r\n // - Internal browser on Mac OS X\r\n // This does not include:\r\n // - Safari on Mac OS X\r\n // - Chrome on Mac OS X\r\n // - Chromium on Mac OS X\r\n // Because they do not use the Mac OS networking stack.\r\n if (strContains(userAgent, \"Macintosh; Intel Mac OS X 10_14\") && strEndsWith(userAgent, \"AppleWebKit/605.1.15 (KHTML, like Gecko)\")) {\r\n return true;\r\n }\r\n // Cover Chrome 50-69, because some versions are broken by SameSite=None, and none in this range require it.\r\n // Note: this covers some pre-Chromium Edge versions, but pre-Chromim Edge does not require SameSite=None, so this is fine.\r\n // Note: this regex applies to Windows, Mac OS X, and Linux, deliberately.\r\n if (strContains(userAgent, \"Chrome/5\") || strContains(userAgent, \"Chrome/6\")) {\r\n return true;\r\n }\r\n // Unreal Engine runs Chromium 59, but does not advertise as Chrome until 4.23. Treat versions of Unreal\r\n // that don't specify their Chrome version as lacking support for SameSite=None.\r\n if (strContains(userAgent, \"UnrealEngine\") && !strContains(userAgent, \"Chrome\")) {\r\n return true;\r\n }\r\n // UCBrowser < 12.13.2 ignores Set-Cookie headers with SameSite=None\r\n // NB: this rule isn't complete - you need regex to make a complete rule.\r\n // See: https://www.chromium.org/updates/same-site/incompatible-clients\r\n if (strContains(userAgent, \"UCBrowser/12\") || strContains(userAgent, \"UCBrowser/11\")) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n//# sourceMappingURL=CookieMgr.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}