@microsoft/1ds-post-js 3.2.1 → 3.2.4

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 (69) hide show
  1. package/README.md +1 -1
  2. package/bundle/{ms.post-3.2.1.gbl.js → ms.post-3.2.4.gbl.js} +1071 -966
  3. package/bundle/ms.post-3.2.4.gbl.js.map +1 -0
  4. package/bundle/ms.post-3.2.4.gbl.min.js +7 -0
  5. package/bundle/ms.post-3.2.4.gbl.min.js.map +1 -0
  6. package/bundle/ms.post-3.2.4.integrity.json +46 -0
  7. package/bundle/{ms.post-3.2.1.js → ms.post-3.2.4.js} +1071 -966
  8. package/bundle/ms.post-3.2.4.js.map +1 -0
  9. package/bundle/ms.post-3.2.4.min.js +7 -0
  10. package/bundle/ms.post-3.2.4.min.js.map +1 -0
  11. package/bundle/ms.post.gbl.js +1070 -965
  12. package/bundle/ms.post.gbl.js.map +1 -1
  13. package/bundle/ms.post.gbl.min.js +2 -2
  14. package/bundle/ms.post.gbl.min.js.map +1 -1
  15. package/bundle/ms.post.integrity.json +17 -17
  16. package/bundle/ms.post.js +1070 -965
  17. package/bundle/ms.post.js.map +1 -1
  18. package/bundle/ms.post.min.js +2 -2
  19. package/bundle/ms.post.min.js.map +1 -1
  20. package/dist/ms.post.js +251 -212
  21. package/dist/ms.post.js.map +1 -1
  22. package/dist/ms.post.min.js +2 -2
  23. package/dist/ms.post.min.js.map +1 -1
  24. package/dist-esm/src/BatchNotificationActions.js +1 -1
  25. package/dist-esm/src/ClockSkewManager.js +6 -1
  26. package/dist-esm/src/ClockSkewManager.js.map +1 -1
  27. package/dist-esm/src/DataModels.js +1 -1
  28. package/dist-esm/src/EventBatch.d.ts +0 -5
  29. package/dist-esm/src/EventBatch.js +9 -4
  30. package/dist-esm/src/EventBatch.js.map +1 -1
  31. package/dist-esm/src/HttpManager.d.ts +4 -8
  32. package/dist-esm/src/HttpManager.js +120 -112
  33. package/dist-esm/src/HttpManager.js.map +1 -1
  34. package/dist-esm/src/Index.js +1 -1
  35. package/dist-esm/src/InternalConstants.d.ts +27 -0
  36. package/dist-esm/src/InternalConstants.js +40 -0
  37. package/dist-esm/src/InternalConstants.js.map +1 -0
  38. package/dist-esm/src/KillSwitch.js +7 -2
  39. package/dist-esm/src/KillSwitch.js.map +1 -1
  40. package/dist-esm/src/PostChannel.d.ts +3 -6
  41. package/dist-esm/src/PostChannel.js +97 -73
  42. package/dist-esm/src/PostChannel.js.map +1 -1
  43. package/dist-esm/src/RetryPolicy.js +1 -1
  44. package/dist-esm/src/Serializer.d.ts +1 -1
  45. package/dist-esm/src/Serializer.js +9 -3
  46. package/dist-esm/src/Serializer.js.map +1 -1
  47. package/dist-esm/src/TimeoutOverrideWrapper.d.ts +18 -0
  48. package/dist-esm/src/TimeoutOverrideWrapper.js +28 -0
  49. package/dist-esm/src/TimeoutOverrideWrapper.js.map +1 -0
  50. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  51. package/package.json +5 -3
  52. package/src/EventBatch.ts +4 -4
  53. package/src/HttpManager.ts +74 -71
  54. package/src/InternalConstants.ts +41 -0
  55. package/src/KillSwitch.ts +1 -1
  56. package/src/PostChannel.ts +72 -44
  57. package/src/Serializer.ts +7 -5
  58. package/src/TimeoutOverrideWrapper.ts +29 -0
  59. package/bundle/ms.post-3.2.1.gbl.js.map +0 -1
  60. package/bundle/ms.post-3.2.1.gbl.min.js +0 -7
  61. package/bundle/ms.post-3.2.1.gbl.min.js.map +0 -1
  62. package/bundle/ms.post-3.2.1.integrity.json +0 -46
  63. package/bundle/ms.post-3.2.1.js.map +0 -1
  64. package/bundle/ms.post-3.2.1.min.js +0 -7
  65. package/bundle/ms.post-3.2.1.min.js.map +0 -1
  66. package/dist-esm/src/Constants.d.ts +0 -25
  67. package/dist-esm/src/Constants.js +0 -31
  68. package/dist-esm/src/Constants.js.map +0 -1
  69. package/src/Constants.ts +0 -28
