@microsoft/1ds-post-js 4.1.0-nightly3.2401-23 → 4.1.0-nightly3.2402-03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/bundle/es5/{ms.post-4.1.0-nightly3.2401-23.gbl.js → ms.post-4.1.0-nightly3.2402-03.gbl.js} +93 -37
  2. package/bundle/es5/ms.post-4.1.0-nightly3.2402-03.gbl.js.map +1 -0
  3. package/bundle/es5/ms.post-4.1.0-nightly3.2402-03.gbl.min.js +7 -0
  4. package/bundle/es5/ms.post-4.1.0-nightly3.2402-03.gbl.min.js.map +1 -0
  5. package/bundle/es5/ms.post-4.1.0-nightly3.2402-03.integrity.json +46 -0
  6. package/bundle/es5/{ms.post-4.1.0-nightly3.2401-23.js → ms.post-4.1.0-nightly3.2402-03.js} +93 -37
  7. package/bundle/es5/ms.post-4.1.0-nightly3.2402-03.js.map +1 -0
  8. package/bundle/es5/ms.post-4.1.0-nightly3.2402-03.min.js +7 -0
  9. package/bundle/es5/ms.post-4.1.0-nightly3.2402-03.min.js.map +1 -0
  10. package/bundle/es5/ms.post.gbl.js +92 -36
  11. package/bundle/es5/ms.post.gbl.js.map +1 -1
  12. package/bundle/es5/ms.post.gbl.min.js +2 -2
  13. package/bundle/es5/ms.post.gbl.min.js.map +1 -1
  14. package/bundle/es5/ms.post.integrity.json +17 -17
  15. package/bundle/es5/ms.post.js +92 -36
  16. package/bundle/es5/ms.post.js.map +1 -1
  17. package/bundle/es5/ms.post.min.js +2 -2
  18. package/bundle/es5/ms.post.min.js.map +1 -1
  19. package/dist/es5/ms.post.js +90 -34
  20. package/dist/es5/ms.post.js.map +1 -1
  21. package/dist/es5/ms.post.min.js +2 -2
  22. package/dist/es5/ms.post.min.js.map +1 -1
  23. package/dist-es5/BatchNotificationActions.js +1 -1
  24. package/dist-es5/ClockSkewManager.js +1 -1
  25. package/dist-es5/DataModels.js +1 -1
  26. package/dist-es5/EventBatch.js +1 -1
  27. package/dist-es5/HttpManager.js +17 -8
  28. package/dist-es5/HttpManager.js.map +1 -1
  29. package/dist-es5/Index.js +1 -1
  30. package/dist-es5/InternalConstants.js +1 -1
  31. package/dist-es5/KillSwitch.js +3 -3
  32. package/dist-es5/KillSwitch.js.map +1 -1
  33. package/dist-es5/PostChannel.js +67 -20
  34. package/dist-es5/PostChannel.js.map +1 -1
  35. package/dist-es5/RetryPolicy.js +1 -1
  36. package/dist-es5/Serializer.js +1 -1
  37. package/dist-es5/TimeoutOverrideWrapper.js +1 -1
  38. package/dist-es5/__DynamicConstants.js +17 -14
  39. package/dist-es5/__DynamicConstants.js.map +1 -1
  40. package/dist-es5/typings/XDomainRequest.js +1 -1
  41. package/package.json +2 -2
  42. package/types/1ds-post-js.d.ts +7 -1
  43. package/types/1ds-post-js.namespaced.d.ts +7 -1
  44. package/bundle/es5/ms.post-4.1.0-nightly3.2401-23.gbl.js.map +0 -1
  45. package/bundle/es5/ms.post-4.1.0-nightly3.2401-23.gbl.min.js +0 -7
  46. package/bundle/es5/ms.post-4.1.0-nightly3.2401-23.gbl.min.js.map +0 -1
  47. package/bundle/es5/ms.post-4.1.0-nightly3.2401-23.integrity.json +0 -46
  48. package/bundle/es5/ms.post-4.1.0-nightly3.2401-23.js.map +0 -1
  49. package/bundle/es5/ms.post-4.1.0-nightly3.2401-23.min.js +0 -7
  50. package/bundle/es5/ms.post-4.1.0-nightly3.2401-23.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * 1DS JS SDK POST plugin, 4.1.0-nightly3.2401-23
2
+ * 1DS JS SDK POST plugin, 4.1.0-nightly3.2402-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import dynamicProto from "@microsoft/dynamicproto-js";
12
12
  import { arrForEach, dateNow, strTrim } from "@microsoft/1ds-core-js";
13
- import { _DYN_IS_TENANT_KILLED, _DYN_LENGTH, _DYN_PUSH, _DYN_SET_KILL_SWITCH_TENA10, _DYN_SPLIT } from "./__DynamicConstants";
13
+ import { _DYN_IS_TENANT_KILLED, _DYN_LENGTH, _DYN_PUSH, _DYN_SET_KILL_SWITCH_TENA12, _DYN_SPLIT } from "./__DynamicConstants";
14
14
  var SecToMsMultiplier = 1000;
