@microsoft/1ds-post-js 3.2.7 → 3.2.9

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 (59) hide show
  1. package/README.md +2 -1
  2. package/bundle/{ms.post-3.2.7.gbl.js → ms.post-3.2.9.gbl.js} +93 -60
  3. package/bundle/ms.post-3.2.9.gbl.js.map +1 -0
  4. package/bundle/ms.post-3.2.9.gbl.min.js +7 -0
  5. package/bundle/ms.post-3.2.9.gbl.min.js.map +1 -0
  6. package/bundle/ms.post-3.2.9.integrity.json +46 -0
  7. package/bundle/{ms.post-3.2.7.js → ms.post-3.2.9.js} +93 -60
  8. package/bundle/ms.post-3.2.9.js.map +1 -0
  9. package/bundle/ms.post-3.2.9.min.js +7 -0
  10. package/bundle/ms.post-3.2.9.min.js.map +1 -0
  11. package/bundle/ms.post.gbl.js +92 -59
  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 +92 -59
  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 +17 -12
  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.d.ts +1 -1
  25. package/dist-esm/src/BatchNotificationActions.js +1 -1
  26. package/dist-esm/src/ClockSkewManager.js +1 -1
  27. package/dist-esm/src/DataModels.d.ts +8 -3
  28. package/dist-esm/src/DataModels.js +1 -1
  29. package/dist-esm/src/EventBatch.js +3 -3
  30. package/dist-esm/src/EventBatch.js.map +1 -1
  31. package/dist-esm/src/HttpManager.js +13 -9
  32. package/dist-esm/src/HttpManager.js.map +1 -1
  33. package/dist-esm/src/Index.js +1 -1
  34. package/dist-esm/src/InternalConstants.d.ts +1 -0
  35. package/dist-esm/src/InternalConstants.js +2 -1
  36. package/dist-esm/src/InternalConstants.js.map +1 -1
  37. package/dist-esm/src/KillSwitch.js +1 -1
  38. package/dist-esm/src/PostChannel.js +3 -3
  39. package/dist-esm/src/PostChannel.js.map +1 -1
  40. package/dist-esm/src/RetryPolicy.js +1 -1
  41. package/dist-esm/src/Serializer.js +3 -2
  42. package/dist-esm/src/Serializer.js.map +1 -1
  43. package/dist-esm/src/TimeoutOverrideWrapper.d.ts +2 -2
  44. package/dist-esm/src/TimeoutOverrideWrapper.js +1 -1
  45. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  46. package/package.json +4 -4
  47. package/src/DataModels.ts +7 -1
  48. package/src/EventBatch.ts +2 -2
  49. package/src/HttpManager.ts +12 -8
  50. package/src/InternalConstants.ts +1 -0
  51. package/src/PostChannel.ts +1 -1
  52. package/src/Serializer.ts +2 -1
  53. package/bundle/ms.post-3.2.7.gbl.js.map +0 -1
  54. package/bundle/ms.post-3.2.7.gbl.min.js +0 -7
  55. package/bundle/ms.post-3.2.7.gbl.min.js.map +0 -1
  56. package/bundle/ms.post-3.2.7.integrity.json +0 -46
  57. package/bundle/ms.post-3.2.7.js.map +0 -1
  58. package/bundle/ms.post-3.2.7.min.js +0 -7
  59. package/bundle/ms.post-3.2.7.min.js.map +0 -1
@@ -22,7 +22,7 @@ import { EventBatch } from "./EventBatch";
22
22
  import { IChannelConfiguration } from "./Index";
23
23
  import {
24
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,
25
+ STR_CONTENT_TYPE_HEADER, STR_DISABLED_PROPERTY_NAME, STR_DROPPED, STR_EMPTY, STR_KILL_DURATION_HEADER, STR_KILL_DURATION_SECONDS_HEADER,
26
26
  STR_KILL_TOKENS_HEADER, STR_MSA_DEVICE_TICKET, STR_MSFPC, STR_NO_RESPONSE_BODY, STR_OTHER, STR_POST_METHOD, STR_REQUEUE,
27
27
  STR_RESPONSE_FAIL, STR_SENDING, STR_TIME_DELTA_HEADER, STR_TIME_DELTA_TO_APPLY, STR_UPLOAD_TIME
28
28
  } from "./InternalConstants";
@@ -85,7 +85,7 @@ function _getResponseText(xhr: XMLHttpRequest | IXDomainRequest) {
85
85
  // Best effort, as XHR may throw while XDR wont so just ignore
86
86
  }
87
87
 
88
- return "";
88
+ return STR_EMPTY;
89
89
  }
90
90
 
