@microsoft/applicationinsights-channel-js 2.7.3-nightly.2112-07 → 2.7.3

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 (30) hide show
  1. package/browser/applicationinsights-channel-js.integrity.json +9 -9
  2. package/browser/applicationinsights-channel-js.js +86 -54
  3. package/browser/applicationinsights-channel-js.js.map +1 -1
  4. package/browser/applicationinsights-channel-js.min.js +2 -2
  5. package/browser/applicationinsights-channel-js.min.js.map +1 -1
  6. package/dist/applicationinsights-channel-js.api.json +1 -1
  7. package/dist/applicationinsights-channel-js.d.ts +1 -1
  8. package/dist/applicationinsights-channel-js.js +86 -54
  9. package/dist/applicationinsights-channel-js.js.map +1 -1
  10. package/dist/applicationinsights-channel-js.min.js +2 -2
  11. package/dist/applicationinsights-channel-js.min.js.map +1 -1
  12. package/dist/applicationinsights-channel-js.rollup.d.ts +1 -1
  13. package/dist-esm/EnvelopeCreator.js +2 -2
  14. package/dist-esm/EnvelopeCreator.js.map +1 -1
  15. package/dist-esm/Interfaces.js +1 -1
  16. package/dist-esm/Offline.js +1 -1
  17. package/dist-esm/SendBuffer.js +1 -1
  18. package/dist-esm/Sender.js +50 -27
  19. package/dist-esm/Sender.js.map +1 -1
  20. package/dist-esm/Serializer.js +1 -1
  21. package/dist-esm/TelemetryProcessors/Sample.js +1 -1
  22. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
  23. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
  24. package/dist-esm/applicationinsights-channel-js.js +1 -1
  25. package/package.json +54 -57
  26. package/src/EnvelopeCreator.ts +2 -2
  27. package/src/Offline.ts +1 -1
  28. package/src/SendBuffer.ts +1 -1
  29. package/src/Sender.ts +52 -28
  30. package/types/tsdoc-metadata.json +1 -1