@@ -3,37 +3,37 @@
3
3
  * @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)
4
4
  * @copyright Microsoft 2018-2020
5
5
  */
6
+ import dynamicProto from "@microsoft/dynamicproto-js";
7
+ import EVTClockSkewManager from "./ClockSkewManager";
8
+ import EVTKillSwitch from "./KillSwitch";
6
9
  import {
7
- isReactNative, isValueAssigned, isString, getTime, arrForEach, getLocation, strTrim, isFetchSupported, isXhrSupported,
8
- isBeaconsSupported, FullVersionString, useXDomainRequest, IExtendedAppInsightsCore, IExtendedConfiguration,
9
- eLoggingSeverity, _eExtendedInternalMessageId, SendRequestReason, strUndefined, getNavigator, doPerf, IPerfEvent,
10
- dateNow, isUndefined, isNullOrUndefined, objForEachKey, ICookieMgr, isNumber, isArray, TransportType, dumpObj, objKeys, extend,
11
- EventSendType, hasOwnProperty, openXhr, _throwInternal, _eInternalMessageId
10
+ EventSendType, FullVersionString, ICookieMgr, IDiagnosticLogger, IExtendedAppInsightsCore, IExtendedConfiguration, IPerfEvent,
11
+ SendRequestReason, TransportType, _eExtendedInternalMessageId, _eInternalMessageId, _throwInternal, _warnToConsole, arrForEach, dateNow,
12
+ doPerf, dumpObj, eLoggingSeverity, extend, getLocation, getNavigator, getTime, hasOwnProperty, isArray, isBeaconsSupported,
13
+ isFetchSupported, isNullOrUndefined, isNumber, isReactNative, isString, isUndefined, isValueAssigned, isXhrSupported, objForEachKey,
14
+ objKeys, openXhr, strTrim, strUndefined, useXDomainRequest
12
15
  } from "@microsoft/1ds-core-js";
16
+ import { BatchNotificationAction, BatchNotificationActions } from "./BatchNotificationActions";
13
17
  import {
14
- IXHROverride, IPostTransmissionTelemetryItem, ICollectorResult,
15
- IPostChannel, PayloadPreprocessorFunction, PayloadListenerFunction, IPayloadData,
16
- SendPOSTFunction, EventBatchNotificationReason,
18
+ EventBatchNotificationReason, ICollectorResult, IPayloadData, IPostChannel, IPostTransmissionTelemetryItem, IXHROverride,
19
+ PayloadListenerFunction, PayloadPreprocessorFunction, SendPOSTFunction
17
20
  } from "./DataModels";
18
- import { BatchNotificationAction, BatchNotificationActions } from "./BatchNotificationActions";
19
21
  import { EventBatch } from "./EventBatch";
20
- import { Serializer, ISerializedPayload } from "./Serializer";
21
- import { retryPolicyGetMillisToBackoffForRetry, retryPolicyShouldRetryForStatus } from "./RetryPolicy";
22
- import EVTKillSwitch from "./KillSwitch";
23
- import EVTClockSkewManager from "./ClockSkewManager";
24
- import dynamicProto from "@microsoft/dynamicproto-js";
25
22
  import { IChannelConfiguration } from "./Index";
