@microsoft/applicationinsights-core-js 2.8.5-nightly.2206-04 → 2.8.5-nightly.2207-02

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 (133) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +807 -711
  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 +400 -336
  7. package/dist/applicationinsights-core-js.d.ts +1 -1
  8. package/dist/applicationinsights-core-js.js +807 -711
  9. package/dist/applicationinsights-core-js.js.map +1 -1
  10. package/dist/applicationinsights-core-js.min.js +2 -2
  11. package/dist/applicationinsights-core-js.min.js.map +1 -1
  12. package/dist/applicationinsights-core-js.rollup.d.ts +1 -1
  13. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +14 -10
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  15. package/dist-esm/JavaScriptSDK/BaseCore.js +158 -139
  16. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +39 -36
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/ChannelController.js +60 -61
  20. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  21. package/dist-esm/JavaScriptSDK/CookieMgr.js +46 -43
  22. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  23. package/dist-esm/JavaScriptSDK/CoreUtils.js +16 -15
  24. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +7 -5
  26. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +4 -3
  28. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js.map +1 -1
  29. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +56 -56
  30. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  31. package/dist-esm/JavaScriptSDK/EnvUtils.js +21 -20
  32. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  33. package/dist-esm/JavaScriptSDK/EventHelpers.js +45 -39
  34. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  35. package/dist-esm/JavaScriptSDK/HelperFuncs.js +49 -40
  36. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  37. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +18 -16
  38. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  39. package/dist-esm/JavaScriptSDK/InternalConstants.js +19 -21
  40. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/NotificationManager.js +26 -23
  42. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/PerfManager.js +41 -35
  44. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +54 -53
  46. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/RandomHelper.js +5 -4
  48. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +34 -34
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  51. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +11 -10
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  53. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +4 -3
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
  55. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +26 -23
  56. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  57. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +103 -86
  60. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +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/IDistributedTraceContext.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  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 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  85. package/dist-esm/__DynamicConstants.js +70 -0
  86. package/dist-esm/__DynamicConstants.js.map +1 -0
  87. package/dist-esm/applicationinsights-core-js.js +1 -1
  88. package/package.json +5 -2
  89. package/src/JavaScriptSDK/AppInsightsCore.ts +17 -17
  90. package/src/JavaScriptSDK/BaseCore.ts +112 -97
  91. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +36 -32
  92. package/src/JavaScriptSDK/ChannelController.ts +39 -37
  93. package/src/JavaScriptSDK/CookieMgr.ts +27 -27
  94. package/src/JavaScriptSDK/CoreUtils.ts +19 -20
  95. package/src/JavaScriptSDK/DataCacheHelper.ts +12 -11
  96. package/src/JavaScriptSDK/DbgExtensionUtils.ts +9 -9
  97. package/src/JavaScriptSDK/DiagnosticLogger.ts +49 -50
  98. package/src/JavaScriptSDK/EnvUtils.ts +15 -17
  99. package/src/JavaScriptSDK/EventHelpers.ts +15 -14
  100. package/src/JavaScriptSDK/HelperFuncs.ts +20 -11
  101. package/src/JavaScriptSDK/InstrumentHooks.ts +11 -13
  102. package/src/JavaScriptSDK/InternalConstants.ts +20 -20
  103. package/src/JavaScriptSDK/NotificationManager.ts +27 -27
  104. package/src/JavaScriptSDK/PerfManager.ts +21 -19
  105. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +38 -34
  106. package/src/JavaScriptSDK/RandomHelper.ts +8 -9
  107. package/src/JavaScriptSDK/TelemetryHelpers.ts +33 -34
  108. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +17 -16
  109. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +11 -11
  110. package/src/JavaScriptSDK/W3cTraceParent.ts +6 -6
  111. package/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +1 -1
  112. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +72 -56
  113. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +1 -1
  114. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +2 -2
  115. package/types/JavaScriptSDK/AppInsightsCore.d.ts +4 -4
  116. package/types/JavaScriptSDK/BaseCore.d.ts +11 -11
  117. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +4 -4
  118. package/types/JavaScriptSDK/ChannelController.d.ts +1 -2
  119. package/types/JavaScriptSDK/CookieMgr.d.ts +3 -3
  120. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +2 -2
  121. package/types/JavaScriptSDK/HelperFuncs.d.ts +6 -0
  122. package/types/JavaScriptSDK/InstrumentHooks.d.ts +1 -1
  123. package/types/JavaScriptSDK/InternalConstants.d.ts +16 -20
  124. package/types/JavaScriptSDK/NotificationManager.d.ts +1 -1
  125. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +2 -2
  126. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +4 -4
  127. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +2 -2
  128. package/types/__DynamicConstants.d.ts +56 -0
  129. package/types/tsdoc-metadata.json +1 -1
  130. package/dist-esm/JavaScriptSDK/Constants.js +0 -9
  131. package/dist-esm/JavaScriptSDK/Constants.js.map +0 -1
  132. package/src/JavaScriptSDK/Constants.ts +0 -5
  133. package/types/JavaScriptSDK/Constants.d.ts +0 -2