package/package.json CHANGED
@@ -1,57 +1,54 @@
1
- {
2
- "name": "@microsoft/applicationinsights-channel-js",
3
- "version": "2.7.3-nightly.2112-07",
4
- "description": "Microsoft Application Insights JavaScript SDK Channel",
5
- "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
- "author": "Microsoft Application Insights Team",
7
- "main": "dist/applicationinsights-channel-js.js",
8
- "module": "dist-esm/applicationinsights-channel-js.js",
9
- "types": "types/applicationinsights-channel-js.d.ts",
10
- "sideEffects": false,
11
- "repository": "github:Microsoft/applicationinsights-js",
12
- "scripts": {
13
- "clean": "rm -rf browser dist dist-esm types",
14
- "build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen",
15
- "build:esm": "grunt aichannel",
16
- "build:browser": "rollup -c",
17
- "rebuild": "npm run build",
18
- "test": "grunt aichanneltest",
19
- "lint": "tslint -p tsconfig.json",
20
- "dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights JavaScript SDK Channel\"",
21
- "sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js"
22
- },
23
- "devDependencies": {
24
- "@microsoft/ai-test-framework": "0.0.1",
25
- "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
26
- "@microsoft/applicationinsights-rollup-es3": "1.1.3",
27
- "@microsoft/api-extractor": "^7.18.1",
28
- "@types/sinon": "4.3.3",
29
- "grunt": "^1.4.1",
30
- "grunt-cli": "^1.4.3",
31
- "@nevware21/grunt-ts-plugin": "^0.4.3",
32
- "@nevware21/grunt-eslint-ts": "^0.2.2",
33
- "globby": "^11.0.0",
34
- "magic-string": "^0.25.7",
35
- "@rollup/plugin-commonjs": "^18.0.0",
36
- "@rollup/plugin-node-resolve": "^11.2.1",
37
- "@rollup/plugin-replace": "^2.3.3",
38
- "rollup-plugin-cleanup": "3.2.1",
39
- "rollup": "^2.32.0",
40
- "typescript": "^4.3.4",
41
- "tslib": "^2.0.0",
42
- "sinon": "^7.3.1"
43
- },
44
- "peerDependencies": {
45
- "tslib": "*"
46
- },
47
- "dependencies": {
48
- "@microsoft/dynamicproto-js": "^1.1.4",
49
- "@microsoft/applicationinsights-shims": "2.0.0",
50
- "@microsoft/applicationinsights-core-js": "2.7.3-nightly.2112-07",
51
- "@microsoft/applicationinsights-common": "2.7.3-nightly.2112-07"
52
- },
53
- "license": "MIT",
54
- "publishConfig": {
55
- "tag": "nightly"
56
- }
57
- }
1
+ {
2
+ "name": "@microsoft/applicationinsights-channel-js",
3
+ "version": "2.7.3",
4
+ "description": "Microsoft Application Insights JavaScript SDK Channel",
5
+ "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
+ "author": "Microsoft Application Insights Team",
7
+ "main": "dist/applicationinsights-channel-js.js",
8
+ "module": "dist-esm/applicationinsights-channel-js.js",
9
+ "types": "types/applicationinsights-channel-js.d.ts",
10
+ "sideEffects": false,
11
+ "repository": "github:Microsoft/applicationinsights-js",
12
+ "scripts": {
13
+ "clean": "rm -rf browser dist dist-esm types",
14
+ "build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen",
15
+ "build:esm": "grunt aichannel",
16
+ "build:browser": "rollup -c",
17
+ "rebuild": "npm run build",
18
+ "test": "grunt aichanneltest",
19
+ "lint": "tslint -p tsconfig.json",
20
+ "dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights JavaScript SDK Channel\"",
21
+ "sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js"
22
+ },
23
+ "devDependencies": {
24
+ "@microsoft/ai-test-framework": "0.0.1",
25
+ "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
26
+ "@microsoft/applicationinsights-rollup-es3": "1.1.3",
27
+ "@microsoft/api-extractor": "^7.18.1",
28
+ "@types/sinon": "4.3.3",
29
+ "grunt": "^1.4.1",
30
+ "grunt-cli": "^1.4.3",
31
+ "@nevware21/grunt-ts-plugin": "^0.4.3",
32
+ "@nevware21/grunt-eslint-ts": "^0.2.2",
33
+ "globby": "^11.0.0",
34
+ "magic-string": "^0.25.7",
35
+ "@rollup/plugin-commonjs": "^18.0.0",
36
+ "@rollup/plugin-node-resolve": "^11.2.1",
37
+ "@rollup/plugin-replace": "^2.3.3",
38
+ "rollup-plugin-cleanup": "3.2.1",
39
+ "rollup": "^2.32.0",
40
+ "typescript": "^4.3.4",
41
+ "tslib": "^2.0.0",
42
+ "sinon": "^7.3.1"
43
+ },
44
+ "peerDependencies": {
45
+ "tslib": "*"
46
+ },
47
+ "dependencies": {
48
+ "@microsoft/dynamicproto-js": "^1.1.4",
49
+ "@microsoft/applicationinsights-shims": "2.0.1",
50
+ "@microsoft/applicationinsights-core-js": "2.7.3",
51
+ "@microsoft/applicationinsights-common": "2.7.3"
52
+ },
53
+ "license": "MIT"
54
+ }
@@ -175,7 +175,7 @@ function EnvelopeCreatorInit(logger: IDiagnosticLogger, telemetryItem: ITelemetr
175
175
  }
176
176
 
177
177
  export const EnvelopeCreator = {
178
- Version: "2.7.3-nightly.2112-07"
178
+ Version: "2.7.3"
179
179
  };
180
180
 