23
+ import {
24
+ DEFAULT_CACHE_CONTROL, DEFAULT_CONTENT_TYPE, STR_API_KEY, STR_AUTH_XTOKEN, STR_CACHE_CONTROL, STR_CLIENT_ID, STR_CLIENT_VERSION,
25
+ STR_CONTENT_TYPE_HEADER, STR_DISABLED_PROPERTY_NAME, STR_DROPPED, STR_KILL_DURATION_HEADER, STR_KILL_DURATION_SECONDS_HEADER,
26
+ STR_KILL_TOKENS_HEADER, STR_MSA_DEVICE_TICKET, STR_MSFPC, STR_NO_RESPONSE_BODY, STR_OTHER, STR_POST_METHOD, STR_REQUEUE,
27
+ STR_RESPONSE_FAIL, STR_SENDING, STR_TIME_DELTA_HEADER, STR_TIME_DELTA_TO_APPLY, STR_UPLOAD_TIME
28
+ } from "./InternalConstants";
29
+ import { retryPolicyGetMillisToBackoffForRetry, retryPolicyShouldRetryForStatus } from "./RetryPolicy";
30
+ import { ISerializedPayload, Serializer } from "./Serializer";
31
+ import { ITimeoutOverrideWrapper } from "./TimeoutOverrideWrapper";
26
32
  import { XDomainRequest as IXDomainRequest } from "./typings/XDomainRequest";
27
- import {
28
- defaultCacheControl, defaultContentType, DisabledPropertyName, Method, strApiKey, strAuthXToken, strCacheControl,
29
- strClientId, strClientVersion, strContentTypeHeader, strDropped, strKillDurationHeader, strKillDurationSecondsHeader,
30
- strKillTokensHeader, strMsaDeviceTicket, strMsfpc, strNoResponseBody, strOther, strRequeue, strResponseFail, strSending, strTimeDeltaHeader,
31
- strTimeDeltaToApply, strUploadTime
32
- } from "./Constants";
33
33
 
34
34
  const strSendAttempt = "sendAttempt";
35
35
 
36
- const _noResponseQs = "&" + strNoResponseBody + "=true";
36
+ const _noResponseQs = "&" + STR_NO_RESPONSE_BODY + "=true";
37
37
 
38
38
  // TypeScript removed this interface so we need to declare the global so we can check for it's existence.