@@ -1,38 +1,38 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2206-04
2
+ * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2207-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
  //
7
+ import { _DYN_CONFIG, _DYN_CREATE_NEW, _DYN_FLUSH, _DYN_IDENTIFIER, _DYN_LENGTH, _DYN_ON_COMPLETE, _DYN_PROCESS_NEXT, _DYN_PUSH } from "../__DynamicConstants";
7
8
  import { arrForEach, isArray, objFreeze, throwError } from "./HelperFuncs";
8
- import { strPause, strProcessNext, strResume, strTeardown } from "./InternalConstants";
9
+ import { STR_PRIORITY } from "./InternalConstants";
9
10
  import { createProcessTelemetryContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
10
11
  import { initializePlugins } from "./TelemetryHelpers";
11
12
  export var ChannelControllerPriority = 500;
12
13
  var ChannelValidationMessage = "Channel has invalid priority - ";
13
- function _addChannelQueue(channelQueue, queue, config, core) {
14
- if (queue && isArray(queue) && queue.length > 0) {
14
+ function _addChannelQueue(channelQueue, queue, core) {
15
+ if (queue && isArray(queue) && queue[_DYN_LENGTH /* @min:%2elength */] > 0) {
15
16
  queue = queue.sort(function (a, b) {
16
- return a.priority - b.priority;
17
+ return a[STR_PRIORITY /* @min:%2epriority */] - b[STR_PRIORITY /* @min:%2epriority */];
17
18
  });
18
19
  arrForEach(queue, function (queueItem) {
19
- if (queueItem.priority < ChannelControllerPriority) {
20
- throwError(ChannelValidationMessage + queueItem.identifier);
20
+ if (queueItem[STR_PRIORITY /* @min:%2epriority */] < ChannelControllerPriority) {
21
+ throwError(ChannelValidationMessage + queueItem[_DYN_IDENTIFIER /* @min:%2eidentifier */]);
21
22
  }
22
23
  });
23
- channelQueue.push({
24
+ channelQueue[_DYN_PUSH /* @min:%2epush */]({
24
25
  queue: objFreeze(queue),
25
- chain: createTelemetryProxyChain(queue, config, core)
26
+ chain: createTelemetryProxyChain(queue, core[_DYN_CONFIG /* @min:%2econfig */], core)
26
27
  });
27
28
  }
28
29
  }
29
30
  export function createChannelControllerPlugin(channelQueue, core) {
30
- var _a;
31
31
  function _getTelCtx() {
32
- return createProcessTelemetryContext(null, core.config, core, null);
32
+ return createProcessTelemetryContext(null, core[_DYN_CONFIG /* @min:%2econfig */], core, null);
33
33
  }
34
34
  function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {
35
- var waiting = theChannels ? (theChannels.length + 1) : 1;
35
+ var waiting = theChannels ? (theChannels[_DYN_LENGTH /* @min:%2elength */] + 1) : 1;
36
36
  function _runChainOnComplete() {
37
37
  waiting--;
38
38
  if (waiting === 0) {
@@ -43,10 +43,10 @@ export function createChannelControllerPlugin(channelQueue, core) {
43
43
  if (waiting > 0) {
44
44
  arrForEach(theChannels, function (channels) {
45
45
  // pass on to first item in queue
46
- if (channels && channels.queue.length > 0) {
46
+ if (channels && channels.queue[_DYN_LENGTH /* @min:%2elength */] > 0) {
47
47
  var channelChain = channels.chain;
48
- var chainCtx = itemCtx.createNew(channelChain);
49
- chainCtx.onComplete(_runChainOnComplete);
48
+ var chainCtx = itemCtx[_DYN_CREATE_NEW /* @min:%2ecreateNew */](channelChain);
49
+ chainCtx[_DYN_ON_COMPLETE /* @min:%2eonComplete */](_runChainOnComplete);
50
50
  // Cause this chain to start processing
51
51
  processFn(chainCtx);
52
52
  }
@@ -62,9 +62,9 @@ export function createChannelControllerPlugin(channelQueue, core) {
62
62
  reason: 0 /* TelemetryUpdateReason.Unknown */
63
63
  };
64
64
  _processChannelQueue(channelQueue, updateCtx, function (chainCtx) {
65
- chainCtx[strProcessNext](theUpdateState);
65
+ chainCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](theUpdateState);
66
66
  }, function () {
67
- updateCtx[strProcessNext](theUpdateState);
67
+ updateCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](theUpdateState);
68
68
  });
69
69
  return true;
70
70
  }
@@ -74,21 +74,21 @@ export function createChannelControllerPlugin(channelQueue, core) {
74
74
  isAsync: false
75
75
  };
76
76
  _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {
77
- chainCtx[strProcessNext](theUnloadState);
77
+ chainCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](theUnloadState);
78
78
  }, function () {
79
- unloadCtx[strProcessNext](theUnloadState);
79
+ unloadCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](theUnloadState);
80
80
  isInitialized = false;
81
81
  });
82
82
  return true;
83
83
  }
84
84
  function _getChannel(pluginIdentifier) {
85
85
  var thePlugin = null;
86
- if (channelQueue && channelQueue.length > 0) {
86
+ if (channelQueue && channelQueue[_DYN_LENGTH /* @min:%2elength */] > 0) {
87
87
  arrForEach(channelQueue, function (channels) {
88
88
  // pass on to first item in queue
89
- if (channels && channels.queue.length > 0) {
89
+ if (channels && channels.queue[_DYN_LENGTH /* @min:%2elength */] > 0) {
90
90
  arrForEach(channels.queue, function (ext) {
91
- if (ext.identifier === pluginIdentifier) {
91
+ if (ext[_DYN_IDENTIFIER /* @min:%2eidentifier */] === pluginIdentifier) {
92
92
  thePlugin = ext;
93
93
  // Cause arrForEach to stop iterating
94
94
  return -1;
@@ -104,46 +104,45 @@ export function createChannelControllerPlugin(channelQueue, core) {
104
104
  return thePlugin;
105
105
  }
106
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
- }
116
- });
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
107
+ var channelController = {
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[_DYN_LENGTH /* @min:%2elength */] > 0) {
114
+ initializePlugins(createProcessTelemetryContext(channels.chain, config, core), extensions);
115
+ }
116
+ });
129
117
  },
130
- _a[strPause] = function () {
118
+ isInitialized: function () {
119
+ return isInitialized;
120
+ },
121
+ processTelemetry: function (item, itemCtx) {
122
+ _processChannelQueue(channelQueue, itemCtx || _getTelCtx(), function (chainCtx) {
123
+ chainCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](item);
124
+ }, function () {
125
+ itemCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](item);
126
+ });
127
+ },
128
+ update: _doUpdate,
129
+ pause: function () {
131
130
  _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
132
131
  chainCtx.iterate(function (plugin) {
133
- plugin[strPause] && plugin[strPause]();
132
+ plugin.pause && plugin.pause();
134
133
  });
135
134
  }, null);
136
135
  },
137
- _a[strResume] = function () {
136
+ resume: function () {
138
137
  _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
139
138
  chainCtx.iterate(function (plugin) {
140
- plugin[strResume] && plugin[strResume]();
139
+ plugin.resume && plugin.resume();
141
140
  });
142
141
  }, null);
143
142
  },
144
- _a[strTeardown] = _doTeardown,
145
- _a.getChannel = _getChannel,
146
- _a.flush = function (isAsync, callBack, sendReason, cbTimeout) {
143
+ teardown: _doTeardown,
144
+ getChannel: _getChannel,
145
+ flush: function (isAsync, callBack, sendReason, cbTimeout) {
147
146
  // Setting waiting to one so that we don't call the callBack until we finish iterating
148
147
  var waiting = 1;
149
148
  var doneIterating = false;
@@ -162,11 +161,11 @@ export function createChannelControllerPlugin(channelQueue, core) {
162
161
  }
163
162
  _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {
164
163
  chainCtx.iterate(function (plugin) {
165
- if (plugin.flush) {
164
+ if (plugin[_DYN_FLUSH /* @min:%2eflush */]) {
166
165
  waiting++;
167
166
  var handled_1 = false;
168
167
  // Not all channels will call this callback for every scenario
169
- if (!plugin.flush(isAsync, function () {
168
+ if (!plugin[_DYN_FLUSH /* @min:%2eflush */](isAsync, function () {
170
169
  handled_1 = true;
171
170
  doCallback();
172
171
  }, sendReason)) {
@@ -193,27 +192,27 @@ export function createChannelControllerPlugin(channelQueue, core) {
193
192
  });
194
193
  return true;
195
194
  },
196
- _a._setQueue = function (queue) {
195
+ _setQueue: function (queue) {
197
196
  channelQueue = queue;
198
- },
199
- _a);
197
+ }
198
+ };
200
199
  return channelController;
201
200
  }
202
- export function createChannelQueues(channels, extensions, config, core) {
201
+ export function createChannelQueues(channels, extensions, core) {
203
202
  var channelQueue = [];
204
203
  if (channels) {
205
204
  // Add and sort the configuration channel queues
206
- arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, config, core); });
205
+ arrForEach(channels, function (queue) { return _addChannelQueue(channelQueue, queue, core); });
207
206
  }
208
207
  if (extensions) {
209
208
  // Create a new channel queue for any extensions with a priority > the ChannelControllerPriority
210
209
  var extensionQueue_1 = [];
211
210
  arrForEach(extensions, function (plugin) {
212
- if (plugin.priority > ChannelControllerPriority) {
213
- extensionQueue_1.push(plugin);
211
+ if (plugin[STR_PRIORITY /* @min:%2epriority */] > ChannelControllerPriority) {
212
+ extensionQueue_1[_DYN_PUSH /* @min:%2epush */](plugin);
214
213
  }
215
214
  });
216
- _addChannelQueue(channelQueue, extensionQueue_1, config, core);
215
+ _addChannelQueue(channelQueue, extensionQueue_1, core);
217
216
  }
218
217
  return channelQueue;
219
218
  }
@@ -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\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 /* TelemetryUpdateReason.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 /* TelemetryUnloadReason.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
+ {"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 { _DYN_CONFIG, _DYN_CREATE_NEW, _DYN_FLUSH, _DYN_IDENTIFIER, _DYN_LENGTH, _DYN_ON_COMPLETE, _DYN_PROCESS_NEXT, _DYN_PUSH } from \"../__DynamicConstants\";\r\nimport { arrForEach, isArray, objFreeze, throwError } from \"./HelperFuncs\";\r\nimport { STR_PRIORITY } 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, core) {\r\n if (queue && isArray(queue) && queue[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n queue = queue.sort(function (a, b) {\r\n return a[STR_PRIORITY /* @min:%2epriority */] - b[STR_PRIORITY /* @min:%2epriority */];\r\n });\r\n arrForEach(queue, function (queueItem) {\r\n if (queueItem[STR_PRIORITY /* @min:%2epriority */] < ChannelControllerPriority) {\r\n throwError(ChannelValidationMessage + queueItem[_DYN_IDENTIFIER /* @min:%2eidentifier */]);\r\n }\r\n });\r\n channelQueue[_DYN_PUSH /* @min:%2epush */]({\r\n queue: objFreeze(queue),\r\n chain: createTelemetryProxyChain(queue, core[_DYN_CONFIG /* @min:%2econfig */], core)\r\n });\r\n }\r\n}\r\nexport function createChannelControllerPlugin(channelQueue, core) {\r\n function _getTelCtx() {\r\n return createProcessTelemetryContext(null, core[_DYN_CONFIG /* @min:%2econfig */], core, null);\r\n }\r\n function _processChannelQueue(theChannels, itemCtx, processFn, onComplete) {\r\n var waiting = theChannels ? (theChannels[_DYN_LENGTH /* @min:%2elength */] + 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[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n var channelChain = channels.chain;\r\n var chainCtx = itemCtx[_DYN_CREATE_NEW /* @min:%2ecreateNew */](channelChain);\r\n chainCtx[_DYN_ON_COMPLETE /* @min:%2eonComplete */](_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 /* TelemetryUpdateReason.Unknown */\r\n };\r\n _processChannelQueue(channelQueue, updateCtx, function (chainCtx) {\r\n chainCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](theUpdateState);\r\n }, function () {\r\n updateCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](theUpdateState);\r\n });\r\n return true;\r\n }\r\n function _doTeardown(unloadCtx, unloadState) {\r\n var theUnloadState = unloadState || {\r\n reason: 0 /* TelemetryUnloadReason.ManualTeardown */,\r\n isAsync: false\r\n };\r\n _processChannelQueue(channelQueue, unloadCtx, function (chainCtx) {\r\n chainCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](theUnloadState);\r\n }, function () {\r\n unloadCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](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[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n arrForEach(channelQueue, function (channels) {\r\n // pass on to first item in queue\r\n if (channels && channels.queue[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n arrForEach(channels.queue, function (ext) {\r\n if (ext[_DYN_IDENTIFIER /* @min:%2eidentifier */] === 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 = {\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[_DYN_LENGTH /* @min:%2elength */] > 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[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](item);\r\n }, function () {\r\n itemCtx[_DYN_PROCESS_NEXT /* @min:%2eprocessNext */](item);\r\n });\r\n },\r\n update: _doUpdate,\r\n pause: function () {\r\n _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {\r\n chainCtx.iterate(function (plugin) {\r\n plugin.pause && plugin.pause();\r\n });\r\n }, null);\r\n },\r\n resume: function () {\r\n _processChannelQueue(channelQueue, _getTelCtx(), function (chainCtx) {\r\n chainCtx.iterate(function (plugin) {\r\n plugin.resume && plugin.resume();\r\n });\r\n }, null);\r\n },\r\n teardown: _doTeardown,\r\n getChannel: _getChannel,\r\n 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[_DYN_FLUSH /* @min:%2eflush */]) {\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[_DYN_FLUSH /* @min:%2eflush */](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 _setQueue: function (queue) {\r\n channelQueue = queue;\r\n }\r\n };\r\n return channelController;\r\n}\r\nexport function createChannelQueues(channels, extensions, 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, 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[STR_PRIORITY /* @min:%2epriority */] > ChannelControllerPriority) {\r\n extensionQueue_1[_DYN_PUSH /* @min:%2epush */](plugin);\r\n }\r\n });\r\n _addChannelQueue(channelQueue, extensionQueue_1, 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"}
@@ -1,11 +1,12 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2206-04
2
+ * Application Insights JavaScript SDK - Core, 2.8.5-nightly.2207-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
+ import { _DYN_COOKIE_CFG, _DYN_INDEX_OF, _DYN_LENGTH, _DYN_LOGGER, _DYN_SET_ENABLED, _DYN_SPLIT, _DYN_SUBSTRING, _DYN_USER_AGENT } from "../__DynamicConstants";
6
+ import { _throwInternal } from "./DiagnosticLogger";
5
7
  import { dumpObj, getDocument, getLocation, getNavigator, isIE } from "./EnvUtils";
6
8
  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";
9
+ import { STR_EMPTY } from "./InternalConstants";
9
10
  var strToGMTString = "toGMTString";
10
11
  var strToUTCString = "toUTCString";
11
12
  var strCookie = "cookie";
@@ -47,7 +48,7 @@ function _isMgrEnabled(cookieMgr) {
47
48
  return true;
48
49
  }
49
50
  function _createCookieMgrConfig(rootConfig) {
50
- var cookieMgrCfg = rootConfig.cookieCfg = rootConfig.cookieCfg || {};
51
+ var cookieMgrCfg = rootConfig[_DYN_COOKIE_CFG /* @min:%2ecookieCfg */] = rootConfig[_DYN_COOKIE_CFG /* @min:%2ecookieCfg */] || {};
51
52
  // Sets the values from the root config if not already present on the cookieMgrCfg
52
53
  setValue(cookieMgrCfg, "domain", rootConfig.cookieDomain, isNotNullOrUndefined, isNullOrUndefined);
53
54
  setValue(cookieMgrCfg, "path", rootConfig.cookiePath || "/", null, isNullOrUndefined);
@@ -78,7 +79,7 @@ export function safeGetCookieMgr(core, config) {
78
79
  cookieMgr = core.getCookieMgr();
79
80
  }
80
81
  else if (config) {
81
- var cookieCfg = config.cookieCfg;
82
+ var cookieCfg = config[_DYN_COOKIE_CFG /* @min:%2ecookieCfg */];
82
83
  if (cookieCfg[strConfigCookieMgr]) {
83
84
  cookieMgr = cookieCfg[strConfigCookieMgr];
84
85
  }
@@ -88,42 +89,44 @@ export function safeGetCookieMgr(core, config) {
88
89
  }
89
90
  if (!cookieMgr) {
90
91
  // Get or initialize the default global (legacy) cookie manager if we couldn't find one
91
- cookieMgr = _gblCookieMgr(config, (core || {}).logger);
92
+ cookieMgr = _gblCookieMgr(config, (core || {})[_DYN_LOGGER /* @min:%2elogger */]);
92
93
  }
93
94
  return cookieMgr;
94
95
  }
95
96
  export function createCookieMgr(rootConfig, logger) {
97
+ var _a;
96
98
  var cookieMgrConfig = _createCookieMgrConfig(rootConfig || _globalCookieConfig);
97
99
  var _path = cookieMgrConfig.path || "/";
98
100
  var _domain = cookieMgrConfig.domain;
99
101
  // Explicitly checking against false, so that setting to undefined will === true
100
102
  var _enabled = cookieMgrConfig[strEnabled] !== false;
101
- var cookieMgr = {
102
- isEnabled: function () {
103
- var enabled = _enabled && areCookiesSupported(logger);
104
- // Using an indirect lookup for any global cookie manager to support tree shaking for SDK's
105
- // that don't use the "applicationinsights-core" version of the default cookie function
106
- var gblManager = _globalCookieConfig[strConfigCookieMgr];
107
- if (enabled && gblManager && cookieMgr !== gblManager) {
108
- // Make sure the GlobalCookie Manager instance (if not this instance) is also enabled.
109
- // As the global (deprecated) functions may have been called (for backward compatibility)
110
- enabled = _isMgrEnabled(gblManager);
103
+ var cookieMgr = (_a = {
104
+ isEnabled: function () {
105
+ var enabled = _enabled && areCookiesSupported(logger);
106
+ // Using an indirect lookup for any global cookie manager to support tree shaking for SDK's
107
+ // that don't use the "applicationinsights-core" version of the default cookie function
108
+ var gblManager = _globalCookieConfig[strConfigCookieMgr];
109
+ if (enabled && gblManager && cookieMgr !== gblManager) {
110
+ // Make sure the GlobalCookie Manager instance (if not this instance) is also enabled.
111
+ // As the global (deprecated) functions may have been called (for backward compatibility)
112
+ enabled = _isMgrEnabled(gblManager);
113
+ }
114
+ return enabled;
111
115
  }
112
- return enabled;
113
116
  },
114
- setEnabled: function (value) {
117
+ _a[_DYN_SET_ENABLED /* @min:setEnabled */] = function (value) {
115
118
  // Explicitly checking against false, so that setting to undefined will === true
116
119
  _enabled = value !== false;
117
120
  },
118
- set: function (name, value, maxAgeSec, domain, path) {
121
+ _a.set = function (name, value, maxAgeSec, domain, path) {
119
122
  var result = false;
120
123
  if (_isMgrEnabled(cookieMgr)) {
121
124
  var values = {};
122
- var theValue = strTrim(value || strEmpty);
123
- var idx = theValue.indexOf(";");
125
+ var theValue = strTrim(value || STR_EMPTY);
126
+ var idx = theValue[_DYN_INDEX_OF /* @min:%2eindexOf */](";");
124
127
  if (idx !== -1) {
125
- theValue = strTrim(value.substring(0, idx));
126
- values = _extractParts(value.substring(idx + 1));
128
+ theValue = strTrim(value[_DYN_SUBSTRING /* @min:%2esubstring */](0, idx));
129
+ values = _extractParts(value[_DYN_SUBSTRING /* @min:%2esubstring */](idx + 1));
127
130
  }
128
131
  // Only update domain if not already present (isUndefined) and the value is truthy (not null, undefined or empty string)
129
132
  setValue(values, "domain", domain || _domain, isTruthy, isUndefined);
@@ -137,12 +140,12 @@ export function createCookieMgr(rootConfig, logger) {
137
140
  if (expireMs > 0) {
138
141
  var expiry = new Date();
139
142
  expiry.setTime(expireMs);
140
- setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || strEmpty, isTruthy);
143
+ setValue(values, strExpires, _formatDate(expiry, !_isIE ? strToUTCString : strToGMTString) || _formatDate(expiry, _isIE ? strToGMTString : strToUTCString) || STR_EMPTY, isTruthy);
141
144
  }
142
145
  }
143
146
  if (!_isIE) {
144
147
  // Only replace if not already present
145
- setValue(values, "max-age", strEmpty + maxAgeSec, null, isUndefined);
148
+ setValue(values, "max-age", STR_EMPTY + maxAgeSec, null, isUndefined);
146
149
  }
147
150
  }
148
151
  var location_1 = getLocation();
@@ -150,7 +153,7 @@ export function createCookieMgr(rootConfig, logger) {
150
153
  setValue(values, "secure", null, null, isUndefined);
151
154
  // Only set same site if not also secure
152
155
  if (_allowUaSameSite === null) {
153
- _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {}).userAgent);
156
+ _allowUaSameSite = !uaDisallowsSameSiteNone((getNavigator() || {})[_DYN_USER_AGENT /* @min:%2euserAgent */]);
154
157
  }
155
158
  if (_allowUaSameSite) {
156
159
  setValue(values, "SameSite", "None", null, isUndefined);
@@ -163,14 +166,14 @@ export function createCookieMgr(rootConfig, logger) {
163
166
  }
164
167
  return result;
165
168
  },
166
- get: function (name) {
167
- var value = strEmpty;
169
+ _a.get = function (name) {
170
+ var value = STR_EMPTY;
168
171
  if (_isMgrEnabled(cookieMgr)) {
169
172
  value = (cookieMgrConfig.getCookie || _getCookieValue)(name);
170
173
  }
171
174
  return value;
172
175
  },
173
- del: function (name, path) {
176
+ _a.del = function (name, path) {
174
177
  var result = false;
175
178
  if (_isMgrEnabled(cookieMgr)) {
176
179
  // Only remove the cookie if the manager and cookie support has not been disabled
@@ -178,7 +181,7 @@ export function createCookieMgr(rootConfig, logger) {
178
181
  }
179
182
  return result;
180
183
  },
181
- purge: function (name, path) {
184
+ _a.purge = function (name, path) {
182
185
  var _a;
183
186
  var result = false;
184
187
  if (areCookiesSupported(logger)) {
@@ -192,12 +195,12 @@ export function createCookieMgr(rootConfig, logger) {
192
195
  values["max-age"] = "0";
193
196
  }
194
197
  var delCookie = cookieMgrConfig.delCookie || _setCookieValue;
195
- delCookie(name, _formatCookieValue(strEmpty, values));
198
+ delCookie(name, _formatCookieValue(STR_EMPTY, values));
196
199
  result = true;
197
200
  }
198
201
  return result;
199
- }
200
- };
202
+ },
203
+ _a);
201
204
  // Associated this cookie manager with the config
202
205
  cookieMgr[strConfigCookieMgr] = cookieMgr;
203
206
  return cookieMgr;
@@ -220,17 +223,17 @@ export function areCookiesSupported(logger) {
220
223
  }
221
224
  function _extractParts(theValue) {
222
225
  var values = {};
223
- if (theValue && theValue.length) {
224
- var parts = strTrim(theValue).split(";");
226
+ if (theValue && theValue[_DYN_LENGTH /* @min:%2elength */]) {
227
+ var parts = strTrim(theValue)[_DYN_SPLIT /* @min:%2esplit */](";");
225
228
  arrForEach(parts, function (thePart) {
226
- thePart = strTrim(thePart || strEmpty);
229
+ thePart = strTrim(thePart || STR_EMPTY);
227
230
  if (thePart) {
228
- var idx = thePart.indexOf("=");
231
+ var idx = thePart[_DYN_INDEX_OF /* @min:%2eindexOf */]("=");
229
232
  if (idx === -1) {
230
233
  values[thePart] = null;
231
234
  }
232
235
  else {
233
- values[strTrim(thePart.substring(0, idx))] = strTrim(thePart.substring(idx + 1));
236
+ values[strTrim(thePart[_DYN_SUBSTRING /* @min:%2esubstring */](0, idx))] = strTrim(thePart[_DYN_SUBSTRING /* @min:%2esubstring */](idx + 1));
234
237
  }
235
238
  }
236
239
  });
@@ -244,21 +247,21 @@ function _formatDate(theDate, func) {
244
247
  return null;
245
248
  }
246
249
  function _formatCookieValue(value, values) {
247
- var cookieValue = value || strEmpty;
250
+ var cookieValue = value || STR_EMPTY;
248
251
  objForEachKey(values, function (name, theValue) {
249
- cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : strEmpty);
252
+ cookieValue += "; " + name + (!isNullOrUndefined(theValue) ? "=" + theValue : STR_EMPTY);
250
253
  });
251
254
  return cookieValue;
252
255
  }
253
256
  function _getCookieValue(name) {
254
- var cookieValue = strEmpty;
257
+ var cookieValue = STR_EMPTY;
255
258
  if (_doc) {
256
- var theCookie = _doc[strCookie] || strEmpty;
259
+ var theCookie = _doc[strCookie] || STR_EMPTY;
257
260
  if (_parsedCookieValue !== theCookie) {
258
261
  _cookieCache = _extractParts(theCookie);
259
262
  _parsedCookieValue = theCookie;
260
263
  }
261
- cookieValue = strTrim(_cookieCache[name] || strEmpty);
264
+ cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);
262
265
  }
263
266
  return cookieValue;
264
267
  }
@@ -1 +1 @@
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 /* eLoggingSeverity.WARNING */, 68 /* _eInternalMessageId.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 { _DYN_COOKIE_CFG, _DYN_INDEX_OF, _DYN_LENGTH, _DYN_LOGGER, _DYN_SET_ENABLED, _DYN_SPLIT, _DYN_SUBSTRING, _DYN_USER_AGENT } from \"../__DynamicConstants\";\r\nimport { _throwInternal } from \"./DiagnosticLogger\";\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\nimport { STR_EMPTY } from \"./InternalConstants\";\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[_DYN_COOKIE_CFG /* @min:%2ecookieCfg */] = rootConfig[_DYN_COOKIE_CFG /* @min:%2ecookieCfg */] || {};\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[_DYN_COOKIE_CFG /* @min:%2ecookieCfg */];\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 || {})[_DYN_LOGGER /* @min:%2elogger */]);\r\n }\r\n return cookieMgr;\r\n}\r\nexport function createCookieMgr(rootConfig, logger) {\r\n var _a;\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 = (_a = {\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 },\r\n _a[_DYN_SET_ENABLED /* @min: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 _a.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 || STR_EMPTY);\r\n var idx = theValue[_DYN_INDEX_OF /* @min:%2eindexOf */](\";\");\r\n if (idx !== -1) {\r\n theValue = strTrim(value[_DYN_SUBSTRING /* @min:%2esubstring */](0, idx));\r\n values = _extractParts(value[_DYN_SUBSTRING /* @min:%2esubstring */](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) || STR_EMPTY, isTruthy);\r\n }\r\n }\r\n if (!_isIE) {\r\n // Only replace if not already present\r\n setValue(values, \"max-age\", STR_EMPTY + 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() || {})[_DYN_USER_AGENT /* @min:%2euserAgent */]);\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 _a.get = function (name) {\r\n var value = STR_EMPTY;\r\n if (_isMgrEnabled(cookieMgr)) {\r\n value = (cookieMgrConfig.getCookie || _getCookieValue)(name);\r\n }\r\n return value;\r\n },\r\n _a.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 _a.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(STR_EMPTY, values));\r\n result = true;\r\n }\r\n return result;\r\n },\r\n _a);\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 /* eLoggingSeverity.WARNING */, 68 /* _eInternalMessageId.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[_DYN_LENGTH /* @min:%2elength */]) {\r\n var parts = strTrim(theValue)[_DYN_SPLIT /* @min:%2esplit */](\";\");\r\n arrForEach(parts, function (thePart) {\r\n thePart = strTrim(thePart || STR_EMPTY);\r\n if (thePart) {\r\n var idx = thePart[_DYN_INDEX_OF /* @min:%2eindexOf */](\"=\");\r\n if (idx === -1) {\r\n values[thePart] = null;\r\n }\r\n else {\r\n values[strTrim(thePart[_DYN_SUBSTRING /* @min:%2esubstring */](0, idx))] = strTrim(thePart[_DYN_SUBSTRING /* @min:%2esubstring */](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 || STR_EMPTY;\r\n objForEachKey(values, function (name, theValue) {\r\n cookieValue += \"; \" + name + (!isNullOrUndefined(theValue) ? \"=\" + theValue : STR_EMPTY);\r\n });\r\n return cookieValue;\r\n}\r\nfunction _getCookieValue(name) {\r\n var cookieValue = STR_EMPTY;\r\n if (_doc) {\r\n var theCookie = _doc[strCookie] || STR_EMPTY;\r\n if (_parsedCookieValue !== theCookie) {\r\n _cookieCache = _extractParts(theCookie);\r\n _parsedCookieValue = theCookie;\r\n }\r\n cookieValue = strTrim(_cookieCache[name] || STR_EMPTY);\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;AACA;AACA;AACA"}