181
181
  export function DependencyEnvelopeCreator(logger: IDiagnosticLogger, telemetryItem: ITelemetryItem, customUndefinedValue?: any): IEnvelope {
@@ -284,7 +284,7 @@ export function PageViewEnvelopeCreator(logger: IDiagnosticLogger, telemetryItem
284
284
  if (((telemetryItem.ext || {}).trace || {}).traceID) {
285
285
  currentContextId = telemetryItem.ext.trace.traceID;
286
286
  }
287
- const id = bd.id || currentContextId
287
+ const id = bd.id || currentContextId;
288
288
  const name = bd.name;
289
289
  const url = bd.uri;
290
290
  const properties = bd[strProperties] || {};
package/src/Offline.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EventHelper, getWindow, getDocument, getNavigator, isUndefined, isNullOrUndefined, attachEvent } from "@microsoft/applicationinsights-core-js";
1
+ import { getWindow, getDocument, getNavigator, isUndefined, isNullOrUndefined, attachEvent } from "@microsoft/applicationinsights-core-js";
2
2
  import dynamicProto from "@microsoft/dynamicproto-js";
3
3
 
4
4
  /**
package/src/SendBuffer.ts CHANGED
@@ -266,7 +266,7 @@ export class SessionStorageSendBuffer extends BaseSendBuffer implements ISendBuf
266
266
  sentElements = _removePayloadsFromBuffer(payload, sentElements);
267
267
 
268
268
  _setBuffer(SessionStorageSendBuffer.SENT_BUFFER_KEY, sentElements);
269
- }
269
+ };
270
270
 
271
271
  function _removePayloadsFromBuffer(payloads: string[], buffer: string[]): string[] {
272
272
  const remaining: string[] = [];
package/src/Sender.ts CHANGED
@@ -233,7 +233,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
233
233
 
234
234
  _self.addHeader = (name: string, value: string) => {
235
235
  _headers[name] = value;
236
- }
236
+ };
237
237
 
238
238
  _self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void => {
239
239
  _base.initialize(config, core, extensions, pluginChain);
@@ -757,7 +757,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
757
757
  /**
758
758
  * Send fetch API request
759
759
  * @param payload {string} - The data payload to be sent.
760
- * @param isAsync {boolean} - not used
760
+ * @param isAsync {boolean} - For fetch this identifies whether we are "unloading" (false) or a normal request
761
761
  */
762
762
  function _doFetchSender(payload: string[], isAsync: boolean) {
763
763
  const endPointUrl = _self._senderConfig.endpointUrl();
@@ -765,6 +765,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
765
765
  const plainTextBatch = new Blob([batch], { type: "application/json" });
766
766
  let requestHeaders = new Headers();
767
767
  let batchLength = batch.length;
768
+ let ignoreResponse = false;
769
+ let responseHandled = false;
768
770
 
769
771
  // append Sdk-Context request header only in case of breeze endpoint
770
772
  if (isInternalApplicationInsightsEndpoint(endPointUrl)) {
@@ -780,10 +782,13 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
780
782
  headers: requestHeaders,
781
783
  body: plainTextBatch,
782
784
  [DisabledPropertyName]: true // Mark so we don't attempt to track this request
783
- }
785
+ };
784
786
 
785
787
  if (!isAsync) {
786
788
  init.keepalive = true;
789
+ // As a sync request (during unload), it is unlikely that we will get a chance to process the response so
790
+ // just like beacon send assume that the events have been accepted and processed
791
+ ignoreResponse = true;
787
792
  _syncFetchPayload += batchLength;
788
793
  }
789
794
 
@@ -796,34 +801,53 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
796
801
  // cause the request to fail and we no telemetry would be sent
797
802
  }
798
803
 
799
- fetch(request).then(response => {
800
- if (!isAsync) {
801
- _syncFetchPayload -= batchLength;
802
- batchLength = 0;
803
- }
804
+ _self._buffer.markAsSent(payload);
804
805
 
805
- /**
806
- * The Promise returned from fetch() won’t reject on HTTP error status even if the response is an HTTP 404 or 500.
807
- * Instead, it will resolve normally (with ok status set to false), and it will only reject on network failure
808
- * or if anything prevented the request from completing.
809
- */
810
- if (!response.ok) {
811
- _self._onError(payload, response.statusText)
812
- } else {
813
- response.text().then(text => {
814
- _checkResponsStatus(response.status, payload, response.url, payload.length, response.statusText, text);
815
- });
816
- }
817
- }).catch((error: Error) => {
818
- if (!isAsync) {
819
- _syncFetchPayload -= batchLength;
820
- batchLength = 0;
806
+ try {
807
+ fetch(request).then(response => {
808
+ if (!isAsync) {
809
+ _syncFetchPayload -= batchLength;
810
+ batchLength = 0;
811
+ }
812
+
813
+ if (!responseHandled) {
814
+ responseHandled = true;
815
+
816
+ /**
817
+ * The Promise returned from fetch() won’t reject on HTTP error status even if the response is an HTTP 404 or 500.
818
+ * Instead, it will resolve normally (with ok status set to false), and it will only reject on network failure
819
+ * or if anything prevented the request from completing.
820
+ */
821
+ if (!response.ok) {
822
+ _self._onError(payload, response.statusText)
823
+ } else {
824
+ response.text().then(text => {
825
+ _checkResponsStatus(response.status, payload, response.url, payload.length, response.statusText, text);
826
+ });
827
+ }
828
+ }
829
+ }).catch((error: Error) => {
830
+ if (!isAsync) {
831
+ _syncFetchPayload -= batchLength;
832
+ batchLength = 0;
833
+ }
834
+
835
+ if (!responseHandled) {
836
+ responseHandled = true;
837
+ _self._onError(payload, error.message)
838
+ }
839
+ });
840
+ } catch (e) {
841
+ if (!responseHandled) {
842
+ _self._onError(payload, dumpObj(e));
821
843
  }
844
+ }
822
845
 
823
- _self._onError(payload, error.message)
824
- });
825
-
826
- _self._buffer.markAsSent(payload);
846
+ if (ignoreResponse && !responseHandled) {
847
+ // Assume success during unload processing as we most likely won't get the response
848
+ responseHandled = true;
849
+ _self._onSuccess(payload, payload.length);
850
+ }
827
851
  }
828
852
 
829
853
  /**
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.21"
8
+ "packageVersion": "7.19.4"
9
9
  }
10
10
  ]
11
11
  }