15
15
  /**
16
16
  * Class to stop certain tenants sending events.
@@ -28,7 +28,7 @@ var KillSwitch = /** @class */ (function () {
28
28
  return result;
29
29
  }
30
30
  dynamicProto(KillSwitch, this, function (_self) {
31
- _self[_DYN_SET_KILL_SWITCH_TENA10 /* @min:%2esetKillSwitchTenants */] = function (killTokens, killDuration) {
31
+ _self[_DYN_SET_KILL_SWITCH_TENA12 /* @min:%2esetKillSwitchTenants */] = function (killTokens, killDuration) {
32
32
  if (killTokens && killDuration) {
33
33
  try {
34
34
  var killedTokens = _normalizeTenants(killTokens[_DYN_SPLIT /* @min:%2esplit */](","));
@@ -1 +1 @@
1
- {"version":3,"file":"KillSwitch.js.map","sources":["KillSwitch.js"],"sourcesContent":["/**\r\n* KillSwitch.ts\r\n* @author Abhilash Panwar (abpanwar)\r\n* @copyright Microsoft 2018\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { arrForEach, dateNow, strTrim } from \"@microsoft/1ds-core-js\";\r\nimport { _DYN_IS_TENANT_KILLED, _DYN_LENGTH, _DYN_PUSH, _DYN_SET_KILL_SWITCH_TENA10, _DYN_SPLIT } from \"./__DynamicConstants\";\r\nvar SecToMsMultiplier = 1000;\r\n/**\r\n* Class to stop certain tenants sending events.\r\n*/\r\nvar KillSwitch = /** @class */ (function () {\r\n function KillSwitch() {\r\n var _killedTokenDictionary = {};\r\n function _normalizeTenants(values) {\r\n var result = [];\r\n if (values) {\r\n arrForEach(values, function (value) {\r\n result[_DYN_PUSH /* @min:%2epush */](strTrim(value));\r\n });\r\n }\r\n return result;\r\n }\r\n dynamicProto(KillSwitch, this, function (_self) {\r\n _self[_DYN_SET_KILL_SWITCH_TENA10 /* @min:%2esetKillSwitchTenants */] = function (killTokens, killDuration) {\r\n if (killTokens && killDuration) {\r\n try {\r\n var killedTokens = _normalizeTenants(killTokens[_DYN_SPLIT /* @min:%2esplit */](\",\"));\r\n if (killDuration === \"this-request-only\") {\r\n return killedTokens;\r\n }\r\n var durationMs = parseInt(killDuration, 10) * SecToMsMultiplier;\r\n for (var i = 0; i < killedTokens[_DYN_LENGTH /* @min:%2elength */]; ++i) {\r\n _killedTokenDictionary[killedTokens[i]] = dateNow() + durationMs;\r\n }\r\n }\r\n catch (ex) {\r\n return [];\r\n }\r\n }\r\n return [];\r\n };\r\n _self[_DYN_IS_TENANT_KILLED /* @min:%2eisTenantKilled */] = function (tenantToken) {\r\n var killDictionary = _killedTokenDictionary;\r\n var name = strTrim(tenantToken);\r\n if (killDictionary[name] !== undefined && killDictionary[name] > dateNow()) {\r\n return true;\r\n }\r\n delete killDictionary[name];\r\n return false;\r\n };\r\n });\r\n }\r\n /**\r\n * Set the tenants that are to be killed along with the duration. If the duration is\r\n * a special value identifying that the tokens are too be killed for only this request, then\r\n * a array of tokens is returned.\r\n * @param killedTokens - Tokens that are too be marked to be killed.\r\n * @param killDuration - The duration for which the tokens are to be killed.\r\n * @returns The tokens that are killed only for this given request.\r\n */\r\n KillSwitch.prototype.setKillSwitchTenants = function (killTokens, killDuration) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return [];\r\n };\r\n /**\r\n * Determing if the given tenant token has been killed for the moment.\r\n * @param tenantToken - The token to be checked.\r\n * @returns True if token has been killed, false otherwise.\r\n */\r\n KillSwitch.prototype.isTenantKilled = function (tenantToken) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n return KillSwitch;\r\n}());\r\nexport { KillSwitch };\r\n//# sourceMappingURL=KillSwitch.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;wDAoBM,CAAC;;;;;sBACe;AACtB;AACA;AACA"}
1
+ {"version":3,"file":"KillSwitch.js.map","sources":["KillSwitch.js"],"sourcesContent":["/**\r\n* KillSwitch.ts\r\n* @author Abhilash Panwar (abpanwar)\r\n* @copyright Microsoft 2018\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { arrForEach, dateNow, strTrim } from \"@microsoft/1ds-core-js\";\r\nimport { _DYN_IS_TENANT_KILLED, _DYN_LENGTH, _DYN_PUSH, _DYN_SET_KILL_SWITCH_TENA12, _DYN_SPLIT } from \"./__DynamicConstants\";\r\nvar SecToMsMultiplier = 1000;\r\n/**\r\n* Class to stop certain tenants sending events.\r\n*/\r\nvar KillSwitch = /** @class */ (function () {\r\n function KillSwitch() {\r\n var _killedTokenDictionary = {};\r\n function _normalizeTenants(values) {\r\n var result = [];\r\n if (values) {\r\n arrForEach(values, function (value) {\r\n result[_DYN_PUSH /* @min:%2epush */](strTrim(value));\r\n });\r\n }\r\n return result;\r\n }\r\n dynamicProto(KillSwitch, this, function (_self) {\r\n _self[_DYN_SET_KILL_SWITCH_TENA12 /* @min:%2esetKillSwitchTenants */] = function (killTokens, killDuration) {\r\n if (killTokens && killDuration) {\r\n try {\r\n var killedTokens = _normalizeTenants(killTokens[_DYN_SPLIT /* @min:%2esplit */](\",\"));\r\n if (killDuration === \"this-request-only\") {\r\n return killedTokens;\r\n }\r\n var durationMs = parseInt(killDuration, 10) * SecToMsMultiplier;\r\n for (var i = 0; i < killedTokens[_DYN_LENGTH /* @min:%2elength */]; ++i) {\r\n _killedTokenDictionary[killedTokens[i]] = dateNow() + durationMs;\r\n }\r\n }\r\n catch (ex) {\r\n return [];\r\n }\r\n }\r\n return [];\r\n };\r\n _self[_DYN_IS_TENANT_KILLED /* @min:%2eisTenantKilled */] = function (tenantToken) {\r\n var killDictionary = _killedTokenDictionary;\r\n var name = strTrim(tenantToken);\r\n if (killDictionary[name] !== undefined && killDictionary[name] > dateNow()) {\r\n return true;\r\n }\r\n delete killDictionary[name];\r\n return false;\r\n };\r\n });\r\n }\r\n /**\r\n * Set the tenants that are to be killed along with the duration. If the duration is\r\n * a special value identifying that the tokens are too be killed for only this request, then\r\n * a array of tokens is returned.\r\n * @param killedTokens - Tokens that are too be marked to be killed.\r\n * @param killDuration - The duration for which the tokens are to be killed.\r\n * @returns The tokens that are killed only for this given request.\r\n */\r\n KillSwitch.prototype.setKillSwitchTenants = function (killTokens, killDuration) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return [];\r\n };\r\n /**\r\n * Determing if the given tenant token has been killed for the moment.\r\n * @param tenantToken - The token to be checked.\r\n * @returns True if token has been killed, false otherwise.\r\n */\r\n KillSwitch.prototype.isTenantKilled = function (tenantToken) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n return KillSwitch;\r\n}());\r\nexport { KillSwitch };\r\n//# sourceMappingURL=KillSwitch.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;wDAoBM,CAAC;;;;;sBACe;AACtB;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * 1DS JS SDK POST plugin, 4.1.0-nightly3.2401-23
2
+ * 1DS JS SDK POST plugin, 4.1.0-nightly3.2402-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -19,7 +19,7 @@ import { HttpManager } from "./HttpManager";
19
19
  import { STR_MSA_DEVICE_TICKET, STR_TRACE, STR_USER } from "./InternalConstants";
20
20
  import { retryPolicyGetMillisToBackoffForRetry } from "./RetryPolicy";
21
21
  import { createTimeoutWrapper } from "./TimeoutOverrideWrapper";
22
- import { _DYN_AUTO_FLUSH_EVENTS_LI13, _DYN_BASE_DATA, _DYN_BATCHES, _DYN_CAN_SEND_REQUEST, _DYN_CLEAR_TIMEOUT_OVERRI3, _DYN_CONCAT, _DYN_COUNT, _DYN_DATA, _DYN_DISABLE_AUTO_BATCH_F14, _DYN_DISABLE_OPTIMIZE_OBJ, _DYN_DISABLE_TELEMETRY, _DYN_EVENTS, _DYN_EVENTS_LIMIT_IN_MEM, _DYN_GET_WPARAM, _DYN_IDENTIFIER, _DYN_IGNORE_MC1_MS0_COOKI12, _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE, _DYN_I_KEY, _DYN_LATENCY, _DYN_LENGTH, _DYN_OVERRIDE_INSTRUMENTA15, _DYN_PUSH, _DYN_SEND_ATTEMPT, _DYN_SEND_POST, _DYN_SEND_QUEUED_REQUESTS, _DYN_SEND_SYNCHRONOUS_BAT9, _DYN_SET_TIMEOUT_OVERRIDE, _DYN_SET_UNLOADING, _DYN_SPLICE, _DYN_SPLIT, _DYN_SYNC, _DYN__BACK_OFF_TRANSMISSI11 } from "./__DynamicConstants";
22
+ import { _DYN_AUTO_FLUSH_EVENTS_LI15, _DYN_BASE_DATA, _DYN_BATCHES, _DYN_CAN_SEND_REQUEST, _DYN_CLEAR_TIMEOUT_OVERRI3, _DYN_CONCAT, _DYN_COUNT, _DYN_DATA, _DYN_DISABLE_AUTO_BATCH_F16, _DYN_DISABLE_OPTIMIZE_OBJ, _DYN_DISABLE_TELEMETRY, _DYN_EVENTS, _DYN_EVENTS_LIMIT_IN_MEM, _DYN_GET_OFFLINE_REQUEST_9, _DYN_GET_WPARAM, _DYN_HDRS, _DYN_IDENTIFIER, _DYN_IGNORE_MC1_MS0_COOKI14, _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE, _DYN_I_KEY, _DYN_LATENCY, _DYN_LENGTH, _DYN_OVERRIDE_INSTRUMENTA17, _DYN_PUSH, _DYN_SEND_ATTEMPT, _DYN_SEND_POST, _DYN_SEND_QUEUED_REQUESTS, _DYN_SEND_SYNCHRONOUS_BAT11, _DYN_SERIALIZE_OFFLINE_EV8, _DYN_SET_TIMEOUT_OVERRIDE, _DYN_SET_UNLOADING, _DYN_SPLICE, _DYN_SPLIT, _DYN_SYNC, _DYN__BACK_OFF_TRANSMISSI13 } from "./__DynamicConstants";
23
23
  var FlushCheckTimer = 0.250; // This needs to be in seconds, so this is 250ms
24
24
  var MaxNumberEventPerBatch = 500;
25
25
  var EventsDroppedAtOneTime = 20;
@@ -30,6 +30,7 @@ var MaxConnections = 2;
30
30
  var MaxRequestRetriesBeforeBackoff = 1;
31
31
  var MaxEventsLimitInMem = 10000;
32
32
  var strEventsDiscarded = "eventsDiscarded";
33
+ var EMPTY_STR = "";
33
34
  var undefValue = undefined;
34
35
  /**
35
36
  * The default settings for the config.
@@ -84,7 +85,7 @@ var PostChannel = /** @class */ (function (_super) {
84
85
  var _this = _super.call(this) || this;
85
86
  _this.identifier = "PostChannel";
86
87
  _this.priority = 1011;
87
- _this.version = '4.1.0-nightly3.2401-23';
88
+ _this.version = '4.1.0-nightly3.2402-03';
88
89
  var _postConfig;
89
90
  var _isTeardownCalled = false;
90
91
  var _flushCallbackQueue = [];
@@ -138,17 +139,17 @@ var PostChannel = /** @class */ (function (_super) {
138
139
  _timeoutWrapper = createTimeoutWrapper(_postConfig[_DYN_SET_TIMEOUT_OVERRIDE /* @min:%2esetTimeoutOverride */], _postConfig[_DYN_CLEAR_TIMEOUT_OVERRI3 /* @min:%2eclearTimeoutOverride */]);
139
140
  // Only try and use the optimizeObject() if this appears to be a chromium based browser and it has not been explicitly disabled
140
141
  _optimizeObject = !_postConfig[_DYN_DISABLE_OPTIMIZE_OBJ /* @min:%2edisableOptimizeObj */] && isChromium();
141
- _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI12 /* @min:%2eignoreMc1Ms0CookieProcessing */];
142
+ _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI14 /* @min:%2eignoreMc1Ms0CookieProcessing */];
142
143
  _hookWParam(core); // _hookWParam uses _ignoreMc1Ms0CookieProcessing
143
144
  _queueSizeLimit = _postConfig[_DYN_EVENTS_LIMIT_IN_MEM /* @min:%2eeventsLimitInMem */];
144
145
  _immediateQueueSizeLimit = _postConfig.immediateEventLimit;
145
- _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI13 /* @min:%2eautoFlushEventsLimit */];
146
+ _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 /* @min:%2eautoFlushEventsLimit */];
146
147
  _maxEventSendAttempts = _postConfig.maxEventRetryAttempts;
147
148
  _maxUnloadEventSendAttempts = _postConfig.maxUnloadEventRetryAttempts;
148
- _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F14 /* @min:%2edisableAutoBatchFlushLimit */];
149
+ _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F16 /* @min:%2edisableAutoBatchFlushLimit */];
149
150
  _setAutoLimits();
150
151
  // Override iKey if provided in Post config if provided for during initialization
151
- _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA15 /* @min:%2eoverrideInstrumentationKey */];
152
+ _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA17 /* @min:%2eoverrideInstrumentationKey */];
152
153
  // DisableTelemetry was defined in the config provided during initialization
153
154
  _disableTelemetry = !!_postConfig[_DYN_DISABLE_TELEMETRY /* @min:%2edisableTelemetry */];
154
155
  if (_unloadHandlersAdded) {
@@ -190,6 +191,26 @@ var PostChannel = /** @class */ (function (_super) {
190
191
  }
191
192
  _self.processNext(event, itemCtx);
192
193
  };
194
+ _self.getOfflineSupport = function () {
195
+ var details = _httpManager[_DYN_GET_OFFLINE_REQUEST_9 /* @min:%2egetOfflineRequestDetails */]();
196
+ return {
197
+ getUrl: function () {
198
+ return details.url;
199
+ },
200
+ serialize: _serialize,
201
+ batch: _batch,
202
+ shouldProcess: function (evt) {
203
+ return !_disableTelemetry;
204
+ },
205
+ createPayload: function (evt) {
206
+ return {
207
+ urlString: details.url,
208
+ headers: details[_DYN_HDRS /* @min:%2ehdrs */],
209
+ data: evt
210
+ };
211
+ }
212
+ };
213
+ };
193
214
  _self._doTeardown = function (unloadCtx, unloadState) {
194
215
  _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);
195
216
  _isTeardownCalled = true;
@@ -213,6 +234,29 @@ var PostChannel = /** @class */ (function (_super) {
213
234
  return wparam | existingGetWParamMethod.call(core);
214
235
  };
215
236
  }
237
+ function _batch(arr) {
238
+ var rlt = EMPTY_STR;
239
+ if (arr && arr[_DYN_LENGTH /* @min:%2elength */]) {
240
+ arrForEach(arr, function (item) {
241
+ if (rlt) {
242
+ rlt += "\n";
243
+ }
244
+ rlt += item;
245
+ });
246
+ }
247
+ return rlt;
248
+ }
249
+ function _serialize(event) {
250
+ var rlt = EMPTY_STR;
251
+ try {
252
+ _cleanEvent(event);
253
+ rlt = _httpManager[_DYN_SERIALIZE_OFFLINE_EV8 /* @min:%2eserializeOfflineEvt */](event);
254
+ }
255
+ catch (e) {
256
+ // eslint-disable-next-line no-empty
257
+ }
258
+ return rlt;
259
+ }
216
260
  // Moving event handlers out from the initialize closure so that any local variables can be garbage collected
217
261
  function _handleUnloadEvents(evt) {
218
262
  var theEvt = evt || getWindow().event; // IE 8 does not pass the event
@@ -228,16 +272,7 @@ var PostChannel = /** @class */ (function (_super) {
228
272
  _isPageUnloadTriggered = false;
229
273
  _httpManager[_DYN_SET_UNLOADING /* @min:%2esetUnloading */](_isPageUnloadTriggered);
230
274
  }
231
- function _addEventToQueues(event, append) {
232
- // If send attempt field is undefined we should set it to 0.
233
- if (!event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */]) {
234
- event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] = 0;
235
- }
236
- // Add default latency
237
- if (!event[_DYN_LATENCY /* @min:%2elatency */]) {
238
- event[_DYN_LATENCY /* @min:%2elatency */] = 1 /* EventLatencyValue.Normal */;
239
- }
240
- // Remove extra AI properties if present
275
+ function _cleanEvent(event) {
241
276
  if (event.ext && event.ext[STR_TRACE]) {
242
277
  delete (event.ext[STR_TRACE]);
243
278
  }
@@ -254,6 +289,17 @@ var PostChannel = /** @class */ (function (_super) {
254
289
  event[_DYN_DATA /* @min:%2edata */] = optimizeObject(event[_DYN_DATA /* @min:%2edata */]);
255
290
  }
256
291
  }
292
+ }
293
+ function _addEventToQueues(event, append) {
294
+ // If send attempt field is undefined we should set it to 0.
295
+ if (!event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */]) {
296
+ event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] = 0;
297
+ }
298
+ // Add default latency
299
+ if (!event[_DYN_LATENCY /* @min:%2elatency */]) {
300
+ event[_DYN_LATENCY /* @min:%2elatency */] = 1 /* EventLatencyValue.Normal */;
301
+ }
302
+ _cleanEvent(event);
257
303
  if (event[_DYN_SYNC /* @min:%2esync */]) {
258
304
  // If the transmission is backed off then do not send synchronous events.
259
305
  // We will convert these events to Real time latency instead.
@@ -268,7 +314,7 @@ var PostChannel = /** @class */ (function (_super) {
268
314
  if (_optimizeObject) {
269
315
  event = optimizeObject(event);
270
316
  }
271
- _httpManager[_DYN_SEND_SYNCHRONOUS_BAT9 /* @min:%2esendSynchronousBatch */](EventBatch.create(event[_DYN_I_KEY /* @min:%2eiKey */], [event]), event[_DYN_SYNC /* @min:%2esync */] === true ? 1 /* EventSendType.Synchronous */ : event[_DYN_SYNC /* @min:%2esync */], 3 /* SendRequestReason.SyncEvent */);
317
+ _httpManager[_DYN_SEND_SYNCHRONOUS_BAT11 /* @min:%2esendSynchronousBatch */](EventBatch.create(event[_DYN_I_KEY /* @min:%2eiKey */], [event]), event[_DYN_SYNC /* @min:%2esync */] === true ? 1 /* EventSendType.Synchronous */ : event[_DYN_SYNC /* @min:%2esync */], 3 /* SendRequestReason.SyncEvent */);
272
318
  return;
273
319
  }
274
320
  }
@@ -306,7 +352,7 @@ var PostChannel = /** @class */ (function (_super) {
306
352
  }
307
353
  _self.setEventQueueLimits = function (eventLimit, autoFlushLimit) {
308
354
  _postConfig[_DYN_EVENTS_LIMIT_IN_MEM /* @min:%2eeventsLimitInMem */] = _queueSizeLimit = isGreaterThanZero(eventLimit) ? eventLimit : MaxEventsLimitInMem;
309
- _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI13 /* @min:%2eautoFlushEventsLimit */] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;
355
+ _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 /* @min:%2eautoFlushEventsLimit */] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;
310
356
  _setAutoLimits();
311
357
  // We only do this check here as during normal event addition if the queue is > then events start getting dropped
312
358
  var doFlush = _queueSize > eventLimit;
@@ -472,7 +518,7 @@ var PostChannel = /** @class */ (function (_super) {
472
518
  }
473
519
  }
474
520
  }
475
- _self[_DYN__BACK_OFF_TRANSMISSI11 /* @min:%2e_backOffTransmission */] = function () {
521
+ _self[_DYN__BACK_OFF_TRANSMISSI13 /* @min:%2e_backOffTransmission */] = function () {
476
522
  if (_currentBackoffCount < MaxBackoffCount) {
477
523
  _currentBackoffCount++;
478
524
  _clearScheduledTimer();
@@ -928,6 +974,7 @@ var PostChannel = /** @class */ (function (_super) {
928
974
  // Removed Stub for PostChannel.prototype._setTransmitProfile.
929
975
  // Removed Stub for PostChannel.prototype._backOffTransmission.
930
976
  // Removed Stub for PostChannel.prototype._clearBackOff.
977
+ // Removed Stub for PostChannel.prototype.getOfflineSupport.
931
978
  // This is a workaround for an IE bug when using dynamicProto() with classes that don't have any
932
979
  // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
933
980
  PostChannel.__ieDyn=1;
@@ -1 +1 @@
1
- {"version":3,"file":"PostChannel.js.map","sources":["PostChannel.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\n/**\r\n* PostManager.ts\r\n* @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)\r\n* @copyright Microsoft 2018-2020\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseTelemetryPlugin, EventsDiscardedReason, _throwInternal, addPageHideEventListener, addPageShowEventListener, addPageUnloadEventListener, arrForEach, createProcessTelemetryContext, createUniqueNamespace, doPerf, getWindow, isChromium, isGreaterThanZero, isNumber, mergeEvtNamespace, objForEachKey, onConfigChange, optimizeObject, proxyFunctions, removePageHideEventListener, removePageShowEventListener, removePageUnloadEventListener, setProcessTelemetryTimings } from \"@microsoft/1ds-core-js\";\r\nimport { createPromise } from \"@nevware21/ts-async\";\r\nimport { objDeepFreeze } from \"@nevware21/ts-utils\";\r\nimport { BE_PROFILE, NRT_PROFILE, RT_PROFILE } from \"./DataModels\";\r\nimport { EventBatch } from \"./EventBatch\";\r\nimport { HttpManager } from \"./HttpManager\";\r\nimport { STR_MSA_DEVICE_TICKET, STR_TRACE, STR_USER } from \"./InternalConstants\";\r\nimport { retryPolicyGetMillisToBackoffForRetry } from \"./RetryPolicy\";\r\nimport { createTimeoutWrapper } from \"./TimeoutOverrideWrapper\";\r\nimport { _DYN_AUTO_FLUSH_EVENTS_LI13, _DYN_BASE_DATA, _DYN_BATCHES, _DYN_CAN_SEND_REQUEST, _DYN_CLEAR_TIMEOUT_OVERRI3, _DYN_CONCAT, _DYN_COUNT, _DYN_DATA, _DYN_DISABLE_AUTO_BATCH_F14, _DYN_DISABLE_OPTIMIZE_OBJ, _DYN_DISABLE_TELEMETRY, _DYN_EVENTS, _DYN_EVENTS_LIMIT_IN_MEM, _DYN_GET_WPARAM, _DYN_IDENTIFIER, _DYN_IGNORE_MC1_MS0_COOKI12, _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE, _DYN_I_KEY, _DYN_LATENCY, _DYN_LENGTH, _DYN_OVERRIDE_INSTRUMENTA15, _DYN_PUSH, _DYN_SEND_ATTEMPT, _DYN_SEND_POST, _DYN_SEND_QUEUED_REQUESTS, _DYN_SEND_SYNCHRONOUS_BAT9, _DYN_SET_TIMEOUT_OVERRIDE, _DYN_SET_UNLOADING, _DYN_SPLICE, _DYN_SPLIT, _DYN_SYNC, _DYN__BACK_OFF_TRANSMISSI11 } from \"./__DynamicConstants\";\r\nvar FlushCheckTimer = 0.250; // This needs to be in seconds, so this is 250ms\r\nvar MaxNumberEventPerBatch = 500;\r\nvar EventsDroppedAtOneTime = 20;\r\nvar MaxSendAttempts = 6;\r\nvar MaxSyncUnloadSendAttempts = 2; // Assuming 2 based on beforeunload and unload\r\nvar MaxBackoffCount = 4;\r\nvar MaxConnections = 2;\r\nvar MaxRequestRetriesBeforeBackoff = 1;\r\nvar MaxEventsLimitInMem = 10000;\r\nvar strEventsDiscarded = \"eventsDiscarded\";\r\nvar undefValue = undefined;\r\n/**\r\n * The default settings for the config.\r\n * WE MUST include all defaults here to ensure that the config is created with all of the properties\r\n * defined as dynamic.\r\n */\r\nvar defaultPostChannelConfig = objDeepFreeze({\r\n eventsLimitInMem: { isVal: isGreaterThanZero, v: MaxEventsLimitInMem },\r\n immediateEventLimit: { isVal: isGreaterThanZero, v: 500 },\r\n autoFlushEventsLimit: { isVal: isGreaterThanZero, v: 0 },\r\n disableAutoBatchFlushLimit: false,\r\n httpXHROverride: { isVal: isOverrideFn, v: undefValue },\r\n overrideInstrumentationKey: undefValue,\r\n overrideEndpointUrl: undefValue,\r\n disableTelemetry: false,\r\n ignoreMc1Ms0CookieProcessing: false,\r\n setTimeoutOverride: undefValue,\r\n clearTimeoutOverride: undefValue,\r\n payloadPreprocessor: undefValue,\r\n payloadListener: undefValue,\r\n disableEventTimings: undefValue,\r\n valueSanitizer: undefValue,\r\n stringifyObjects: undefValue,\r\n enableCompoundKey: undefValue,\r\n disableOptimizeObj: false,\r\n // disableCacheHeader: undefValue, // See Task #7178858 - Collector requires a change to support this\r\n transports: undefValue,\r\n unloadTransports: undefValue,\r\n useSendBeacon: undefValue,\r\n disableFetchKeepAlive: undefValue,\r\n avoidOptions: false,\r\n xhrTimeout: undefValue,\r\n disableXhrSync: undefValue,\r\n alwaysUseXhrOverride: false,\r\n maxEventRetryAttempts: { isVal: isNumber, v: MaxSendAttempts },\r\n maxUnloadEventRetryAttempts: { isVal: isNumber, v: MaxSyncUnloadSendAttempts },\r\n addNoResponse: undefValue,\r\n excludeCsMetaData: undefValue\r\n});\r\nfunction isOverrideFn(httpXHROverride) {\r\n return httpXHROverride && httpXHROverride[_DYN_SEND_POST /* @min:%2esendPOST */];\r\n}\r\n/**\r\n * Class that manages adding events to inbound queues and batching of events\r\n * into requests.\r\n * @group Classes\r\n * @group Entrypoint\r\n */\r\nvar PostChannel = /** @class */ (function (_super) {\r\n __extends(PostChannel, _super);\r\n function PostChannel() {\r\n var _this = _super.call(this) || this;\r\n _this.identifier = \"PostChannel\";\r\n _this.priority = 1011;\r\n _this.version = '4.1.0-nightly3.2401-23';\r\n var _postConfig;\r\n var _isTeardownCalled = false;\r\n var _flushCallbackQueue = [];\r\n var _flushCallbackTimer;\r\n var _paused = false;\r\n var _immediateQueueSize = 0;\r\n var _immediateQueueSizeLimit;\r\n var _queueSize = 0;\r\n var _queueSizeLimit;\r\n var _profiles = {};\r\n var _currentProfile = RT_PROFILE;\r\n var _scheduledTimer;\r\n var _immediateTimer;\r\n var _currentBackoffCount;\r\n var _timerCount;\r\n var _httpManager;\r\n var _batchQueues;\r\n var _autoFlushEventsLimit;\r\n // either MaxBatchSize * (1+ Max Connections) or _queueLimit / 6 (where 3 latency Queues [normal, realtime, cost deferred] * 2 [allow half full -- allow for retry])\r\n var _autoFlushBatchLimit;\r\n var _delayedBatchSendLatency;\r\n var _delayedBatchReason;\r\n var _optimizeObject;\r\n var _isPageUnloadTriggered;\r\n var _maxEventSendAttempts;\r\n var _maxUnloadEventSendAttempts;\r\n var _evtNamespace;\r\n var _timeoutWrapper;\r\n var _ignoreMc1Ms0CookieProcessing;\r\n var _disableAutoBatchFlushLimit;\r\n var _notificationManager;\r\n var _unloadHandlersAdded;\r\n var _overrideInstrumentationKey;\r\n var _disableTelemetry;\r\n dynamicProto(PostChannel, _this, function (_self, _base) {\r\n _initDefaults();\r\n // Special internal method to allow the DebugPlugin to hook embedded objects\r\n _self[\"_getDbgPlgTargets\"] = function () {\r\n return [_httpManager, _postConfig];\r\n };\r\n _self[_DYN_INITIALIZE /* @min:%2einitialize */] = function (theConfig, core, extensions) {\r\n doPerf(core, function () { return \"PostChannel:initialize\"; }, function () {\r\n _base[_DYN_INITIALIZE /* @min:%2einitialize */](theConfig, core, extensions);\r\n _notificationManager = core.getNotifyMgr();\r\n try {\r\n _evtNamespace = mergeEvtNamespace(createUniqueNamespace(_self[_DYN_IDENTIFIER /* @min:%2eidentifier */]), core.evtNamespace && core.evtNamespace());\r\n _self._addHook(onConfigChange(theConfig, function (details) {\r\n var coreConfig = details.cfg;\r\n var ctx = createProcessTelemetryContext(null, coreConfig, core);\r\n _postConfig = ctx.getExtCfg(_self[_DYN_IDENTIFIER /* @min:%2eidentifier */], defaultPostChannelConfig);\r\n _timeoutWrapper = createTimeoutWrapper(_postConfig[_DYN_SET_TIMEOUT_OVERRIDE /* @min:%2esetTimeoutOverride */], _postConfig[_DYN_CLEAR_TIMEOUT_OVERRI3 /* @min:%2eclearTimeoutOverride */]);\r\n // Only try and use the optimizeObject() if this appears to be a chromium based browser and it has not been explicitly disabled\r\n _optimizeObject = !_postConfig[_DYN_DISABLE_OPTIMIZE_OBJ /* @min:%2edisableOptimizeObj */] && isChromium();\r\n _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI12 /* @min:%2eignoreMc1Ms0CookieProcessing */];\r\n _hookWParam(core); // _hookWParam uses _ignoreMc1Ms0CookieProcessing\r\n _queueSizeLimit = _postConfig[_DYN_EVENTS_LIMIT_IN_MEM /* @min:%2eeventsLimitInMem */];\r\n _immediateQueueSizeLimit = _postConfig.immediateEventLimit;\r\n _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI13 /* @min:%2eautoFlushEventsLimit */];\r\n _maxEventSendAttempts = _postConfig.maxEventRetryAttempts;\r\n _maxUnloadEventSendAttempts = _postConfig.maxUnloadEventRetryAttempts;\r\n _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F14 /* @min:%2edisableAutoBatchFlushLimit */];\r\n _setAutoLimits();\r\n // Override iKey if provided in Post config if provided for during initialization\r\n _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA15 /* @min:%2eoverrideInstrumentationKey */];\r\n // DisableTelemetry was defined in the config provided during initialization\r\n _disableTelemetry = !!_postConfig[_DYN_DISABLE_TELEMETRY /* @min:%2edisableTelemetry */];\r\n if (_unloadHandlersAdded) {\r\n _removeUnloadHandlers();\r\n }\r\n var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];\r\n // When running in Web browsers try to send all telemetry if page is unloaded\r\n _unloadHandlersAdded = addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace);\r\n _unloadHandlersAdded = addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace) || _unloadHandlersAdded;\r\n _unloadHandlersAdded = addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents, _evtNamespace) || _unloadHandlersAdded;\r\n }));\r\n // only initialize the manager once\r\n _httpManager[_DYN_INITIALIZE /* @min:%2einitialize */](theConfig, _self.core, _self);\r\n }\r\n catch (e) {\r\n // resetting the initialized state because of failure\r\n _self.setInitialized(false);\r\n throw e;\r\n }\r\n }, function () { return ({ theConfig: theConfig, core: core, extensions: extensions }); });\r\n };\r\n _self.processTelemetry = function (ev, itemCtx) {\r\n setProcessTelemetryTimings(ev, _self[_DYN_IDENTIFIER /* @min:%2eidentifier */]);\r\n itemCtx = itemCtx || _self._getTelCtx(itemCtx);\r\n var event = ev;\r\n if (!_disableTelemetry && !_isTeardownCalled) {\r\n // Override iKey if provided in Post config if provided for during initialization\r\n if (_overrideInstrumentationKey) {\r\n event[_DYN_I_KEY /* @min:%2eiKey */] = _overrideInstrumentationKey;\r\n }\r\n _addEventToQueues(event, true);\r\n if (_isPageUnloadTriggered) {\r\n // Unload event has been received so we need to try and flush new events\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n }\r\n else {\r\n _scheduleTimer();\r\n }\r\n }\r\n _self.processNext(event, itemCtx);\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState) {\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n _isTeardownCalled = true;\r\n _httpManager.teardown();\r\n _removeUnloadHandlers();\r\n // Just register to remove all events associated with this namespace\r\n _initDefaults();\r\n };\r\n function _removeUnloadHandlers() {\r\n removePageUnloadEventListener(null, _evtNamespace);\r\n removePageHideEventListener(null, _evtNamespace);\r\n removePageShowEventListener(null, _evtNamespace);\r\n }\r\n function _hookWParam(core) {\r\n var existingGetWParamMethod = core[_DYN_GET_WPARAM /* @min:%2egetWParam */];\r\n core[_DYN_GET_WPARAM /* @min:%2egetWParam */] = function () {\r\n var wparam = 0;\r\n if (_ignoreMc1Ms0CookieProcessing) {\r\n wparam = wparam | 2;\r\n }\r\n return wparam | existingGetWParamMethod.call(core);\r\n };\r\n }\r\n // Moving event handlers out from the initialize closure so that any local variables can be garbage collected\r\n function _handleUnloadEvents(evt) {\r\n var theEvt = evt || getWindow().event; // IE 8 does not pass the event\r\n if (theEvt.type !== \"beforeunload\") {\r\n // Only set the unload trigger if not beforeunload event as beforeunload can be cancelled while the other events can't\r\n _isPageUnloadTriggered = true;\r\n _httpManager[_DYN_SET_UNLOADING /* @min:%2esetUnloading */](_isPageUnloadTriggered);\r\n }\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n }\r\n function _handleShowEvents(evt) {\r\n // Handle the page becoming visible again\r\n _isPageUnloadTriggered = false;\r\n _httpManager[_DYN_SET_UNLOADING /* @min:%2esetUnloading */](_isPageUnloadTriggered);\r\n }\r\n function _addEventToQueues(event, append) {\r\n // If send attempt field is undefined we should set it to 0.\r\n if (!event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */]) {\r\n event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] = 0;\r\n }\r\n // Add default latency\r\n if (!event[_DYN_LATENCY /* @min:%2elatency */]) {\r\n event[_DYN_LATENCY /* @min:%2elatency */] = 1 /* EventLatencyValue.Normal */;\r\n }\r\n // Remove extra AI properties if present\r\n if (event.ext && event.ext[STR_TRACE]) {\r\n delete (event.ext[STR_TRACE]);\r\n }\r\n if (event.ext && event.ext[STR_USER] && event.ext[STR_USER][\"id\"]) {\r\n delete (event.ext[STR_USER][\"id\"]);\r\n }\r\n // v8 performance optimization for iterating over the keys\r\n if (_optimizeObject) {\r\n event.ext = optimizeObject(event.ext);\r\n if (event[_DYN_BASE_DATA /* @min:%2ebaseData */]) {\r\n event[_DYN_BASE_DATA /* @min:%2ebaseData */] = optimizeObject(event[_DYN_BASE_DATA /* @min:%2ebaseData */]);\r\n }\r\n if (event[_DYN_DATA /* @min:%2edata */]) {\r\n event[_DYN_DATA /* @min:%2edata */] = optimizeObject(event[_DYN_DATA /* @min:%2edata */]);\r\n }\r\n }\r\n if (event[_DYN_SYNC /* @min:%2esync */]) {\r\n // If the transmission is backed off then do not send synchronous events.\r\n // We will convert these events to Real time latency instead.\r\n if (_currentBackoffCount || _paused) {\r\n event[_DYN_LATENCY /* @min:%2elatency */] = 3 /* EventLatencyValue.RealTime */;\r\n event[_DYN_SYNC /* @min:%2esync */] = false;\r\n }\r\n else {\r\n // Log the event synchronously\r\n if (_httpManager) {\r\n // v8 performance optimization for iterating over the keys\r\n if (_optimizeObject) {\r\n event = optimizeObject(event);\r\n }\r\n _httpManager[_DYN_SEND_SYNCHRONOUS_BAT9 /* @min:%2esendSynchronousBatch */](EventBatch.create(event[_DYN_I_KEY /* @min:%2eiKey */], [event]), event[_DYN_SYNC /* @min:%2esync */] === true ? 1 /* EventSendType.Synchronous */ : event[_DYN_SYNC /* @min:%2esync */], 3 /* SendRequestReason.SyncEvent */);\r\n return;\r\n }\r\n }\r\n }\r\n var evtLatency = event[_DYN_LATENCY /* @min:%2elatency */];\r\n var queueSize = _queueSize;\r\n var queueLimit = _queueSizeLimit;\r\n if (evtLatency === 4 /* EventLatencyValue.Immediate */) {\r\n queueSize = _immediateQueueSize;\r\n queueLimit = _immediateQueueSizeLimit;\r\n }\r\n var eventDropped = false;\r\n // Only add the event if the queue isn't full or it's a direct event (which don't add to the queue sizes)\r\n if (queueSize < queueLimit) {\r\n eventDropped = !_addEventToProperQueue(event, append);\r\n }\r\n else {\r\n var dropLatency = 1 /* EventLatencyValue.Normal */;\r\n var dropNumber = EventsDroppedAtOneTime;\r\n if (evtLatency === 4 /* EventLatencyValue.Immediate */) {\r\n // Only drop other immediate events as they are not technically sharing the general queue\r\n dropLatency = 4 /* EventLatencyValue.Immediate */;\r\n dropNumber = 1;\r\n }\r\n // Drop old event from lower or equal latency\r\n eventDropped = true;\r\n if (_dropEventWithLatencyOrLess(event[_DYN_I_KEY /* @min:%2eiKey */], event[_DYN_LATENCY /* @min:%2elatency */], dropLatency, dropNumber)) {\r\n eventDropped = !_addEventToProperQueue(event, append);\r\n }\r\n }\r\n if (eventDropped) {\r\n // Can't drop events from current queues because the all the slots are taken by queues that are being flushed.\r\n _notifyEvents(strEventsDiscarded, [event], EventsDiscardedReason.QueueFull);\r\n }\r\n }\r\n _self.setEventQueueLimits = function (eventLimit, autoFlushLimit) {\r\n _postConfig[_DYN_EVENTS_LIMIT_IN_MEM /* @min:%2eeventsLimitInMem */] = _queueSizeLimit = isGreaterThanZero(eventLimit) ? eventLimit : MaxEventsLimitInMem;\r\n _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI13 /* @min:%2eautoFlushEventsLimit */] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;\r\n _setAutoLimits();\r\n // We only do this check here as during normal event addition if the queue is > then events start getting dropped\r\n var doFlush = _queueSize > eventLimit;\r\n if (!doFlush && _autoFlushBatchLimit > 0) {\r\n // Check the auto flush max batch size\r\n for (var latency = 1 /* EventLatencyValue.Normal */; !doFlush && latency <= 3 /* EventLatencyValue.RealTime */; latency++) {\r\n var batchQueue = _batchQueues[latency];\r\n if (batchQueue && batchQueue[_DYN_BATCHES /* @min:%2ebatches */]) {\r\n arrForEach(batchQueue[_DYN_BATCHES /* @min:%2ebatches */], function (theBatch) {\r\n if (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() >= _autoFlushBatchLimit) {\r\n // If any 1 batch is > than the limit then trigger an auto flush\r\n doFlush = true;\r\n }\r\n });\r\n }\r\n }\r\n }\r\n _performAutoFlush(true, doFlush);\r\n };\r\n _self.pause = function () {\r\n _clearScheduledTimer();\r\n _paused = true;\r\n _httpManager.pause();\r\n };\r\n _self.resume = function () {\r\n _paused = false;\r\n _httpManager.resume();\r\n _scheduleTimer();\r\n };\r\n _self._loadTransmitProfiles = function (profiles) {\r\n _resetTransmitProfiles();\r\n objForEachKey(profiles, function (profileName, profileValue) {\r\n var profLen = profileValue[_DYN_LENGTH /* @min:%2elength */];\r\n if (profLen >= 2) {\r\n var directValue = (profLen > 2 ? profileValue[2] : 0);\r\n profileValue[_DYN_SPLICE /* @min:%2esplice */](0, profLen - 2);\r\n // Make sure if a higher latency is set to not send then don't send lower latency\r\n if (profileValue[1] < 0) {\r\n profileValue[0] = -1;\r\n }\r\n // Make sure each latency is multiple of the latency higher then it. If not a multiple\r\n // we round up so that it becomes a multiple.\r\n if (profileValue[1] > 0 && profileValue[0] > 0) {\r\n var timerMultiplier = profileValue[0] / profileValue[1];\r\n profileValue[0] = Math.ceil(timerMultiplier) * profileValue[1];\r\n }\r\n // Add back the direct profile timeout\r\n if (directValue >= 0 && profileValue[1] >= 0 && directValue > profileValue[1]) {\r\n // Make sure if it's not disabled (< 0) then make sure it's not larger than RealTime\r\n directValue = profileValue[1];\r\n }\r\n profileValue[_DYN_PUSH /* @min:%2epush */](directValue);\r\n _profiles[profileName] = profileValue;\r\n }\r\n });\r\n };\r\n _self.flush = function (async, callback, sendReason) {\r\n if (async === void 0) { async = true; }\r\n var result;\r\n if (!_paused) {\r\n sendReason = sendReason || 1 /* SendRequestReason.ManualFlush */;\r\n if (async) {\r\n if (!callback) {\r\n result = createPromise(function (resolve) {\r\n // Set the callback to the promise resolve callback\r\n callback = resolve;\r\n });\r\n }\r\n if (_flushCallbackTimer == null) {\r\n // Clear the normal schedule timer as we are going to try and flush ASAP\r\n _clearScheduledTimer();\r\n // Move all queued events to the HttpManager so that we don't discard new events (Auto flush scenario)\r\n _queueBatches(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);\r\n _flushCallbackTimer = _createTimer(function () {\r\n _flushCallbackTimer = null;\r\n _flushImpl(callback, sendReason);\r\n }, 0);\r\n }\r\n else {\r\n // Even if null (no callback) this will ensure after the flushImpl finishes waiting\r\n // for a completely idle connection it will attempt to re-flush any queued events on the next cycle\r\n _flushCallbackQueue[_DYN_PUSH /* @min:%2epush */](callback);\r\n }\r\n }\r\n else {\r\n // Clear the normal schedule timer as we are going to try and flush ASAP\r\n var cleared = _clearScheduledTimer();\r\n // Now cause all queued events to be sent synchronously\r\n _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 1 /* EventSendType.Synchronous */, sendReason);\r\n callback && callback();\r\n if (cleared) {\r\n // restart the normal event timer if it was cleared\r\n _scheduleTimer();\r\n }\r\n }\r\n }\r\n return result;\r\n };\r\n _self.setMsaAuthTicket = function (ticket) {\r\n _httpManager.addHeader(STR_MSA_DEVICE_TICKET, ticket);\r\n };\r\n _self.hasEvents = _hasEvents;\r\n _self._setTransmitProfile = function (profileName) {\r\n if (_currentProfile !== profileName && _profiles[profileName] !== undefined) {\r\n _clearScheduledTimer();\r\n _currentProfile = profileName;\r\n _scheduleTimer();\r\n }\r\n };\r\n proxyFunctions(_self, function () { return _httpManager; }, [\"addResponseHandler\"]);\r\n /**\r\n * Batch and send events currently in the queue for the given latency.\r\n * @param latency - Latency for which to send events.\r\n */\r\n function _sendEventsForLatencyAndAbove(latency, sendType, sendReason) {\r\n var queued = _queueBatches(latency, sendType, sendReason);\r\n // Always trigger the request as while the post channel may not have queued additional events, the httpManager may already have waiting events\r\n _httpManager[_DYN_SEND_QUEUED_REQUESTS /* @min:%2esendQueuedRequests */](sendType, sendReason);\r\n return queued;\r\n }\r\n function _hasEvents() {\r\n return _queueSize > 0;\r\n }\r\n /**\r\n * Try to schedule the timer after which events will be sent. If there are\r\n * no events to be sent, or there is already a timer scheduled, or the\r\n * http manager doesn't have any idle connections this method is no-op.\r\n */\r\n function _scheduleTimer() {\r\n // If we had previously attempted to send requests, but the http manager didn't have any idle connections then the requests where delayed\r\n // so try and requeue then again now\r\n if (_delayedBatchSendLatency >= 0 && _queueBatches(_delayedBatchSendLatency, 0 /* EventSendType.Batched */, _delayedBatchReason)) {\r\n _httpManager[_DYN_SEND_QUEUED_REQUESTS /* @min:%2esendQueuedRequests */](0 /* EventSendType.Batched */, _delayedBatchReason);\r\n }\r\n if (_immediateQueueSize > 0 && !_immediateTimer && !_paused) {\r\n // During initialization _profiles enforce that the direct [2] is less than real time [1] timer value\r\n // If the immediateTimeout is disabled the immediate events will be sent with Real Time events\r\n var immediateTimeOut = _profiles[_currentProfile][2];\r\n if (immediateTimeOut >= 0) {\r\n _immediateTimer = _createTimer(function () {\r\n _immediateTimer = null;\r\n // Only try to send direct events\r\n _sendEventsForLatencyAndAbove(4 /* EventLatencyValue.Immediate */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);\r\n _scheduleTimer();\r\n }, immediateTimeOut);\r\n }\r\n }\r\n // During initialization the _profiles enforce that the normal [0] is a multiple of the real time [1] timer value\r\n var timeOut = _profiles[_currentProfile][1];\r\n if (!_scheduledTimer && !_flushCallbackTimer && timeOut >= 0 && !_paused) {\r\n if (_hasEvents()) {\r\n _scheduledTimer = _createTimer(function () {\r\n _scheduledTimer = null;\r\n _sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 /* EventLatencyValue.RealTime */ : 1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);\r\n // Increment the count for next cycle\r\n _timerCount++;\r\n _timerCount %= 2;\r\n _scheduleTimer();\r\n }, timeOut);\r\n }\r\n else {\r\n _timerCount = 0;\r\n }\r\n }\r\n }\r\n _self[_DYN__BACK_OFF_TRANSMISSI11 /* @min:%2e_backOffTransmission */] = function () {\r\n if (_currentBackoffCount < MaxBackoffCount) {\r\n _currentBackoffCount++;\r\n _clearScheduledTimer();\r\n _scheduleTimer();\r\n }\r\n };\r\n _self._clearBackOff = function () {\r\n if (_currentBackoffCount) {\r\n _currentBackoffCount = 0;\r\n _clearScheduledTimer();\r\n _scheduleTimer();\r\n }\r\n };\r\n function _initDefaults() {\r\n _postConfig = null;\r\n _isTeardownCalled = false;\r\n _flushCallbackQueue = [];\r\n _flushCallbackTimer = null;\r\n _paused = false;\r\n _immediateQueueSize = 0;\r\n _immediateQueueSizeLimit = 500;\r\n _queueSize = 0;\r\n _queueSizeLimit = MaxEventsLimitInMem;\r\n _profiles = {};\r\n _currentProfile = RT_PROFILE;\r\n _scheduledTimer = null;\r\n _immediateTimer = null;\r\n _currentBackoffCount = 0;\r\n _timerCount = 0;\r\n _batchQueues = {};\r\n _autoFlushEventsLimit = 0;\r\n _unloadHandlersAdded = false;\r\n // either MaxBatchSize * (1+ Max Connections) or _queueLimit / 6 (where 3 latency Queues [normal, realtime, cost deferred] * 2 [allow half full -- allow for retry])\r\n _autoFlushBatchLimit = 0;\r\n _delayedBatchSendLatency = -1;\r\n _delayedBatchReason = null;\r\n _optimizeObject = true;\r\n _isPageUnloadTriggered = false;\r\n _maxEventSendAttempts = MaxSendAttempts;\r\n _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;\r\n _evtNamespace = null;\r\n _overrideInstrumentationKey = null;\r\n _disableTelemetry = false;\r\n _timeoutWrapper = createTimeoutWrapper();\r\n _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {\r\n requeue: _requeueEvents,\r\n send: _sendingEvent,\r\n sent: _eventsSentEvent,\r\n drop: _eventsDropped,\r\n rspFail: _eventsResponseFail,\r\n oth: _otherEvent\r\n });\r\n _initializeProfiles();\r\n _clearQueues();\r\n _setAutoLimits();\r\n }\r\n function _createTimer(theTimerFunc, timeOut) {\r\n // If the transmission is backed off make the timer at least 1 sec to allow for back off.\r\n if (timeOut === 0 && _currentBackoffCount) {\r\n timeOut = 1;\r\n }\r\n var timerMultiplier = 1000;\r\n if (_currentBackoffCount) {\r\n timerMultiplier = retryPolicyGetMillisToBackoffForRetry(_currentBackoffCount - 1);\r\n }\r\n return _timeoutWrapper.set(theTimerFunc, timeOut * timerMultiplier);\r\n }\r\n function _clearScheduledTimer() {\r\n if (_scheduledTimer !== null) {\r\n _scheduledTimer.cancel();\r\n _scheduledTimer = null;\r\n _timerCount = 0;\r\n return true;\r\n }\r\n return false;\r\n }\r\n // Try to send all queued events using beacons if available\r\n function _releaseAllQueues(sendType, sendReason) {\r\n _clearScheduledTimer();\r\n // Cancel all flush callbacks\r\n if (_flushCallbackTimer) {\r\n _flushCallbackTimer.cancel();\r\n _flushCallbackTimer = null;\r\n }\r\n if (!_paused) {\r\n // Queue all the remaining requests to be sent. The requests will be sent using HTML5 Beacons if they are available.\r\n _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, sendType, sendReason);\r\n }\r\n }\r\n /**\r\n * Add empty queues for all latencies in the inbound queues map. This is called\r\n * when Transmission Manager is being flushed. This ensures that new events added\r\n * after flush are stored separately till we flush the current events.\r\n */\r\n function _clearQueues() {\r\n _batchQueues[4 /* EventLatencyValue.Immediate */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n _batchQueues[3 /* EventLatencyValue.RealTime */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n _batchQueues[2 /* EventLatencyValue.CostDeferred */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n _batchQueues[1 /* EventLatencyValue.Normal */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n }\r\n function _getEventBatch(iKey, latency, create) {\r\n var batchQueue = _batchQueues[latency];\r\n if (!batchQueue) {\r\n latency = 1 /* EventLatencyValue.Normal */;\r\n batchQueue = _batchQueues[latency];\r\n }\r\n var eventBatch = batchQueue.iKeyMap[iKey];\r\n if (!eventBatch && create) {\r\n eventBatch = EventBatch.create(iKey);\r\n batchQueue.batches[_DYN_PUSH /* @min:%2epush */](eventBatch);\r\n batchQueue.iKeyMap[iKey] = eventBatch;\r\n }\r\n return eventBatch;\r\n }\r\n function _performAutoFlush(isAsync, doFlush) {\r\n // Only perform the auto flush check if the httpManager has an idle connection and we are not in a backoff situation\r\n if (_httpManager[_DYN_CAN_SEND_REQUEST /* @min:%2ecanSendRequest */]() && !_currentBackoffCount) {\r\n if (_autoFlushEventsLimit > 0 && _queueSize > _autoFlushEventsLimit) {\r\n // Force flushing\r\n doFlush = true;\r\n }\r\n if (doFlush && _flushCallbackTimer == null) {\r\n // Auto flush the queue, adding a callback to avoid the creation of a promise\r\n _self.flush(isAsync, function () { }, 20 /* SendRequestReason.MaxQueuedEvents */);\r\n }\r\n }\r\n }\r\n function _addEventToProperQueue(event, append) {\r\n // v8 performance optimization for iterating over the keys\r\n if (_optimizeObject) {\r\n event = optimizeObject(event);\r\n }\r\n var latency = event[_DYN_LATENCY /* @min:%2elatency */];\r\n var eventBatch = _getEventBatch(event[_DYN_I_KEY /* @min:%2eiKey */], latency, true);\r\n if (eventBatch.addEvent(event)) {\r\n if (latency !== 4 /* EventLatencyValue.Immediate */) {\r\n _queueSize++;\r\n // Check for auto flushing based on total events in the queue, but not for requeued or retry events\r\n if (append && event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] === 0) {\r\n // Force the flushing of the batch if the batch (specific iKey / latency combination) reaches it's auto flush limit\r\n _performAutoFlush(!event.sync, _autoFlushBatchLimit > 0 && eventBatch[_DYN_COUNT /* @min:%2ecount */]() >= _autoFlushBatchLimit);\r\n }\r\n }\r\n else {\r\n // Direct events don't need auto flushing as they are scheduled (by default) for immediate delivery\r\n _immediateQueueSize++;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n function _dropEventWithLatencyOrLess(iKey, latency, currentLatency, dropNumber) {\r\n while (currentLatency <= latency) {\r\n var eventBatch = _getEventBatch(iKey, latency, true);\r\n if (eventBatch && eventBatch[_DYN_COUNT /* @min:%2ecount */]() > 0) {\r\n // Dropped oldest events from lowest possible latency\r\n var droppedEvents = eventBatch[_DYN_SPLIT /* @min:%2esplit */](0, dropNumber);\r\n var droppedCount = droppedEvents[_DYN_COUNT /* @min:%2ecount */]();\r\n if (droppedCount > 0) {\r\n if (currentLatency === 4 /* EventLatencyValue.Immediate */) {\r\n _immediateQueueSize -= droppedCount;\r\n }\r\n else {\r\n _queueSize -= droppedCount;\r\n }\r\n _notifyBatchEvents(strEventsDiscarded, [droppedEvents], EventsDiscardedReason.QueueFull);\r\n return true;\r\n }\r\n }\r\n currentLatency++;\r\n }\r\n // Unable to drop any events -- lets just make sure the queue counts are correct to avoid exhaustion\r\n _resetQueueCounts();\r\n return false;\r\n }\r\n /**\r\n * Internal helper to reset the queue counts, used as a backstop to avoid future queue exhaustion errors\r\n * that might occur because of counting issues.\r\n */\r\n function _resetQueueCounts() {\r\n var immediateQueue = 0;\r\n var normalQueue = 0;\r\n var _loop_1 = function (latency) {\r\n var batchQueue = _batchQueues[latency];\r\n if (batchQueue && batchQueue[_DYN_BATCHES /* @min:%2ebatches */]) {\r\n arrForEach(batchQueue[_DYN_BATCHES /* @min:%2ebatches */], function (theBatch) {\r\n if (latency === 4 /* EventLatencyValue.Immediate */) {\r\n immediateQueue += theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n else {\r\n normalQueue += theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n });\r\n }\r\n };\r\n for (var latency = 1 /* EventLatencyValue.Normal */; latency <= 4 /* EventLatencyValue.Immediate */; latency++) {\r\n _loop_1(latency);\r\n }\r\n _queueSize = normalQueue;\r\n _immediateQueueSize = immediateQueue;\r\n }\r\n function _queueBatches(latency, sendType, sendReason) {\r\n var eventsQueued = false;\r\n var isAsync = sendType === 0 /* EventSendType.Batched */;\r\n // Only queue batches (to the HttpManager) if this is a sync request or the httpManager has an idle connection\r\n // Thus keeping the events within the PostChannel until the HttpManager has a connection available\r\n // This is so we can drop \"old\" events if the queue is getting full because we can't successfully send events\r\n if (!isAsync || _httpManager[_DYN_CAN_SEND_REQUEST /* @min:%2ecanSendRequest */]()) {\r\n doPerf(_self.core, function () { return \"PostChannel._queueBatches\"; }, function () {\r\n var droppedEvents = [];\r\n var latencyToProcess = 4 /* EventLatencyValue.Immediate */;\r\n while (latencyToProcess >= latency) {\r\n var batchQueue = _batchQueues[latencyToProcess];\r\n if (batchQueue && batchQueue.batches && batchQueue.batches[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n arrForEach(batchQueue[_DYN_BATCHES /* @min:%2ebatches */], function (theBatch) {\r\n // Add the batch to the http manager to send the requests\r\n if (!_httpManager.addBatch(theBatch)) {\r\n // The events from this iKey are being dropped (killed)\r\n droppedEvents = droppedEvents[_DYN_CONCAT /* @min:%2econcat */](theBatch[_DYN_EVENTS /* @min:%2eevents */]());\r\n }\r\n else {\r\n eventsQueued = eventsQueued || (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() > 0);\r\n }\r\n if (latencyToProcess === 4 /* EventLatencyValue.Immediate */) {\r\n _immediateQueueSize -= theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n else {\r\n _queueSize -= theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n });\r\n // Remove all batches from this Queue\r\n batchQueue[_DYN_BATCHES /* @min:%2ebatches */] = [];\r\n batchQueue.iKeyMap = {};\r\n }\r\n latencyToProcess--;\r\n }\r\n if (droppedEvents[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _notifyEvents(strEventsDiscarded, droppedEvents, EventsDiscardedReason.KillSwitch);\r\n }\r\n if (eventsQueued && _delayedBatchSendLatency >= latency) {\r\n // We have queued events at the same level as the delayed values so clear the setting\r\n _delayedBatchSendLatency = -1;\r\n _delayedBatchReason = 0 /* SendRequestReason.Undefined */;\r\n }\r\n }, function () { return ({ latency: latency, sendType: sendType, sendReason: sendReason }); }, !isAsync);\r\n }\r\n else {\r\n // remember the min latency so that we can re-trigger later\r\n _delayedBatchSendLatency = _delayedBatchSendLatency >= 0 ? Math.min(_delayedBatchSendLatency, latency) : latency;\r\n _delayedBatchReason = Math.max(_delayedBatchReason, sendReason);\r\n }\r\n return eventsQueued;\r\n }\r\n /**\r\n * This is the callback method is called as part of the manual flushing process.\r\n * @param callback\r\n * @param sendReason\r\n */\r\n function _flushImpl(callback, sendReason) {\r\n // Add any additional queued events and cause all queued events to be sent asynchronously\r\n _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);\r\n // All events (should) have been queue -- lets just make sure the queue counts are correct to avoid queue exhaustion (previous bug #9685112)\r\n _resetQueueCounts();\r\n _waitForIdleManager(function () {\r\n // Only called AFTER the httpManager does not have any outstanding requests\r\n if (callback) {\r\n callback();\r\n }\r\n if (_flushCallbackQueue[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _flushCallbackTimer = _createTimer(function () {\r\n _flushCallbackTimer = null;\r\n _flushImpl(_flushCallbackQueue.shift(), sendReason);\r\n }, 0);\r\n }\r\n else {\r\n // No more flush requests\r\n _flushCallbackTimer = null;\r\n // Restart the normal timer schedule\r\n _scheduleTimer();\r\n }\r\n });\r\n }\r\n function _waitForIdleManager(callback) {\r\n if (_httpManager[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */]()) {\r\n callback();\r\n }\r\n else {\r\n _flushCallbackTimer = _createTimer(function () {\r\n _flushCallbackTimer = null;\r\n _waitForIdleManager(callback);\r\n }, FlushCheckTimer);\r\n }\r\n }\r\n /**\r\n * Resets the transmit profiles to the default profiles of Real Time, Near Real Time\r\n * and Best Effort. This removes all the custom profiles that were loaded.\r\n */\r\n function _resetTransmitProfiles() {\r\n _clearScheduledTimer();\r\n _initializeProfiles();\r\n _currentProfile = RT_PROFILE;\r\n _scheduleTimer();\r\n }\r\n function _initializeProfiles() {\r\n _profiles = {};\r\n _profiles[RT_PROFILE] = [2, 1, 0];\r\n _profiles[NRT_PROFILE] = [6, 3, 0];\r\n _profiles[BE_PROFILE] = [18, 9, 0];\r\n }\r\n /**\r\n * The notification handler for requeue events\r\n * @ignore\r\n */\r\n function _requeueEvents(batches, reason) {\r\n var droppedEvents = [];\r\n var maxSendAttempts = _maxEventSendAttempts;\r\n if (_isPageUnloadTriggered) {\r\n // If a page unlaod has been triggered reduce the number of times we try to \"retry\"\r\n maxSendAttempts = _maxUnloadEventSendAttempts;\r\n }\r\n arrForEach(batches, function (theBatch) {\r\n if (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() > 0) {\r\n arrForEach(theBatch[_DYN_EVENTS /* @min:%2eevents */](), function (theEvent) {\r\n if (theEvent) {\r\n // Check if the request being added back is for a sync event in which case mark it no longer a sync event\r\n if (theEvent[_DYN_SYNC /* @min:%2esync */]) {\r\n theEvent[_DYN_LATENCY /* @min:%2elatency */] = 4 /* EventLatencyValue.Immediate */;\r\n theEvent[_DYN_SYNC /* @min:%2esync */] = false;\r\n }\r\n if (theEvent[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] < maxSendAttempts) {\r\n // Reset the event timings\r\n setProcessTelemetryTimings(theEvent, _self[_DYN_IDENTIFIER /* @min:%2eidentifier */]);\r\n _addEventToQueues(theEvent, false);\r\n }\r\n else {\r\n droppedEvents[_DYN_PUSH /* @min:%2epush */](theEvent);\r\n }\r\n }\r\n });\r\n }\r\n });\r\n if (droppedEvents[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _notifyEvents(strEventsDiscarded, droppedEvents, EventsDiscardedReason.NonRetryableStatus);\r\n }\r\n if (_isPageUnloadTriggered) {\r\n // Unload event has been received so we need to try and flush new events\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n }\r\n }\r\n function _callNotification(evtName, theArgs) {\r\n var manager = (_notificationManager || {});\r\n var notifyFunc = manager[evtName];\r\n if (notifyFunc) {\r\n try {\r\n notifyFunc.apply(manager, theArgs);\r\n }\r\n catch (e) {\r\n _throwInternal(_self.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 74 /* _eInternalMessageId.NotificationException */, evtName + \" notification failed: \" + e);\r\n }\r\n }\r\n }\r\n function _notifyEvents(evtName, theEvents) {\r\n var extraArgs = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n extraArgs[_i - 2] = arguments[_i];\r\n }\r\n if (theEvents && theEvents[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _callNotification(evtName, [theEvents][_DYN_CONCAT /* @min:%2econcat */](extraArgs));\r\n }\r\n }\r\n function _notifyBatchEvents(evtName, batches) {\r\n var extraArgs = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n extraArgs[_i - 2] = arguments[_i];\r\n }\r\n if (batches && batches[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n arrForEach(batches, function (theBatch) {\r\n if (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() > 0) {\r\n _callNotification(evtName, [theBatch.events()][_DYN_CONCAT /* @min:%2econcat */](extraArgs));\r\n }\r\n });\r\n }\r\n }\r\n /**\r\n * The notification handler for when batches are about to be sent\r\n * @ignore\r\n */\r\n function _sendingEvent(batches, reason, isSyncRequest) {\r\n if (batches && batches[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _callNotification(\"eventsSendRequest\", [(reason >= 1000 /* EventBatchNotificationReason.SendingUndefined */ && reason <= 1999 /* EventBatchNotificationReason.SendingEventMax */ ?\r\n reason - 1000 /* EventBatchNotificationReason.SendingUndefined */ :\r\n 0 /* SendRequestReason.Undefined */), isSyncRequest !== true]);\r\n }\r\n }\r\n /**\r\n * This event represents that a batch of events have been successfully sent and a response received\r\n * @param batches The notification handler for when the batches have been successfully sent\r\n * @param reason For this event the reason will always be EventBatchNotificationReason.Complete\r\n */\r\n function _eventsSentEvent(batches, reason) {\r\n _notifyBatchEvents(\"eventsSent\", batches, reason);\r\n // Try and schedule the processing timer if we have events\r\n _scheduleTimer();\r\n }\r\n function _eventsDropped(batches, reason) {\r\n _notifyBatchEvents(strEventsDiscarded, batches, (reason >= 8000 /* EventBatchNotificationReason.EventsDropped */ && reason <= 8999 /* EventBatchNotificationReason.EventsDroppedMax */ ?\r\n reason - 8000 /* EventBatchNotificationReason.EventsDropped */ :\r\n EventsDiscardedReason.Unknown));\r\n }\r\n function _eventsResponseFail(batches) {\r\n _notifyBatchEvents(strEventsDiscarded, batches, EventsDiscardedReason.NonRetryableStatus);\r\n // Try and schedule the processing timer if we have events\r\n _scheduleTimer();\r\n }\r\n function _otherEvent(batches, reason) {\r\n _notifyBatchEvents(strEventsDiscarded, batches, EventsDiscardedReason.Unknown);\r\n // Try and schedule the processing timer if we have events\r\n _scheduleTimer();\r\n }\r\n function _setAutoLimits() {\r\n if (!_disableAutoBatchFlushLimit) {\r\n _autoFlushBatchLimit = Math.max(MaxNumberEventPerBatch * (MaxConnections + 1), _queueSizeLimit / 6);\r\n }\r\n else {\r\n _autoFlushBatchLimit = 0;\r\n }\r\n }\r\n });\r\n return _this;\r\n }\r\n /**\r\n * Start the queue manager to batch and send events via post.\r\n * @param config - The core configuration.\r\n */\r\n PostChannel.prototype.initialize = function (coreConfig, core, extensions) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add an event to the appropriate inbound queue based on its latency.\r\n * @param ev - The event to be added to the queue.\r\n * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances\r\n * can optionally use this to access the current core instance or define / pass additional information\r\n * to later plugins (vs appending items to the telemetry item)\r\n */\r\n PostChannel.prototype.processTelemetry = function (ev, itemCtx) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Sets the event queue limits at runtime (after initialization), if the number of queued events is greater than the\r\n * eventLimit or autoFlushLimit then a flush() operation will be scheduled.\r\n * @param eventLimit The number of events that can be kept in memory before the SDK starts to drop events. If the value passed is less than or\r\n * equal to zero the value will be reset to the default (10,000).\r\n * @param autoFlushLimit When defined, once this number of events has been queued the system perform a flush() to send the queued events\r\n * without waiting for the normal schedule timers. Passing undefined, null or a value less than or equal to zero will disable the auto flush.\r\n */\r\n PostChannel.prototype.setEventQueueLimits = function (eventLimit, autoFlushLimit) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Pause the transmission of any requests\r\n */\r\n PostChannel.prototype.pause = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Resumes transmission of events.\r\n */\r\n PostChannel.prototype.resume = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add handler to be executed with request response text.\r\n */\r\n PostChannel.prototype.addResponseHandler = function (responseHanlder) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously (the default) and\r\n * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)\r\n * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`\r\n * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)\r\n * @param async - send data asynchronously when true\r\n * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.\r\n * If the caller doesn't return true the caller should assume that it may never be called.\r\n * @param sendReason - specify the reason that you are calling \"flush\" defaults to ManualFlush (1) if not specified\r\n * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller\r\n * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a\r\n * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,\r\n * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided\r\n * and async is true.\r\n */\r\n PostChannel.prototype.flush = function (async, callBack, sendReason) {\r\n if (async === void 0) { async = true; }\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Set AuthMsaDeviceTicket header\r\n * @param ticket - Ticket value.\r\n */\r\n PostChannel.prototype.setMsaAuthTicket = function (ticket) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Check if there are any events waiting to be scheduled for sending.\r\n * @returns True if there are events, false otherwise.\r\n */\r\n PostChannel.prototype.hasEvents = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Load custom transmission profiles. Each profile should have timers for real time, and normal and can\r\n * optionally specify the immediate latency time in ms (defaults to 0 when not defined). Each profile should\r\n * make sure that a each normal latency timer is a multiple of the real-time latency and the immediate\r\n * is smaller than the real-time.\r\n * Setting the timer value to -1 means that the events for that latency will not be scheduled to be sent.\r\n * Note that once a latency has been set to not send, all latencies below it will also not be sent. The\r\n * timers should be in the form of [normal, high, [immediate]].\r\n * e.g Custom:\r\n * [10,5] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms\r\n * [10,5,1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 1ms\r\n * [10,5,0] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms\r\n * [10,5,-1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate events will not be\r\n * scheduled on their own and but they will be included with real-time or normal events as the first events in a batch.\r\n * This also removes any previously loaded custom profiles.\r\n * @param profiles - A dictionary containing the transmit profiles.\r\n */\r\n PostChannel.prototype._loadTransmitProfiles = function (profiles) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Set the transmit profile to be used. This will change the transmission timers\r\n * based on the transmit profile.\r\n * @param profileName - The name of the transmit profile to be used.\r\n */\r\n PostChannel.prototype._setTransmitProfile = function (profileName) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Backs off transmission. This exponentially increases all the timers.\r\n */\r\n PostChannel.prototype._backOffTransmission = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Clears backoff for transmission.\r\n */\r\n PostChannel.prototype._clearBackOff = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n return PostChannel;\r\n}(BaseTelemetryPlugin));\r\nexport { PostChannel };\r\n//# sourceMappingURL=PostChannel.js.map"],"names":[],"mappings":";;;;;AAAA,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;wDAwHM,CAAC;;;;;uBACgB;AACvB;AACA;AACA"}
1
+ {"version":3,"file":"PostChannel.js.map","sources":["PostChannel.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\n/**\r\n* PostManager.ts\r\n* @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)\r\n* @copyright Microsoft 2018-2020\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseTelemetryPlugin, EventsDiscardedReason, _throwInternal, addPageHideEventListener, addPageShowEventListener, addPageUnloadEventListener, arrForEach, createProcessTelemetryContext, createUniqueNamespace, doPerf, getWindow, isChromium, isGreaterThanZero, isNumber, mergeEvtNamespace, objForEachKey, onConfigChange, optimizeObject, proxyFunctions, removePageHideEventListener, removePageShowEventListener, removePageUnloadEventListener, setProcessTelemetryTimings } from \"@microsoft/1ds-core-js\";\r\nimport { createPromise } from \"@nevware21/ts-async\";\r\nimport { objDeepFreeze } from \"@nevware21/ts-utils\";\r\nimport { BE_PROFILE, NRT_PROFILE, RT_PROFILE } from \"./DataModels\";\r\nimport { EventBatch } from \"./EventBatch\";\r\nimport { HttpManager } from \"./HttpManager\";\r\nimport { STR_MSA_DEVICE_TICKET, STR_TRACE, STR_USER } from \"./InternalConstants\";\r\nimport { retryPolicyGetMillisToBackoffForRetry } from \"./RetryPolicy\";\r\nimport { createTimeoutWrapper } from \"./TimeoutOverrideWrapper\";\r\nimport { _DYN_AUTO_FLUSH_EVENTS_LI15, _DYN_BASE_DATA, _DYN_BATCHES, _DYN_CAN_SEND_REQUEST, _DYN_CLEAR_TIMEOUT_OVERRI3, _DYN_CONCAT, _DYN_COUNT, _DYN_DATA, _DYN_DISABLE_AUTO_BATCH_F16, _DYN_DISABLE_OPTIMIZE_OBJ, _DYN_DISABLE_TELEMETRY, _DYN_EVENTS, _DYN_EVENTS_LIMIT_IN_MEM, _DYN_GET_OFFLINE_REQUEST_9, _DYN_GET_WPARAM, _DYN_HDRS, _DYN_IDENTIFIER, _DYN_IGNORE_MC1_MS0_COOKI14, _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE, _DYN_I_KEY, _DYN_LATENCY, _DYN_LENGTH, _DYN_OVERRIDE_INSTRUMENTA17, _DYN_PUSH, _DYN_SEND_ATTEMPT, _DYN_SEND_POST, _DYN_SEND_QUEUED_REQUESTS, _DYN_SEND_SYNCHRONOUS_BAT11, _DYN_SERIALIZE_OFFLINE_EV8, _DYN_SET_TIMEOUT_OVERRIDE, _DYN_SET_UNLOADING, _DYN_SPLICE, _DYN_SPLIT, _DYN_SYNC, _DYN__BACK_OFF_TRANSMISSI13 } from \"./__DynamicConstants\";\r\nvar FlushCheckTimer = 0.250; // This needs to be in seconds, so this is 250ms\r\nvar MaxNumberEventPerBatch = 500;\r\nvar EventsDroppedAtOneTime = 20;\r\nvar MaxSendAttempts = 6;\r\nvar MaxSyncUnloadSendAttempts = 2; // Assuming 2 based on beforeunload and unload\r\nvar MaxBackoffCount = 4;\r\nvar MaxConnections = 2;\r\nvar MaxRequestRetriesBeforeBackoff = 1;\r\nvar MaxEventsLimitInMem = 10000;\r\nvar strEventsDiscarded = \"eventsDiscarded\";\r\nvar EMPTY_STR = \"\";\r\nvar undefValue = undefined;\r\n/**\r\n * The default settings for the config.\r\n * WE MUST include all defaults here to ensure that the config is created with all of the properties\r\n * defined as dynamic.\r\n */\r\nvar defaultPostChannelConfig = objDeepFreeze({\r\n eventsLimitInMem: { isVal: isGreaterThanZero, v: MaxEventsLimitInMem },\r\n immediateEventLimit: { isVal: isGreaterThanZero, v: 500 },\r\n autoFlushEventsLimit: { isVal: isGreaterThanZero, v: 0 },\r\n disableAutoBatchFlushLimit: false,\r\n httpXHROverride: { isVal: isOverrideFn, v: undefValue },\r\n overrideInstrumentationKey: undefValue,\r\n overrideEndpointUrl: undefValue,\r\n disableTelemetry: false,\r\n ignoreMc1Ms0CookieProcessing: false,\r\n setTimeoutOverride: undefValue,\r\n clearTimeoutOverride: undefValue,\r\n payloadPreprocessor: undefValue,\r\n payloadListener: undefValue,\r\n disableEventTimings: undefValue,\r\n valueSanitizer: undefValue,\r\n stringifyObjects: undefValue,\r\n enableCompoundKey: undefValue,\r\n disableOptimizeObj: false,\r\n // disableCacheHeader: undefValue, // See Task #7178858 - Collector requires a change to support this\r\n transports: undefValue,\r\n unloadTransports: undefValue,\r\n useSendBeacon: undefValue,\r\n disableFetchKeepAlive: undefValue,\r\n avoidOptions: false,\r\n xhrTimeout: undefValue,\r\n disableXhrSync: undefValue,\r\n alwaysUseXhrOverride: false,\r\n maxEventRetryAttempts: { isVal: isNumber, v: MaxSendAttempts },\r\n maxUnloadEventRetryAttempts: { isVal: isNumber, v: MaxSyncUnloadSendAttempts },\r\n addNoResponse: undefValue,\r\n excludeCsMetaData: undefValue\r\n});\r\nfunction isOverrideFn(httpXHROverride) {\r\n return httpXHROverride && httpXHROverride[_DYN_SEND_POST /* @min:%2esendPOST */];\r\n}\r\n/**\r\n * Class that manages adding events to inbound queues and batching of events\r\n * into requests.\r\n * @group Classes\r\n * @group Entrypoint\r\n */\r\nvar PostChannel = /** @class */ (function (_super) {\r\n __extends(PostChannel, _super);\r\n function PostChannel() {\r\n var _this = _super.call(this) || this;\r\n _this.identifier = \"PostChannel\";\r\n _this.priority = 1011;\r\n _this.version = '4.1.0-nightly3.2402-03';\r\n var _postConfig;\r\n var _isTeardownCalled = false;\r\n var _flushCallbackQueue = [];\r\n var _flushCallbackTimer;\r\n var _paused = false;\r\n var _immediateQueueSize = 0;\r\n var _immediateQueueSizeLimit;\r\n var _queueSize = 0;\r\n var _queueSizeLimit;\r\n var _profiles = {};\r\n var _currentProfile = RT_PROFILE;\r\n var _scheduledTimer;\r\n var _immediateTimer;\r\n var _currentBackoffCount;\r\n var _timerCount;\r\n var _httpManager;\r\n var _batchQueues;\r\n var _autoFlushEventsLimit;\r\n // either MaxBatchSize * (1+ Max Connections) or _queueLimit / 6 (where 3 latency Queues [normal, realtime, cost deferred] * 2 [allow half full -- allow for retry])\r\n var _autoFlushBatchLimit;\r\n var _delayedBatchSendLatency;\r\n var _delayedBatchReason;\r\n var _optimizeObject;\r\n var _isPageUnloadTriggered;\r\n var _maxEventSendAttempts;\r\n var _maxUnloadEventSendAttempts;\r\n var _evtNamespace;\r\n var _timeoutWrapper;\r\n var _ignoreMc1Ms0CookieProcessing;\r\n var _disableAutoBatchFlushLimit;\r\n var _notificationManager;\r\n var _unloadHandlersAdded;\r\n var _overrideInstrumentationKey;\r\n var _disableTelemetry;\r\n dynamicProto(PostChannel, _this, function (_self, _base) {\r\n _initDefaults();\r\n // Special internal method to allow the DebugPlugin to hook embedded objects\r\n _self[\"_getDbgPlgTargets\"] = function () {\r\n return [_httpManager, _postConfig];\r\n };\r\n _self[_DYN_INITIALIZE /* @min:%2einitialize */] = function (theConfig, core, extensions) {\r\n doPerf(core, function () { return \"PostChannel:initialize\"; }, function () {\r\n _base[_DYN_INITIALIZE /* @min:%2einitialize */](theConfig, core, extensions);\r\n _notificationManager = core.getNotifyMgr();\r\n try {\r\n _evtNamespace = mergeEvtNamespace(createUniqueNamespace(_self[_DYN_IDENTIFIER /* @min:%2eidentifier */]), core.evtNamespace && core.evtNamespace());\r\n _self._addHook(onConfigChange(theConfig, function (details) {\r\n var coreConfig = details.cfg;\r\n var ctx = createProcessTelemetryContext(null, coreConfig, core);\r\n _postConfig = ctx.getExtCfg(_self[_DYN_IDENTIFIER /* @min:%2eidentifier */], defaultPostChannelConfig);\r\n _timeoutWrapper = createTimeoutWrapper(_postConfig[_DYN_SET_TIMEOUT_OVERRIDE /* @min:%2esetTimeoutOverride */], _postConfig[_DYN_CLEAR_TIMEOUT_OVERRI3 /* @min:%2eclearTimeoutOverride */]);\r\n // Only try and use the optimizeObject() if this appears to be a chromium based browser and it has not been explicitly disabled\r\n _optimizeObject = !_postConfig[_DYN_DISABLE_OPTIMIZE_OBJ /* @min:%2edisableOptimizeObj */] && isChromium();\r\n _ignoreMc1Ms0CookieProcessing = _postConfig[_DYN_IGNORE_MC1_MS0_COOKI14 /* @min:%2eignoreMc1Ms0CookieProcessing */];\r\n _hookWParam(core); // _hookWParam uses _ignoreMc1Ms0CookieProcessing\r\n _queueSizeLimit = _postConfig[_DYN_EVENTS_LIMIT_IN_MEM /* @min:%2eeventsLimitInMem */];\r\n _immediateQueueSizeLimit = _postConfig.immediateEventLimit;\r\n _autoFlushEventsLimit = _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 /* @min:%2eautoFlushEventsLimit */];\r\n _maxEventSendAttempts = _postConfig.maxEventRetryAttempts;\r\n _maxUnloadEventSendAttempts = _postConfig.maxUnloadEventRetryAttempts;\r\n _disableAutoBatchFlushLimit = _postConfig[_DYN_DISABLE_AUTO_BATCH_F16 /* @min:%2edisableAutoBatchFlushLimit */];\r\n _setAutoLimits();\r\n // Override iKey if provided in Post config if provided for during initialization\r\n _overrideInstrumentationKey = _postConfig[_DYN_OVERRIDE_INSTRUMENTA17 /* @min:%2eoverrideInstrumentationKey */];\r\n // DisableTelemetry was defined in the config provided during initialization\r\n _disableTelemetry = !!_postConfig[_DYN_DISABLE_TELEMETRY /* @min:%2edisableTelemetry */];\r\n if (_unloadHandlersAdded) {\r\n _removeUnloadHandlers();\r\n }\r\n var excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];\r\n // When running in Web browsers try to send all telemetry if page is unloaded\r\n _unloadHandlersAdded = addPageUnloadEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace);\r\n _unloadHandlersAdded = addPageHideEventListener(_handleUnloadEvents, excludePageUnloadEvents, _evtNamespace) || _unloadHandlersAdded;\r\n _unloadHandlersAdded = addPageShowEventListener(_handleShowEvents, coreConfig.disablePageShowEvents, _evtNamespace) || _unloadHandlersAdded;\r\n }));\r\n // only initialize the manager once\r\n _httpManager[_DYN_INITIALIZE /* @min:%2einitialize */](theConfig, _self.core, _self);\r\n }\r\n catch (e) {\r\n // resetting the initialized state because of failure\r\n _self.setInitialized(false);\r\n throw e;\r\n }\r\n }, function () { return ({ theConfig: theConfig, core: core, extensions: extensions }); });\r\n };\r\n _self.processTelemetry = function (ev, itemCtx) {\r\n setProcessTelemetryTimings(ev, _self[_DYN_IDENTIFIER /* @min:%2eidentifier */]);\r\n itemCtx = itemCtx || _self._getTelCtx(itemCtx);\r\n var event = ev;\r\n if (!_disableTelemetry && !_isTeardownCalled) {\r\n // Override iKey if provided in Post config if provided for during initialization\r\n if (_overrideInstrumentationKey) {\r\n event[_DYN_I_KEY /* @min:%2eiKey */] = _overrideInstrumentationKey;\r\n }\r\n _addEventToQueues(event, true);\r\n if (_isPageUnloadTriggered) {\r\n // Unload event has been received so we need to try and flush new events\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n }\r\n else {\r\n _scheduleTimer();\r\n }\r\n }\r\n _self.processNext(event, itemCtx);\r\n };\r\n _self.getOfflineSupport = function () {\r\n var details = _httpManager[_DYN_GET_OFFLINE_REQUEST_9 /* @min:%2egetOfflineRequestDetails */]();\r\n return {\r\n getUrl: function () {\r\n return details.url;\r\n },\r\n serialize: _serialize,\r\n batch: _batch,\r\n shouldProcess: function (evt) {\r\n return !_disableTelemetry;\r\n },\r\n createPayload: function (evt) {\r\n return {\r\n urlString: details.url,\r\n headers: details[_DYN_HDRS /* @min:%2ehdrs */],\r\n data: evt\r\n };\r\n }\r\n };\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState) {\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n _isTeardownCalled = true;\r\n _httpManager.teardown();\r\n _removeUnloadHandlers();\r\n // Just register to remove all events associated with this namespace\r\n _initDefaults();\r\n };\r\n function _removeUnloadHandlers() {\r\n removePageUnloadEventListener(null, _evtNamespace);\r\n removePageHideEventListener(null, _evtNamespace);\r\n removePageShowEventListener(null, _evtNamespace);\r\n }\r\n function _hookWParam(core) {\r\n var existingGetWParamMethod = core[_DYN_GET_WPARAM /* @min:%2egetWParam */];\r\n core[_DYN_GET_WPARAM /* @min:%2egetWParam */] = function () {\r\n var wparam = 0;\r\n if (_ignoreMc1Ms0CookieProcessing) {\r\n wparam = wparam | 2;\r\n }\r\n return wparam | existingGetWParamMethod.call(core);\r\n };\r\n }\r\n function _batch(arr) {\r\n var rlt = EMPTY_STR;\r\n if (arr && arr[_DYN_LENGTH /* @min:%2elength */]) {\r\n arrForEach(arr, function (item) {\r\n if (rlt) {\r\n rlt += \"\\n\";\r\n }\r\n rlt += item;\r\n });\r\n }\r\n return rlt;\r\n }\r\n function _serialize(event) {\r\n var rlt = EMPTY_STR;\r\n try {\r\n _cleanEvent(event);\r\n rlt = _httpManager[_DYN_SERIALIZE_OFFLINE_EV8 /* @min:%2eserializeOfflineEvt */](event);\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return rlt;\r\n }\r\n // Moving event handlers out from the initialize closure so that any local variables can be garbage collected\r\n function _handleUnloadEvents(evt) {\r\n var theEvt = evt || getWindow().event; // IE 8 does not pass the event\r\n if (theEvt.type !== \"beforeunload\") {\r\n // Only set the unload trigger if not beforeunload event as beforeunload can be cancelled while the other events can't\r\n _isPageUnloadTriggered = true;\r\n _httpManager[_DYN_SET_UNLOADING /* @min:%2esetUnloading */](_isPageUnloadTriggered);\r\n }\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n }\r\n function _handleShowEvents(evt) {\r\n // Handle the page becoming visible again\r\n _isPageUnloadTriggered = false;\r\n _httpManager[_DYN_SET_UNLOADING /* @min:%2esetUnloading */](_isPageUnloadTriggered);\r\n }\r\n function _cleanEvent(event) {\r\n if (event.ext && event.ext[STR_TRACE]) {\r\n delete (event.ext[STR_TRACE]);\r\n }\r\n if (event.ext && event.ext[STR_USER] && event.ext[STR_USER][\"id\"]) {\r\n delete (event.ext[STR_USER][\"id\"]);\r\n }\r\n // v8 performance optimization for iterating over the keys\r\n if (_optimizeObject) {\r\n event.ext = optimizeObject(event.ext);\r\n if (event[_DYN_BASE_DATA /* @min:%2ebaseData */]) {\r\n event[_DYN_BASE_DATA /* @min:%2ebaseData */] = optimizeObject(event[_DYN_BASE_DATA /* @min:%2ebaseData */]);\r\n }\r\n if (event[_DYN_DATA /* @min:%2edata */]) {\r\n event[_DYN_DATA /* @min:%2edata */] = optimizeObject(event[_DYN_DATA /* @min:%2edata */]);\r\n }\r\n }\r\n }\r\n function _addEventToQueues(event, append) {\r\n // If send attempt field is undefined we should set it to 0.\r\n if (!event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */]) {\r\n event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] = 0;\r\n }\r\n // Add default latency\r\n if (!event[_DYN_LATENCY /* @min:%2elatency */]) {\r\n event[_DYN_LATENCY /* @min:%2elatency */] = 1 /* EventLatencyValue.Normal */;\r\n }\r\n _cleanEvent(event);\r\n if (event[_DYN_SYNC /* @min:%2esync */]) {\r\n // If the transmission is backed off then do not send synchronous events.\r\n // We will convert these events to Real time latency instead.\r\n if (_currentBackoffCount || _paused) {\r\n event[_DYN_LATENCY /* @min:%2elatency */] = 3 /* EventLatencyValue.RealTime */;\r\n event[_DYN_SYNC /* @min:%2esync */] = false;\r\n }\r\n else {\r\n // Log the event synchronously\r\n if (_httpManager) {\r\n // v8 performance optimization for iterating over the keys\r\n if (_optimizeObject) {\r\n event = optimizeObject(event);\r\n }\r\n _httpManager[_DYN_SEND_SYNCHRONOUS_BAT11 /* @min:%2esendSynchronousBatch */](EventBatch.create(event[_DYN_I_KEY /* @min:%2eiKey */], [event]), event[_DYN_SYNC /* @min:%2esync */] === true ? 1 /* EventSendType.Synchronous */ : event[_DYN_SYNC /* @min:%2esync */], 3 /* SendRequestReason.SyncEvent */);\r\n return;\r\n }\r\n }\r\n }\r\n var evtLatency = event[_DYN_LATENCY /* @min:%2elatency */];\r\n var queueSize = _queueSize;\r\n var queueLimit = _queueSizeLimit;\r\n if (evtLatency === 4 /* EventLatencyValue.Immediate */) {\r\n queueSize = _immediateQueueSize;\r\n queueLimit = _immediateQueueSizeLimit;\r\n }\r\n var eventDropped = false;\r\n // Only add the event if the queue isn't full or it's a direct event (which don't add to the queue sizes)\r\n if (queueSize < queueLimit) {\r\n eventDropped = !_addEventToProperQueue(event, append);\r\n }\r\n else {\r\n var dropLatency = 1 /* EventLatencyValue.Normal */;\r\n var dropNumber = EventsDroppedAtOneTime;\r\n if (evtLatency === 4 /* EventLatencyValue.Immediate */) {\r\n // Only drop other immediate events as they are not technically sharing the general queue\r\n dropLatency = 4 /* EventLatencyValue.Immediate */;\r\n dropNumber = 1;\r\n }\r\n // Drop old event from lower or equal latency\r\n eventDropped = true;\r\n if (_dropEventWithLatencyOrLess(event[_DYN_I_KEY /* @min:%2eiKey */], event[_DYN_LATENCY /* @min:%2elatency */], dropLatency, dropNumber)) {\r\n eventDropped = !_addEventToProperQueue(event, append);\r\n }\r\n }\r\n if (eventDropped) {\r\n // Can't drop events from current queues because the all the slots are taken by queues that are being flushed.\r\n _notifyEvents(strEventsDiscarded, [event], EventsDiscardedReason.QueueFull);\r\n }\r\n }\r\n _self.setEventQueueLimits = function (eventLimit, autoFlushLimit) {\r\n _postConfig[_DYN_EVENTS_LIMIT_IN_MEM /* @min:%2eeventsLimitInMem */] = _queueSizeLimit = isGreaterThanZero(eventLimit) ? eventLimit : MaxEventsLimitInMem;\r\n _postConfig[_DYN_AUTO_FLUSH_EVENTS_LI15 /* @min:%2eautoFlushEventsLimit */] = _autoFlushEventsLimit = isGreaterThanZero(autoFlushLimit) ? autoFlushLimit : 0;\r\n _setAutoLimits();\r\n // We only do this check here as during normal event addition if the queue is > then events start getting dropped\r\n var doFlush = _queueSize > eventLimit;\r\n if (!doFlush && _autoFlushBatchLimit > 0) {\r\n // Check the auto flush max batch size\r\n for (var latency = 1 /* EventLatencyValue.Normal */; !doFlush && latency <= 3 /* EventLatencyValue.RealTime */; latency++) {\r\n var batchQueue = _batchQueues[latency];\r\n if (batchQueue && batchQueue[_DYN_BATCHES /* @min:%2ebatches */]) {\r\n arrForEach(batchQueue[_DYN_BATCHES /* @min:%2ebatches */], function (theBatch) {\r\n if (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() >= _autoFlushBatchLimit) {\r\n // If any 1 batch is > than the limit then trigger an auto flush\r\n doFlush = true;\r\n }\r\n });\r\n }\r\n }\r\n }\r\n _performAutoFlush(true, doFlush);\r\n };\r\n _self.pause = function () {\r\n _clearScheduledTimer();\r\n _paused = true;\r\n _httpManager.pause();\r\n };\r\n _self.resume = function () {\r\n _paused = false;\r\n _httpManager.resume();\r\n _scheduleTimer();\r\n };\r\n _self._loadTransmitProfiles = function (profiles) {\r\n _resetTransmitProfiles();\r\n objForEachKey(profiles, function (profileName, profileValue) {\r\n var profLen = profileValue[_DYN_LENGTH /* @min:%2elength */];\r\n if (profLen >= 2) {\r\n var directValue = (profLen > 2 ? profileValue[2] : 0);\r\n profileValue[_DYN_SPLICE /* @min:%2esplice */](0, profLen - 2);\r\n // Make sure if a higher latency is set to not send then don't send lower latency\r\n if (profileValue[1] < 0) {\r\n profileValue[0] = -1;\r\n }\r\n // Make sure each latency is multiple of the latency higher then it. If not a multiple\r\n // we round up so that it becomes a multiple.\r\n if (profileValue[1] > 0 && profileValue[0] > 0) {\r\n var timerMultiplier = profileValue[0] / profileValue[1];\r\n profileValue[0] = Math.ceil(timerMultiplier) * profileValue[1];\r\n }\r\n // Add back the direct profile timeout\r\n if (directValue >= 0 && profileValue[1] >= 0 && directValue > profileValue[1]) {\r\n // Make sure if it's not disabled (< 0) then make sure it's not larger than RealTime\r\n directValue = profileValue[1];\r\n }\r\n profileValue[_DYN_PUSH /* @min:%2epush */](directValue);\r\n _profiles[profileName] = profileValue;\r\n }\r\n });\r\n };\r\n _self.flush = function (async, callback, sendReason) {\r\n if (async === void 0) { async = true; }\r\n var result;\r\n if (!_paused) {\r\n sendReason = sendReason || 1 /* SendRequestReason.ManualFlush */;\r\n if (async) {\r\n if (!callback) {\r\n result = createPromise(function (resolve) {\r\n // Set the callback to the promise resolve callback\r\n callback = resolve;\r\n });\r\n }\r\n if (_flushCallbackTimer == null) {\r\n // Clear the normal schedule timer as we are going to try and flush ASAP\r\n _clearScheduledTimer();\r\n // Move all queued events to the HttpManager so that we don't discard new events (Auto flush scenario)\r\n _queueBatches(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);\r\n _flushCallbackTimer = _createTimer(function () {\r\n _flushCallbackTimer = null;\r\n _flushImpl(callback, sendReason);\r\n }, 0);\r\n }\r\n else {\r\n // Even if null (no callback) this will ensure after the flushImpl finishes waiting\r\n // for a completely idle connection it will attempt to re-flush any queued events on the next cycle\r\n _flushCallbackQueue[_DYN_PUSH /* @min:%2epush */](callback);\r\n }\r\n }\r\n else {\r\n // Clear the normal schedule timer as we are going to try and flush ASAP\r\n var cleared = _clearScheduledTimer();\r\n // Now cause all queued events to be sent synchronously\r\n _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 1 /* EventSendType.Synchronous */, sendReason);\r\n callback && callback();\r\n if (cleared) {\r\n // restart the normal event timer if it was cleared\r\n _scheduleTimer();\r\n }\r\n }\r\n }\r\n return result;\r\n };\r\n _self.setMsaAuthTicket = function (ticket) {\r\n _httpManager.addHeader(STR_MSA_DEVICE_TICKET, ticket);\r\n };\r\n _self.hasEvents = _hasEvents;\r\n _self._setTransmitProfile = function (profileName) {\r\n if (_currentProfile !== profileName && _profiles[profileName] !== undefined) {\r\n _clearScheduledTimer();\r\n _currentProfile = profileName;\r\n _scheduleTimer();\r\n }\r\n };\r\n proxyFunctions(_self, function () { return _httpManager; }, [\"addResponseHandler\"]);\r\n /**\r\n * Batch and send events currently in the queue for the given latency.\r\n * @param latency - Latency for which to send events.\r\n */\r\n function _sendEventsForLatencyAndAbove(latency, sendType, sendReason) {\r\n var queued = _queueBatches(latency, sendType, sendReason);\r\n // Always trigger the request as while the post channel may not have queued additional events, the httpManager may already have waiting events\r\n _httpManager[_DYN_SEND_QUEUED_REQUESTS /* @min:%2esendQueuedRequests */](sendType, sendReason);\r\n return queued;\r\n }\r\n function _hasEvents() {\r\n return _queueSize > 0;\r\n }\r\n /**\r\n * Try to schedule the timer after which events will be sent. If there are\r\n * no events to be sent, or there is already a timer scheduled, or the\r\n * http manager doesn't have any idle connections this method is no-op.\r\n */\r\n function _scheduleTimer() {\r\n // If we had previously attempted to send requests, but the http manager didn't have any idle connections then the requests where delayed\r\n // so try and requeue then again now\r\n if (_delayedBatchSendLatency >= 0 && _queueBatches(_delayedBatchSendLatency, 0 /* EventSendType.Batched */, _delayedBatchReason)) {\r\n _httpManager[_DYN_SEND_QUEUED_REQUESTS /* @min:%2esendQueuedRequests */](0 /* EventSendType.Batched */, _delayedBatchReason);\r\n }\r\n if (_immediateQueueSize > 0 && !_immediateTimer && !_paused) {\r\n // During initialization _profiles enforce that the direct [2] is less than real time [1] timer value\r\n // If the immediateTimeout is disabled the immediate events will be sent with Real Time events\r\n var immediateTimeOut = _profiles[_currentProfile][2];\r\n if (immediateTimeOut >= 0) {\r\n _immediateTimer = _createTimer(function () {\r\n _immediateTimer = null;\r\n // Only try to send direct events\r\n _sendEventsForLatencyAndAbove(4 /* EventLatencyValue.Immediate */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);\r\n _scheduleTimer();\r\n }, immediateTimeOut);\r\n }\r\n }\r\n // During initialization the _profiles enforce that the normal [0] is a multiple of the real time [1] timer value\r\n var timeOut = _profiles[_currentProfile][1];\r\n if (!_scheduledTimer && !_flushCallbackTimer && timeOut >= 0 && !_paused) {\r\n if (_hasEvents()) {\r\n _scheduledTimer = _createTimer(function () {\r\n _scheduledTimer = null;\r\n _sendEventsForLatencyAndAbove(_timerCount === 0 ? 3 /* EventLatencyValue.RealTime */ : 1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, 1 /* SendRequestReason.NormalSchedule */);\r\n // Increment the count for next cycle\r\n _timerCount++;\r\n _timerCount %= 2;\r\n _scheduleTimer();\r\n }, timeOut);\r\n }\r\n else {\r\n _timerCount = 0;\r\n }\r\n }\r\n }\r\n _self[_DYN__BACK_OFF_TRANSMISSI13 /* @min:%2e_backOffTransmission */] = function () {\r\n if (_currentBackoffCount < MaxBackoffCount) {\r\n _currentBackoffCount++;\r\n _clearScheduledTimer();\r\n _scheduleTimer();\r\n }\r\n };\r\n _self._clearBackOff = function () {\r\n if (_currentBackoffCount) {\r\n _currentBackoffCount = 0;\r\n _clearScheduledTimer();\r\n _scheduleTimer();\r\n }\r\n };\r\n function _initDefaults() {\r\n _postConfig = null;\r\n _isTeardownCalled = false;\r\n _flushCallbackQueue = [];\r\n _flushCallbackTimer = null;\r\n _paused = false;\r\n _immediateQueueSize = 0;\r\n _immediateQueueSizeLimit = 500;\r\n _queueSize = 0;\r\n _queueSizeLimit = MaxEventsLimitInMem;\r\n _profiles = {};\r\n _currentProfile = RT_PROFILE;\r\n _scheduledTimer = null;\r\n _immediateTimer = null;\r\n _currentBackoffCount = 0;\r\n _timerCount = 0;\r\n _batchQueues = {};\r\n _autoFlushEventsLimit = 0;\r\n _unloadHandlersAdded = false;\r\n // either MaxBatchSize * (1+ Max Connections) or _queueLimit / 6 (where 3 latency Queues [normal, realtime, cost deferred] * 2 [allow half full -- allow for retry])\r\n _autoFlushBatchLimit = 0;\r\n _delayedBatchSendLatency = -1;\r\n _delayedBatchReason = null;\r\n _optimizeObject = true;\r\n _isPageUnloadTriggered = false;\r\n _maxEventSendAttempts = MaxSendAttempts;\r\n _maxUnloadEventSendAttempts = MaxSyncUnloadSendAttempts;\r\n _evtNamespace = null;\r\n _overrideInstrumentationKey = null;\r\n _disableTelemetry = false;\r\n _timeoutWrapper = createTimeoutWrapper();\r\n _httpManager = new HttpManager(MaxNumberEventPerBatch, MaxConnections, MaxRequestRetriesBeforeBackoff, {\r\n requeue: _requeueEvents,\r\n send: _sendingEvent,\r\n sent: _eventsSentEvent,\r\n drop: _eventsDropped,\r\n rspFail: _eventsResponseFail,\r\n oth: _otherEvent\r\n });\r\n _initializeProfiles();\r\n _clearQueues();\r\n _setAutoLimits();\r\n }\r\n function _createTimer(theTimerFunc, timeOut) {\r\n // If the transmission is backed off make the timer at least 1 sec to allow for back off.\r\n if (timeOut === 0 && _currentBackoffCount) {\r\n timeOut = 1;\r\n }\r\n var timerMultiplier = 1000;\r\n if (_currentBackoffCount) {\r\n timerMultiplier = retryPolicyGetMillisToBackoffForRetry(_currentBackoffCount - 1);\r\n }\r\n return _timeoutWrapper.set(theTimerFunc, timeOut * timerMultiplier);\r\n }\r\n function _clearScheduledTimer() {\r\n if (_scheduledTimer !== null) {\r\n _scheduledTimer.cancel();\r\n _scheduledTimer = null;\r\n _timerCount = 0;\r\n return true;\r\n }\r\n return false;\r\n }\r\n // Try to send all queued events using beacons if available\r\n function _releaseAllQueues(sendType, sendReason) {\r\n _clearScheduledTimer();\r\n // Cancel all flush callbacks\r\n if (_flushCallbackTimer) {\r\n _flushCallbackTimer.cancel();\r\n _flushCallbackTimer = null;\r\n }\r\n if (!_paused) {\r\n // Queue all the remaining requests to be sent. The requests will be sent using HTML5 Beacons if they are available.\r\n _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, sendType, sendReason);\r\n }\r\n }\r\n /**\r\n * Add empty queues for all latencies in the inbound queues map. This is called\r\n * when Transmission Manager is being flushed. This ensures that new events added\r\n * after flush are stored separately till we flush the current events.\r\n */\r\n function _clearQueues() {\r\n _batchQueues[4 /* EventLatencyValue.Immediate */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n _batchQueues[3 /* EventLatencyValue.RealTime */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n _batchQueues[2 /* EventLatencyValue.CostDeferred */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n _batchQueues[1 /* EventLatencyValue.Normal */] = {\r\n batches: [],\r\n iKeyMap: {}\r\n };\r\n }\r\n function _getEventBatch(iKey, latency, create) {\r\n var batchQueue = _batchQueues[latency];\r\n if (!batchQueue) {\r\n latency = 1 /* EventLatencyValue.Normal */;\r\n batchQueue = _batchQueues[latency];\r\n }\r\n var eventBatch = batchQueue.iKeyMap[iKey];\r\n if (!eventBatch && create) {\r\n eventBatch = EventBatch.create(iKey);\r\n batchQueue.batches[_DYN_PUSH /* @min:%2epush */](eventBatch);\r\n batchQueue.iKeyMap[iKey] = eventBatch;\r\n }\r\n return eventBatch;\r\n }\r\n function _performAutoFlush(isAsync, doFlush) {\r\n // Only perform the auto flush check if the httpManager has an idle connection and we are not in a backoff situation\r\n if (_httpManager[_DYN_CAN_SEND_REQUEST /* @min:%2ecanSendRequest */]() && !_currentBackoffCount) {\r\n if (_autoFlushEventsLimit > 0 && _queueSize > _autoFlushEventsLimit) {\r\n // Force flushing\r\n doFlush = true;\r\n }\r\n if (doFlush && _flushCallbackTimer == null) {\r\n // Auto flush the queue, adding a callback to avoid the creation of a promise\r\n _self.flush(isAsync, function () { }, 20 /* SendRequestReason.MaxQueuedEvents */);\r\n }\r\n }\r\n }\r\n function _addEventToProperQueue(event, append) {\r\n // v8 performance optimization for iterating over the keys\r\n if (_optimizeObject) {\r\n event = optimizeObject(event);\r\n }\r\n var latency = event[_DYN_LATENCY /* @min:%2elatency */];\r\n var eventBatch = _getEventBatch(event[_DYN_I_KEY /* @min:%2eiKey */], latency, true);\r\n if (eventBatch.addEvent(event)) {\r\n if (latency !== 4 /* EventLatencyValue.Immediate */) {\r\n _queueSize++;\r\n // Check for auto flushing based on total events in the queue, but not for requeued or retry events\r\n if (append && event[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] === 0) {\r\n // Force the flushing of the batch if the batch (specific iKey / latency combination) reaches it's auto flush limit\r\n _performAutoFlush(!event.sync, _autoFlushBatchLimit > 0 && eventBatch[_DYN_COUNT /* @min:%2ecount */]() >= _autoFlushBatchLimit);\r\n }\r\n }\r\n else {\r\n // Direct events don't need auto flushing as they are scheduled (by default) for immediate delivery\r\n _immediateQueueSize++;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n function _dropEventWithLatencyOrLess(iKey, latency, currentLatency, dropNumber) {\r\n while (currentLatency <= latency) {\r\n var eventBatch = _getEventBatch(iKey, latency, true);\r\n if (eventBatch && eventBatch[_DYN_COUNT /* @min:%2ecount */]() > 0) {\r\n // Dropped oldest events from lowest possible latency\r\n var droppedEvents = eventBatch[_DYN_SPLIT /* @min:%2esplit */](0, dropNumber);\r\n var droppedCount = droppedEvents[_DYN_COUNT /* @min:%2ecount */]();\r\n if (droppedCount > 0) {\r\n if (currentLatency === 4 /* EventLatencyValue.Immediate */) {\r\n _immediateQueueSize -= droppedCount;\r\n }\r\n else {\r\n _queueSize -= droppedCount;\r\n }\r\n _notifyBatchEvents(strEventsDiscarded, [droppedEvents], EventsDiscardedReason.QueueFull);\r\n return true;\r\n }\r\n }\r\n currentLatency++;\r\n }\r\n // Unable to drop any events -- lets just make sure the queue counts are correct to avoid exhaustion\r\n _resetQueueCounts();\r\n return false;\r\n }\r\n /**\r\n * Internal helper to reset the queue counts, used as a backstop to avoid future queue exhaustion errors\r\n * that might occur because of counting issues.\r\n */\r\n function _resetQueueCounts() {\r\n var immediateQueue = 0;\r\n var normalQueue = 0;\r\n var _loop_1 = function (latency) {\r\n var batchQueue = _batchQueues[latency];\r\n if (batchQueue && batchQueue[_DYN_BATCHES /* @min:%2ebatches */]) {\r\n arrForEach(batchQueue[_DYN_BATCHES /* @min:%2ebatches */], function (theBatch) {\r\n if (latency === 4 /* EventLatencyValue.Immediate */) {\r\n immediateQueue += theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n else {\r\n normalQueue += theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n });\r\n }\r\n };\r\n for (var latency = 1 /* EventLatencyValue.Normal */; latency <= 4 /* EventLatencyValue.Immediate */; latency++) {\r\n _loop_1(latency);\r\n }\r\n _queueSize = normalQueue;\r\n _immediateQueueSize = immediateQueue;\r\n }\r\n function _queueBatches(latency, sendType, sendReason) {\r\n var eventsQueued = false;\r\n var isAsync = sendType === 0 /* EventSendType.Batched */;\r\n // Only queue batches (to the HttpManager) if this is a sync request or the httpManager has an idle connection\r\n // Thus keeping the events within the PostChannel until the HttpManager has a connection available\r\n // This is so we can drop \"old\" events if the queue is getting full because we can't successfully send events\r\n if (!isAsync || _httpManager[_DYN_CAN_SEND_REQUEST /* @min:%2ecanSendRequest */]()) {\r\n doPerf(_self.core, function () { return \"PostChannel._queueBatches\"; }, function () {\r\n var droppedEvents = [];\r\n var latencyToProcess = 4 /* EventLatencyValue.Immediate */;\r\n while (latencyToProcess >= latency) {\r\n var batchQueue = _batchQueues[latencyToProcess];\r\n if (batchQueue && batchQueue.batches && batchQueue.batches[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n arrForEach(batchQueue[_DYN_BATCHES /* @min:%2ebatches */], function (theBatch) {\r\n // Add the batch to the http manager to send the requests\r\n if (!_httpManager.addBatch(theBatch)) {\r\n // The events from this iKey are being dropped (killed)\r\n droppedEvents = droppedEvents[_DYN_CONCAT /* @min:%2econcat */](theBatch[_DYN_EVENTS /* @min:%2eevents */]());\r\n }\r\n else {\r\n eventsQueued = eventsQueued || (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() > 0);\r\n }\r\n if (latencyToProcess === 4 /* EventLatencyValue.Immediate */) {\r\n _immediateQueueSize -= theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n else {\r\n _queueSize -= theBatch[_DYN_COUNT /* @min:%2ecount */]();\r\n }\r\n });\r\n // Remove all batches from this Queue\r\n batchQueue[_DYN_BATCHES /* @min:%2ebatches */] = [];\r\n batchQueue.iKeyMap = {};\r\n }\r\n latencyToProcess--;\r\n }\r\n if (droppedEvents[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _notifyEvents(strEventsDiscarded, droppedEvents, EventsDiscardedReason.KillSwitch);\r\n }\r\n if (eventsQueued && _delayedBatchSendLatency >= latency) {\r\n // We have queued events at the same level as the delayed values so clear the setting\r\n _delayedBatchSendLatency = -1;\r\n _delayedBatchReason = 0 /* SendRequestReason.Undefined */;\r\n }\r\n }, function () { return ({ latency: latency, sendType: sendType, sendReason: sendReason }); }, !isAsync);\r\n }\r\n else {\r\n // remember the min latency so that we can re-trigger later\r\n _delayedBatchSendLatency = _delayedBatchSendLatency >= 0 ? Math.min(_delayedBatchSendLatency, latency) : latency;\r\n _delayedBatchReason = Math.max(_delayedBatchReason, sendReason);\r\n }\r\n return eventsQueued;\r\n }\r\n /**\r\n * This is the callback method is called as part of the manual flushing process.\r\n * @param callback\r\n * @param sendReason\r\n */\r\n function _flushImpl(callback, sendReason) {\r\n // Add any additional queued events and cause all queued events to be sent asynchronously\r\n _sendEventsForLatencyAndAbove(1 /* EventLatencyValue.Normal */, 0 /* EventSendType.Batched */, sendReason);\r\n // All events (should) have been queue -- lets just make sure the queue counts are correct to avoid queue exhaustion (previous bug #9685112)\r\n _resetQueueCounts();\r\n _waitForIdleManager(function () {\r\n // Only called AFTER the httpManager does not have any outstanding requests\r\n if (callback) {\r\n callback();\r\n }\r\n if (_flushCallbackQueue[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _flushCallbackTimer = _createTimer(function () {\r\n _flushCallbackTimer = null;\r\n _flushImpl(_flushCallbackQueue.shift(), sendReason);\r\n }, 0);\r\n }\r\n else {\r\n // No more flush requests\r\n _flushCallbackTimer = null;\r\n // Restart the normal timer schedule\r\n _scheduleTimer();\r\n }\r\n });\r\n }\r\n function _waitForIdleManager(callback) {\r\n if (_httpManager[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */]()) {\r\n callback();\r\n }\r\n else {\r\n _flushCallbackTimer = _createTimer(function () {\r\n _flushCallbackTimer = null;\r\n _waitForIdleManager(callback);\r\n }, FlushCheckTimer);\r\n }\r\n }\r\n /**\r\n * Resets the transmit profiles to the default profiles of Real Time, Near Real Time\r\n * and Best Effort. This removes all the custom profiles that were loaded.\r\n */\r\n function _resetTransmitProfiles() {\r\n _clearScheduledTimer();\r\n _initializeProfiles();\r\n _currentProfile = RT_PROFILE;\r\n _scheduleTimer();\r\n }\r\n function _initializeProfiles() {\r\n _profiles = {};\r\n _profiles[RT_PROFILE] = [2, 1, 0];\r\n _profiles[NRT_PROFILE] = [6, 3, 0];\r\n _profiles[BE_PROFILE] = [18, 9, 0];\r\n }\r\n /**\r\n * The notification handler for requeue events\r\n * @ignore\r\n */\r\n function _requeueEvents(batches, reason) {\r\n var droppedEvents = [];\r\n var maxSendAttempts = _maxEventSendAttempts;\r\n if (_isPageUnloadTriggered) {\r\n // If a page unlaod has been triggered reduce the number of times we try to \"retry\"\r\n maxSendAttempts = _maxUnloadEventSendAttempts;\r\n }\r\n arrForEach(batches, function (theBatch) {\r\n if (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() > 0) {\r\n arrForEach(theBatch[_DYN_EVENTS /* @min:%2eevents */](), function (theEvent) {\r\n if (theEvent) {\r\n // Check if the request being added back is for a sync event in which case mark it no longer a sync event\r\n if (theEvent[_DYN_SYNC /* @min:%2esync */]) {\r\n theEvent[_DYN_LATENCY /* @min:%2elatency */] = 4 /* EventLatencyValue.Immediate */;\r\n theEvent[_DYN_SYNC /* @min:%2esync */] = false;\r\n }\r\n if (theEvent[_DYN_SEND_ATTEMPT /* @min:%2esendAttempt */] < maxSendAttempts) {\r\n // Reset the event timings\r\n setProcessTelemetryTimings(theEvent, _self[_DYN_IDENTIFIER /* @min:%2eidentifier */]);\r\n _addEventToQueues(theEvent, false);\r\n }\r\n else {\r\n droppedEvents[_DYN_PUSH /* @min:%2epush */](theEvent);\r\n }\r\n }\r\n });\r\n }\r\n });\r\n if (droppedEvents[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _notifyEvents(strEventsDiscarded, droppedEvents, EventsDiscardedReason.NonRetryableStatus);\r\n }\r\n if (_isPageUnloadTriggered) {\r\n // Unload event has been received so we need to try and flush new events\r\n _releaseAllQueues(2 /* EventSendType.SendBeacon */, 2 /* SendRequestReason.Unload */);\r\n }\r\n }\r\n function _callNotification(evtName, theArgs) {\r\n var manager = (_notificationManager || {});\r\n var notifyFunc = manager[evtName];\r\n if (notifyFunc) {\r\n try {\r\n notifyFunc.apply(manager, theArgs);\r\n }\r\n catch (e) {\r\n _throwInternal(_self.diagLog(), 1 /* eLoggingSeverity.CRITICAL */, 74 /* _eInternalMessageId.NotificationException */, evtName + \" notification failed: \" + e);\r\n }\r\n }\r\n }\r\n function _notifyEvents(evtName, theEvents) {\r\n var extraArgs = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n extraArgs[_i - 2] = arguments[_i];\r\n }\r\n if (theEvents && theEvents[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _callNotification(evtName, [theEvents][_DYN_CONCAT /* @min:%2econcat */](extraArgs));\r\n }\r\n }\r\n function _notifyBatchEvents(evtName, batches) {\r\n var extraArgs = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n extraArgs[_i - 2] = arguments[_i];\r\n }\r\n if (batches && batches[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n arrForEach(batches, function (theBatch) {\r\n if (theBatch && theBatch[_DYN_COUNT /* @min:%2ecount */]() > 0) {\r\n _callNotification(evtName, [theBatch.events()][_DYN_CONCAT /* @min:%2econcat */](extraArgs));\r\n }\r\n });\r\n }\r\n }\r\n /**\r\n * The notification handler for when batches are about to be sent\r\n * @ignore\r\n */\r\n function _sendingEvent(batches, reason, isSyncRequest) {\r\n if (batches && batches[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n _callNotification(\"eventsSendRequest\", [(reason >= 1000 /* EventBatchNotificationReason.SendingUndefined */ && reason <= 1999 /* EventBatchNotificationReason.SendingEventMax */ ?\r\n reason - 1000 /* EventBatchNotificationReason.SendingUndefined */ :\r\n 0 /* SendRequestReason.Undefined */), isSyncRequest !== true]);\r\n }\r\n }\r\n /**\r\n * This event represents that a batch of events have been successfully sent and a response received\r\n * @param batches The notification handler for when the batches have been successfully sent\r\n * @param reason For this event the reason will always be EventBatchNotificationReason.Complete\r\n */\r\n function _eventsSentEvent(batches, reason) {\r\n _notifyBatchEvents(\"eventsSent\", batches, reason);\r\n // Try and schedule the processing timer if we have events\r\n _scheduleTimer();\r\n }\r\n function _eventsDropped(batches, reason) {\r\n _notifyBatchEvents(strEventsDiscarded, batches, (reason >= 8000 /* EventBatchNotificationReason.EventsDropped */ && reason <= 8999 /* EventBatchNotificationReason.EventsDroppedMax */ ?\r\n reason - 8000 /* EventBatchNotificationReason.EventsDropped */ :\r\n EventsDiscardedReason.Unknown));\r\n }\r\n function _eventsResponseFail(batches) {\r\n _notifyBatchEvents(strEventsDiscarded, batches, EventsDiscardedReason.NonRetryableStatus);\r\n // Try and schedule the processing timer if we have events\r\n _scheduleTimer();\r\n }\r\n function _otherEvent(batches, reason) {\r\n _notifyBatchEvents(strEventsDiscarded, batches, EventsDiscardedReason.Unknown);\r\n // Try and schedule the processing timer if we have events\r\n _scheduleTimer();\r\n }\r\n function _setAutoLimits() {\r\n if (!_disableAutoBatchFlushLimit) {\r\n _autoFlushBatchLimit = Math.max(MaxNumberEventPerBatch * (MaxConnections + 1), _queueSizeLimit / 6);\r\n }\r\n else {\r\n _autoFlushBatchLimit = 0;\r\n }\r\n }\r\n });\r\n return _this;\r\n }\r\n /**\r\n * Start the queue manager to batch and send events via post.\r\n * @param config - The core configuration.\r\n */\r\n PostChannel.prototype.initialize = function (coreConfig, core, extensions) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add an event to the appropriate inbound queue based on its latency.\r\n * @param ev - The event to be added to the queue.\r\n * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances\r\n * can optionally use this to access the current core instance or define / pass additional information\r\n * to later plugins (vs appending items to the telemetry item)\r\n */\r\n PostChannel.prototype.processTelemetry = function (ev, itemCtx) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Sets the event queue limits at runtime (after initialization), if the number of queued events is greater than the\r\n * eventLimit or autoFlushLimit then a flush() operation will be scheduled.\r\n * @param eventLimit The number of events that can be kept in memory before the SDK starts to drop events. If the value passed is less than or\r\n * equal to zero the value will be reset to the default (10,000).\r\n * @param autoFlushLimit When defined, once this number of events has been queued the system perform a flush() to send the queued events\r\n * without waiting for the normal schedule timers. Passing undefined, null or a value less than or equal to zero will disable the auto flush.\r\n */\r\n PostChannel.prototype.setEventQueueLimits = function (eventLimit, autoFlushLimit) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Pause the transmission of any requests\r\n */\r\n PostChannel.prototype.pause = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Resumes transmission of events.\r\n */\r\n PostChannel.prototype.resume = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Add handler to be executed with request response text.\r\n */\r\n PostChannel.prototype.addResponseHandler = function (responseHanlder) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously (the default) and\r\n * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)\r\n * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`\r\n * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)\r\n * @param async - send data asynchronously when true\r\n * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.\r\n * If the caller doesn't return true the caller should assume that it may never be called.\r\n * @param sendReason - specify the reason that you are calling \"flush\" defaults to ManualFlush (1) if not specified\r\n * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller\r\n * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a\r\n * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,\r\n * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided\r\n * and async is true.\r\n */\r\n PostChannel.prototype.flush = function (async, callBack, sendReason) {\r\n if (async === void 0) { async = true; }\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Set AuthMsaDeviceTicket header\r\n * @param ticket - Ticket value.\r\n */\r\n PostChannel.prototype.setMsaAuthTicket = function (ticket) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Check if there are any events waiting to be scheduled for sending.\r\n * @returns True if there are events, false otherwise.\r\n */\r\n PostChannel.prototype.hasEvents = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Load custom transmission profiles. Each profile should have timers for real time, and normal and can\r\n * optionally specify the immediate latency time in ms (defaults to 0 when not defined). Each profile should\r\n * make sure that a each normal latency timer is a multiple of the real-time latency and the immediate\r\n * is smaller than the real-time.\r\n * Setting the timer value to -1 means that the events for that latency will not be scheduled to be sent.\r\n * Note that once a latency has been set to not send, all latencies below it will also not be sent. The\r\n * timers should be in the form of [normal, high, [immediate]].\r\n * e.g Custom:\r\n * [10,5] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms\r\n * [10,5,1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 1ms\r\n * [10,5,0] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms\r\n * [10,5,-1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate events will not be\r\n * scheduled on their own and but they will be included with real-time or normal events as the first events in a batch.\r\n * This also removes any previously loaded custom profiles.\r\n * @param profiles - A dictionary containing the transmit profiles.\r\n */\r\n PostChannel.prototype._loadTransmitProfiles = function (profiles) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Set the transmit profile to be used. This will change the transmission timers\r\n * based on the transmit profile.\r\n * @param profileName - The name of the transmit profile to be used.\r\n */\r\n PostChannel.prototype._setTransmitProfile = function (profileName) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Backs off transmission. This exponentially increases all the timers.\r\n */\r\n PostChannel.prototype._backOffTransmission = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Clears backoff for transmission.\r\n */\r\n PostChannel.prototype._clearBackOff = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Get Offline support\r\n * @returns internal Offline support interface IInternalOfflineSupport\r\n */\r\n PostChannel.prototype.getOfflineSupport = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n return PostChannel;\r\n}(BaseTelemetryPlugin));\r\nexport { PostChannel };\r\n//# sourceMappingURL=PostChannel.js.map"],"names":[],"mappings":";;;;;AAAA,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;4DAgIM,CAAC;;;;;uBACgB;AACvB;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * 1DS JS SDK POST plugin, 4.1.0-nightly3.2401-23
2
+ * 1DS JS SDK POST plugin, 4.1.0-nightly3.2402-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * 1DS JS SDK POST plugin, 4.1.0-nightly3.2401-23
2
+ * 1DS JS SDK POST plugin, 4.1.0-nightly3.2402-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*
2
- * 1DS JS SDK POST plugin, 4.1.0-nightly3.2401-23
2
+ * 1DS JS SDK POST plugin, 4.1.0-nightly3.2402-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  * (Microsoft Internal Only)
5
5
  */