91
91
  interface IInternalXhrOverride extends IXHROverride {
@@ -178,6 +178,7 @@ export class HttpManager {
178
178
  let _disableXhrSync: boolean;
179
179
  let _disableFetchKeepAlive: boolean;
180
180
  let _canHaveReducedPayload: boolean;
181
+ let _addNoResponse: boolean;
181
182
 
182
183
  dynamicProto(HttpManager, this, (_self) => {
183
184
  let _sendCredentials = true;
@@ -211,6 +212,7 @@ export class HttpManager {
211
212
  _xhrTimeout = channelConfig.xhrTimeout;
212
213
  _disableXhrSync = !!channelConfig.disableXhrSync;
213
214
  _disableFetchKeepAlive = !!channelConfig.disableFetchKeepAlive;
215
+ _addNoResponse = channelConfig.addNoResponse !== false;
214
216
 
215
217
  _useBeacons = !isReactNative(); // Only use beacons if not running in React Native
216
218
  _serializer = new Serializer(_core, valueSanitizer, stringifyObjects, enableCompoundKey);
@@ -361,7 +363,9 @@ export class HttpManager {
361
363
  // As a sync request (during unload), it is unlikely that we will get a chance to process the response so
362
364
  // just like beacon send assume that the events have been accepted and processed
363
365
  ignoreResponse = true;
364
- theUrl += _noResponseQs;
366
+ if (_addNoResponse) {
367
+ theUrl += _noResponseQs;
368
+ }
365
369
  }
366
370
  }
367
371
 
@@ -377,7 +381,7 @@ export class HttpManager {
377
381
 
378
382
  fetch(theUrl, requestInit).then((response) => {
379
383
  let headerMap = {};
380
- let responseText = "";
384
+ let responseText = STR_EMPTY;
381
385
  var headers = response.headers;
382
386
  if (headers) {
383
387
  headers["forEach"]((value: string, name: string) => {
@@ -495,7 +499,7 @@ export class HttpManager {
495
499
  let internalPayloadData = payload as IInternalPayloadData;
496
500
  let status = 200;
497
501
  let thePayload = internalPayloadData._thePayload;
498
- let theUrl = payload.urlString + _noResponseQs;
502
+ let theUrl = payload.urlString + (_addNoResponse ? _noResponseQs : STR_EMPTY);
499
503
 
500
504
  try {
501
505
  let nav = getNavigator();
@@ -529,7 +533,7 @@ export class HttpManager {
529
533
  _warnToConsole(_logger, "Failed to send telemetry using sendBeacon API. Ex:" + dumpObj(ex));
530
534
  status = 0;
531
535
  } finally {
532
- _doOnComplete(oncomplete, status, {}, "");
536
+ _doOnComplete(oncomplete, status, {}, STR_EMPTY);
533
537
  }
534
538
  }
535
539
 
@@ -799,7 +803,7 @@ export class HttpManager {
799
803
  _addRequestDetails(requestDetails, STR_CLIENT_ID, "NO_AUTH", useHeaders);
800
804
  _addRequestDetails(requestDetails, STR_CLIENT_VERSION, FullVersionString, useHeaders);
801
805
 
802
- let apiQsKeys = "";
806
+ let apiQsKeys = STR_EMPTY;
803
807
  arrForEach(thePayload.apiKeys, (apiKey) => {
804
808
  if (apiQsKeys.length > 0) {
805
809
  apiQsKeys += ",";
@@ -1197,7 +1201,7 @@ export class HttpManager {
1197
1201
  }
1198
1202
  }
1199
1203
 
1200
- return "";
1204
+ return STR_EMPTY;
1201
1205
  }
1202
1206
 
1203
1207
  function _handleCollectorResponse(responseText: string): void {
@@ -8,6 +8,7 @@
8
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
9
  // as when using "short" named values from here they will be will be minified smaller than the SdkCoreNames[eSdkCoreNames.xxxx] value.
10
10
 
11
+ export const STR_EMPTY = "";
11
12
  export const STR_POST_METHOD = "POST";
12
13
  export const STR_DISABLED_PROPERTY_NAME: string = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
13
14
 
@@ -160,7 +160,7 @@ export default class PostChannel extends BaseTelemetryPlugin implements IChannel
160
160
 
161
161
  // Override endpointUrl if provided in Post config
162
162
  let endpointUrl = _config.overrideEndpointUrl ? _config.overrideEndpointUrl : coreConfig.endpointUrl;
163
- _self._notificationManager = coreConfig.extensionConfig.NotificationManager;
163
+ _self._notificationManager = core.getNotifyMgr();
164
164
  _httpManager.initialize(endpointUrl, _self.core as IExtendedAppInsightsCore, _self, _xhrOverride, _config);
165
165
 
166
166
  let excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || [];
package/src/Serializer.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  } from "@microsoft/1ds-core-js";
14
14
  import { IPostTransmissionTelemetryItem } from "./DataModels";
15
15
  import { EventBatch } from "./EventBatch";
16
+ import { STR_EMPTY } from "./InternalConstants";
16
17
 
17
18
  /**
18
19
  * Note: This is an optimization for V8-based browsers. When V8 concatenates a string,
@@ -124,7 +125,7 @@ export class Serializer {
124
125
  _self.createPayload = (retryCnt: number, isTeardown: boolean, isSync: boolean, isReducedPayload: boolean, sendReason: SendRequestReason, sendType: EventSendType): ISerializedPayload => {
125
126
  return {
126
127
  apiKeys: [],
127
- payloadBlob: "",
128
+ payloadBlob: STR_EMPTY,
128
129
  overflow: null,
129
130
  sizeExceed: [],
130
131
  failedEvts: [],