39
39
  declare var XDomainRequest: {
@@ -51,11 +51,11 @@ interface IRequestUrlDetails {
51
51
  * Identifies the default notification reason to the action names
52
52
  */
53
53
  const _eventActionMap: any = {
54
- [EventBatchNotificationReason.Paused]: strRequeue,
55
- [EventBatchNotificationReason.RequeueEvents]: strRequeue,
54
+ [EventBatchNotificationReason.Paused]: STR_REQUEUE,
55
+ [EventBatchNotificationReason.RequeueEvents]: STR_REQUEUE,
56
56
  [EventBatchNotificationReason.Complete]: "sent",
57
- [EventBatchNotificationReason.KillSwitch]: strDropped,
58
- [EventBatchNotificationReason.SizeLimitExceeded]: strDropped
57
+ [EventBatchNotificationReason.KillSwitch]: STR_DROPPED,
58
+ [EventBatchNotificationReason.SizeLimitExceeded]: STR_DROPPED
59
59
  };
60
60
 
61
61
  const _collectorQsHeaders = { };
@@ -68,13 +68,13 @@ function _addCollectorHeaderQsMapping(qsName: string, headerName: string, allowQ
68
68
  }
69
69
  }
70
70
 
71
- _addCollectorHeaderQsMapping(strMsaDeviceTicket, strMsaDeviceTicket, false);
72
- _addCollectorHeaderQsMapping(strClientVersion, strClientVersion);
73
- _addCollectorHeaderQsMapping(strClientId, "Client-Id");
74
- _addCollectorHeaderQsMapping(strApiKey, strApiKey);
75
- _addCollectorHeaderQsMapping(strTimeDeltaToApply, strTimeDeltaToApply);
76
- _addCollectorHeaderQsMapping(strUploadTime, strUploadTime);
77
- _addCollectorHeaderQsMapping(strAuthXToken, strAuthXToken);
71
+ _addCollectorHeaderQsMapping(STR_MSA_DEVICE_TICKET, STR_MSA_DEVICE_TICKET, false);
72
+ _addCollectorHeaderQsMapping(STR_CLIENT_VERSION, STR_CLIENT_VERSION);
73
+ _addCollectorHeaderQsMapping(STR_CLIENT_ID, "Client-Id");
74
+ _addCollectorHeaderQsMapping(STR_API_KEY, STR_API_KEY);
75
+ _addCollectorHeaderQsMapping(STR_TIME_DELTA_TO_APPLY, STR_TIME_DELTA_TO_APPLY);
76
+ _addCollectorHeaderQsMapping(STR_UPLOAD_TIME, STR_UPLOAD_TIME);
77
+ _addCollectorHeaderQsMapping(STR_AUTH_XTOKEN, STR_AUTH_XTOKEN);
78
78
 
79
79
  type OnCompleteCallback = (status: number, headers: { [headerName: string]: string }, response?: string) => void;
80
80
 
@@ -141,14 +141,15 @@ export class HttpManager {
141
141
  * @constructor
142
142
  * @param requestQueue - The queue that contains the requests to be sent.
143
143
  */
144
- constructor(maxEventsPerBatch: number, maxConnections: number, maxRequestRetriesBeforeBackoff: number, actions: BatchNotificationActions) {
145
- let _urlString: string = "?cors=true&" + strContentTypeHeader.toLowerCase() + "=" + defaultContentType;
144
+ constructor(maxEventsPerBatch: number, maxConnections: number, maxRequestRetriesBeforeBackoff: number, actions: BatchNotificationActions, timeoutOverride: ITimeoutOverrideWrapper) {
145
+ let _urlString: string = "?cors=true&" + STR_CONTENT_TYPE_HEADER.toLowerCase() + "=" + DEFAULT_CONTENT_TYPE;
146
146
  let _killSwitch: EVTKillSwitch = new EVTKillSwitch();
147
147
  let _paused = false;
148
148
  let _clockSkewManager = new EVTClockSkewManager();
149
149
  let _useBeacons = false;
150
150
  let _outstandingRequests = 0; // Holds the number of outstanding async requests that have not returned a response yet
151
151
  let _postManager: IPostChannel;
152
+ let _logger: IDiagnosticLogger;
152
153
  let _sendInterfaces: { [key: number]: IInternalXhrOverride };
153
154
  let _core: IExtendedAppInsightsCore;
154
155
  let _customHttpInterface = true;
@@ -185,6 +186,7 @@ export class HttpManager {
185
186
  _enableEventTimings = !(_core.config as IExtendedConfiguration).disableEventTimings;
186
187
  let enableCompoundKey = !!(_core.config as IExtendedConfiguration).enableCompoundKey;
187
188
  _postManager = postChannel;
189
+ _logger = _postManager.diagLog();
188
190
  let valueSanitizer = channelConfig.valueSanitizer;
189
191
  let stringifyObjects = channelConfig.stringifyObjects;
190
192
  if (!isUndefined(channelConfig.enableCompoundKey)) {
@@ -232,7 +234,7 @@ export class HttpManager {
232
234
  httpInterface = _getSenderInterface(theTransports, false);
233
235
  syncHttpInterface = _getSenderInterface(theTransports, true);
234
236
  if (!httpInterface) {
235
- _postManager.diagLog().warnToConsole("No available transport to send events");
237
+ _warnToConsole(_logger, "No available transport to send events");
236
238
  }
237
239
  }
238
240
 
@@ -284,7 +286,7 @@ export class HttpManager {
284
286
  function _xdrSendPost(payload: IPayloadData, oncomplete: OnCompleteCallback, sync?: boolean) {
285
287
  // It doesn't support custom headers, so no action is taken with current requestHeaders
286
288
  let xdr = new XDomainRequest();
287
- xdr.open(Method, payload.urlString);
289
+ xdr.open(STR_POST_METHOD, payload.urlString);
288
290
  if (payload.timeout) {
289
291
  xdr.timeout = payload.timeout;
290
292
  }
@@ -313,7 +315,7 @@ export class HttpManager {
313
315
  if (sync) {
314
316
  xdr.send(payload.data);
315
317
  } else {
316
- _postManager._setTimeoutOverride(() => {
318
+ timeoutOverride.set(() => {
317
319
  xdr.send(payload.data);
318
320
  }, 0);
319
321
  }
@@ -325,8 +327,8 @@ export class HttpManager {
325
327
  let responseHandled = false;
326
328
  let requestInit: RequestInit = {
327
329
  body: payload.data,
328
- method: Method,
329
- [DisabledPropertyName]: true
330
+ method: STR_POST_METHOD,
331
+ [STR_DISABLED_PROPERTY_NAME]: true
330
332
  };
331
333
 
332
334
  if (sync) {
@@ -352,8 +354,9 @@ export class HttpManager {
352
354
  fetch(theUrl, requestInit).then((response) => {
353
355
  let headerMap = {};
354
356
  let responseText = "";
355
- if (response.headers) {
356
- response.headers.forEach((value: string, name: string) => {
357
+ var headers = response.headers;
358
+ if (headers) {
359
+ headers["forEach"]((value: string, name: string) => {
357
360
  headerMap[name] = value;
358
361
  });
359
362
  }
@@ -385,7 +388,7 @@ export class HttpManager {
385
388
 
386
389
  if (!responseHandled && payload.timeout > 0) {
387
390
  // Simulate timeout
388
- _postManager._setTimeoutOverride(() => {
391
+ timeoutOverride.set(() => {
389
392
  if (!responseHandled) {
390
393
  // Assume a 500 response (which will cause a retry)
391
394
  responseHandled = true;
@@ -416,9 +419,9 @@ export class HttpManager {
416
419
  // Firefox 2-63 doesn't have getAllResponseHeaders function but it does have getResponseHeader
417
420
  // Only call these if getAllResponseHeaders doesn't exist, otherwise we can get invalid response errors
418
421
  // as collector is not currently returning the correct header to allow JS to access these headers
419
- theHeaders = _appendHeader(theHeaders, xhr, strTimeDeltaHeader);
420
- theHeaders = _appendHeader(theHeaders, xhr, strKillDurationHeader);
421
- theHeaders = _appendHeader(theHeaders, xhr, strKillDurationSecondsHeader);
422
+ theHeaders = _appendHeader(theHeaders, xhr, STR_TIME_DELTA_HEADER);
423
+ theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_HEADER);
424
+ theHeaders = _appendHeader(theHeaders, xhr, STR_KILL_DURATION_SECONDS_HEADER);
422
425
  } else {
423
426
  theHeaders = _convertAllHeadersToMap(xhr.getAllResponseHeaders());
424
427
  }
@@ -433,7 +436,7 @@ export class HttpManager {
433
436
  sync = false;
434
437
  }
435
438
 
436
- let xhrRequest = openXhr(Method, theUrl, _sendCredentials, true, sync, payload.timeout);
439
+ let xhrRequest = openXhr(STR_POST_METHOD, theUrl, _sendCredentials, true, sync, payload.timeout);
437
440
 
438
441
  // Set custom headers (e.g. gzip) here (after open())
439
442
  objForEachKey(payload.headers, (name, value) => {
@@ -457,7 +460,7 @@ export class HttpManager {
457
460
  try {
458
461
  oncomplete(status, headers, response);
459
462
  } catch (e) {
460
- _throwInternal(_postManager.diagLog(),
463
+ _throwInternal(_logger,
461
464
  eLoggingSeverity.WARNING,
462
465
  _eExtendedInternalMessageId.SendPostOnCompleteFailure, dumpObj(e));
463
466
  }
@@ -499,7 +502,7 @@ export class HttpManager {
499
502
  }
500
503
 
501
504
  } catch (ex) {
502
- _postManager.diagLog().warnToConsole("Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(ex));
505
+ _warnToConsole(_logger, "Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(ex));
503
506
  status = 0;
504
507
  } finally {
505
508
  _doOnComplete(oncomplete, status, {}, "");
@@ -737,7 +740,7 @@ export class HttpManager {
737
740
  _sendBatchesNotification(droppedBatches, EventBatchNotificationReason.KillSwitch, sendType);
738
741
  }, () => ({ batches: _createDebugBatches(orgBatches), retryCount, isTeardown, isSynchronous, sendReason, useSendBeacon: _isBeaconPayload(sendType), sendType }), !isSynchronous);
739
742
  } catch (ex) {
740
- _throwInternal(_postManager.diagLog(),
743
+ _throwInternal(_logger,
741
744
  eLoggingSeverity.WARNING,
742
745
  _eInternalMessageId.CannotSerializeObject, "Unexpected Exception sending batch: " + dumpObj(ex));
743
746
  }
@@ -767,8 +770,8 @@ export class HttpManager {
767
770
  requestDetails.useHdrs = (objKeys(requestDetails.hdrs).length > 0);
768
771
  }
769
772
 
770
- _addRequestDetails(requestDetails, strClientId, "NO_AUTH", useHeaders);
771
- _addRequestDetails(requestDetails, strClientVersion, FullVersionString, useHeaders);
773
+ _addRequestDetails(requestDetails, STR_CLIENT_ID, "NO_AUTH", useHeaders);
774
+ _addRequestDetails(requestDetails, STR_CLIENT_VERSION, FullVersionString, useHeaders);
772
775
 
773
776
  let apiQsKeys = "";
774
777
  arrForEach(thePayload.apiKeys, (apiKey) => {
@@ -779,8 +782,8 @@ export class HttpManager {
779
782
  apiQsKeys += apiKey;
780
783
  });
781
784
 
782
- _addRequestDetails(requestDetails, strApiKey, apiQsKeys, useHeaders);
783
- _addRequestDetails(requestDetails, strUploadTime, dateNow().toString(), useHeaders);
785
+ _addRequestDetails(requestDetails, STR_API_KEY, apiQsKeys, useHeaders);
786
+ _addRequestDetails(requestDetails, STR_UPLOAD_TIME, dateNow().toString(), useHeaders);
784
787
 
785
788
  let msfpc = _getMsfpc(thePayload);
786
789
  if (isValueAssigned(msfpc)) {
@@ -788,7 +791,7 @@ export class HttpManager {
788
791
  }
789
792
 
790
793
  if (_clockSkewManager.shouldAddClockSkewHeaders()) {
791
- _addRequestDetails(requestDetails, strTimeDeltaToApply, _clockSkewManager.getClockSkewHeaderValue(), useHeaders);
794
+ _addRequestDetails(requestDetails, STR_TIME_DELTA_TO_APPLY, _clockSkewManager.getClockSkewHeaderValue(), useHeaders);
792
795
  }
793
796
 
794
797
  if (_core.getWParam) {
@@ -880,12 +883,12 @@ export class HttpManager {
880
883
 
881
884
  // Only automatically add the following headers if already sending headers and we are not attempting to avoid an options call
882
885
  if (useHeaders) {
883
- if (!_hasHeader(orgPayloadData.headers, strCacheControl)) {
884
- orgPayloadData.headers[strCacheControl] = defaultCacheControl;
886
+ if (!_hasHeader(orgPayloadData.headers, STR_CACHE_CONTROL)) {
887
+ orgPayloadData.headers[STR_CACHE_CONTROL] = DEFAULT_CACHE_CONTROL;
885
888
  }
886
889
 
887
- if (!_hasHeader(orgPayloadData.headers, strContentTypeHeader)) {
888
- orgPayloadData.headers[strContentTypeHeader] = defaultContentType;
890
+ if (!_hasHeader(orgPayloadData.headers, STR_CONTENT_TYPE_HEADER)) {
891
+ orgPayloadData.headers[STR_CONTENT_TYPE_HEADER] = DEFAULT_CONTENT_TYPE;
889
892
  }
890
893
  }
891
894
 
@@ -909,7 +912,7 @@ export class HttpManager {
909
912
  _self.sendListener(orgPayloadData, payload, isSync, thePayload.isBeacon);
910
913
  }
911
914
  } catch (ex) {
912
- _postManager.diagLog().warnToConsole("Unexpected exception sending payload. Ex:" + dumpObj(ex));
915
+ _warnToConsole(_logger, "Unexpected exception sending payload. Ex:" + dumpObj(ex));
913
916
 
914
917
  _doOnComplete(onComplete, 0, {});
915
918
  }
@@ -1001,9 +1004,9 @@ export class HttpManager {
1001
1004
 
1002
1005
  if (typeof status !== strUndefined) {
1003
1006
  if (headers) {
1004
- _clockSkewManager.setClockSkew(headers[strTimeDeltaHeader]);
1005
- let killDuration = headers[strKillDurationHeader] || headers["kill-duration-seconds"];
1006
- arrForEach(_killSwitch.setKillSwitchTenants(headers[strKillTokensHeader], killDuration), (killToken) => {
1007
+ _clockSkewManager.setClockSkew(headers[STR_TIME_DELTA_HEADER]);
1008
+ let killDuration = headers[STR_KILL_DURATION_HEADER] || headers["kill-duration-seconds"];
1009
+ arrForEach(_killSwitch.setKillSwitchTenants(headers[STR_KILL_TOKENS_HEADER], killDuration), (killToken) => {
1007
1010
  arrForEach(thePayload.batches, (theBatch) => {
1008
1011
  if (theBatch.iKey() === killToken) {
1009
1012
  // Make sure we have initialized the array
@@ -1135,7 +1138,7 @@ export class HttpManager {
1135
1138
  if (isSync) {
1136
1139
  cb();
1137
1140
  } else {
1138
- _postManager._setTimeoutOverride(cb, interval);
1141
+ timeoutOverride.set(cb, interval);
1139
1142
  }
1140
1143
  }
1141
1144
 
@@ -1183,7 +1186,7 @@ export class HttpManager {
1183
1186
  try {
1184
1187
  responseHandlers[i](responseText);
1185
1188
  } catch (e) {
1186
- _throwInternal(_postManager.diagLog(),
1189
+ _throwInternal(_logger,
1187
1190
  eLoggingSeverity.CRITICAL,
1188
1191
  _eExtendedInternalMessageId.PostResponseHandler,
1189
1192
  "Response handler failed: " + e);
@@ -1191,9 +1194,9 @@ export class HttpManager {
1191
1194
  }
1192
1195
  if (responseText) {
1193
1196
  let response = JSON.parse(responseText) as ICollectorResult;
1194
- if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[strMsfpc])) {
1197
+ if (isValueAssigned(response.webResult) && isValueAssigned(response.webResult[STR_MSFPC])) {
1195
1198
  // Set cookie
1196
- _cookieMgr.set("MSFPC", response.webResult[strMsfpc], 365 * 86400);
1199
+ _cookieMgr.set("MSFPC", response.webResult[STR_MSFPC], 365 * 86400);
1197
1200
  }
1198
1201
  }
1199
1202
  } catch (ex) {
@@ -1212,7 +1215,7 @@ export class HttpManager {
1212
1215
  try {
1213
1216
  theAction.call(actions, theBatches, batchReason, isSyncRequest, sendType);
1214
1217
  } catch (e) {
1215
- _throwInternal(_postManager.diagLog(),
1218
+ _throwInternal(_logger,
1216
1219
  eLoggingSeverity.CRITICAL,
1217
1220
  _eInternalMessageId.NotificationException,
1218
1221
  "send request notification failed: " + e);
@@ -1226,13 +1229,13 @@ export class HttpManager {
1226
1229
  function _getNotificationAction(reason: EventBatchNotificationReason): string {
1227
1230
  let action = _eventActionMap[reason];
1228
1231
  if (!isValueAssigned(action)) {
1229
- action = strOther;
1232
+ action = STR_OTHER;
1230
1233
  if (reason >= EventBatchNotificationReason.ResponseFailure && reason <= EventBatchNotificationReason.ResponseFailureMax) {
1231
- action = strResponseFail;
1234
+ action = STR_RESPONSE_FAIL;
1232
1235
  } else if (reason >= EventBatchNotificationReason.EventsDropped && reason <= EventBatchNotificationReason.EventsDroppedMax) {
1233
- action = strDropped;
1236
+ action = STR_DROPPED;
1234
1237
  } else if (reason >= EventBatchNotificationReason.SendingUndefined && reason <= EventBatchNotificationReason.SendingEventMax) {
1235
- action = strSending;
1238
+ action = STR_SENDING;
1236
1239
  }
1237
1240
  }
1238
1241
 
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5
+ // Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!
6
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7
+
8
+ // Generally you should only put values that are used more than 2 times and then only if not already exposed as a constant (such as SdkCoreNames)
9
+ // as when using "short" named values from here they will be will be minified smaller than the SdkCoreNames[eSdkCoreNames.xxxx] value.
10
+
11
+ export const STR_POST_METHOD = "POST";
12
+ export const STR_DISABLED_PROPERTY_NAME: string = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
13
+
14
+ export const STR_DROPPED = "drop";
15
+ export const STR_SENDING = "send";
16
+ export const STR_REQUEUE = "requeue";
17
+ export const STR_RESPONSE_FAIL = "rspFail";
18
+ export const STR_OTHER = "oth";
19
+
20
+ export const DEFAULT_CACHE_CONTROL = "no-cache, no-store";
21
+ export const DEFAULT_CONTENT_TYPE = "application/x-json-stream";
22
+ export const STR_CACHE_CONTROL = "cache-control";
23
+ export const STR_CONTENT_TYPE_HEADER = "content-type";
24
+ export const STR_KILL_TOKENS_HEADER = "kill-tokens";
25
+ export const STR_KILL_DURATION_HEADER = "kill-duration";
26
+ export const STR_KILL_DURATION_SECONDS_HEADER = "kill-duration-seconds";
27
+ export const STR_TIME_DELTA_HEADER = "time-delta-millis";
28
+ export const STR_CLIENT_VERSION = "client-version";
29
+ export const STR_CLIENT_ID = "client-id";
30
+ export const STR_TIME_DELTA_TO_APPLY = "time-delta-to-apply-millis";
31
+ export const STR_UPLOAD_TIME = "upload-time";
32
+ export const STR_API_KEY = "apikey";
33
+ export const STR_MSA_DEVICE_TICKET = "AuthMsaDeviceTicket";
34
+ export const STR_AUTH_XTOKEN = "AuthXToken";
35
+ export const STR_SDK_VERSION = "sdk-version";
36
+ export const STR_NO_RESPONSE_BODY = "NoResponseBody";
37
+
38
+ export const STR_MSFPC = "msfpc";
39
+
40
+ export const STR_TRACE = "trace";
41
+ export const STR_USER = "user";
package/src/KillSwitch.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import dynamicProto from "@microsoft/dynamicproto-js";
8
- import { arrForEach, strTrim, dateNow } from "@microsoft/1ds-core-js";
8
+ import { arrForEach, dateNow, strTrim } from "@microsoft/1ds-core-js";
9
9
 
10
10
  const SecToMsMultiplier = 1000;
11
11