@microsoft/applicationinsights-channel-js 2.8.0-beta.2203-09 → 2.8.0-beta.2203-12

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 (35) hide show
  1. package/browser/applicationinsights-channel-js.integrity.json +9 -9
  2. package/browser/applicationinsights-channel-js.js +16 -7
  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 -30
  7. package/dist/applicationinsights-channel-js.api.md +0 -2
  8. package/dist/applicationinsights-channel-js.d.ts +1 -2
  9. package/dist/applicationinsights-channel-js.js +16 -7
  10. package/dist/applicationinsights-channel-js.js.map +1 -1
  11. package/dist/applicationinsights-channel-js.min.js +2 -2
  12. package/dist/applicationinsights-channel-js.min.js.map +1 -1
  13. package/dist/applicationinsights-channel-js.rollup.d.ts +1 -2
  14. package/dist-esm/EnvelopeCreator.js +2 -2
  15. package/dist-esm/EnvelopeCreator.js.map +1 -1
  16. package/dist-esm/Interfaces.js +1 -1
  17. package/dist-esm/Offline.js +1 -1
  18. package/dist-esm/SendBuffer.js +1 -1
  19. package/dist-esm/Sender.js +4 -2
  20. package/dist-esm/Sender.js.map +1 -1
  21. package/dist-esm/Serializer.js +1 -1
  22. package/dist-esm/TelemetryProcessors/Sample.js +3 -3
  23. package/dist-esm/TelemetryProcessors/Sample.js.map +1 -1
  24. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.js +1 -1
  25. package/dist-esm/TelemetryProcessors/SamplingScoreGenerators/SamplingScoreGenerator.js +1 -1
  26. package/dist-esm/applicationinsights-channel-js.js +1 -1
  27. package/package.json +4 -4
  28. package/src/EnvelopeCreator.ts +2 -2
  29. package/src/Sender.ts +14 -14
  30. package/src/Serializer.ts +4 -8
  31. package/src/TelemetryProcessors/Sample.ts +1 -1
  32. package/src/TelemetryProcessors/SamplingScoreGenerators/HashCodeScoreGenerator.ts +3 -1
  33. package/types/Sender.d.ts +0 -1
  34. package/types/TelemetryProcessors/Sample.d.ts +2 -2
  35. package/types/tsdoc-metadata.json +1 -1
package/src/Sender.ts CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  getWindow, getNavigator, getJSON, BaseTelemetryPlugin, ITelemetryPluginChain, INotificationManager,
20
20
  SendRequestReason, objForEachKey, isNullOrUndefined, arrForEach, dateNow, dumpObj, getExceptionName, getIEVersion, objKeys,
21
21
  isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported, isArray, createUniqueNamespace, mergeEvtNamespace,
22
- IProcessTelemetryUnloadContext, ITelemetryUnloadState, _throwInternal
22
+ IProcessTelemetryUnloadContext, ITelemetryUnloadState, _throwInternal, throwError
23
23
  } from "@microsoft/applicationinsights-core-js";
24
24
  import { createOfflineListener, IOfflineListener } from "./Offline";
25
25
  import { Sample } from "./TelemetryProcessors/Sample"
@@ -202,6 +202,10 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
202
202
  };
203
203
 
204
204
  _self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void => {
205
+ if (_self.isInitialized()) {
206
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _InternalMessageId.SenderNotInitialized, "Sender is already initialized");
207
+ }
208
+
205
209
  _base.initialize(config, core, extensions, pluginChain);
206
210
  let ctx = _self._getTelCtx();
207
211
  let identifier = _self.identifier;
@@ -588,9 +592,9 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
588
592
 
589
593
  function _checkAndUpdateEndPointUrl(responseUrl: string) {
590
594
  // Maximum stamp specific redirects allowed(uncomment this when breeze is ready with not allowing redirects feature)
591
- if(_stamp_specific_redirects >= 10) {
592
- // _self._senderConfig.endpointUrl = () => Sender._getDefaultAppInsightsChannelConfig().endpointUrl()+"/?redirect=false";
593
- // _stamp_specific_redirects = 0;
595
+ if(_stamp_specific_redirects >= 10) {
596
+ // _self._senderConfig.endpointUrl = () => Sender._getDefaultAppInsightsChannelConfig().endpointUrl()+"/?redirect=false";
597
+ // _stamp_specific_redirects = 0;
594
598
  return false;
595
599
  }
596
600
  if(!isNullOrUndefined(responseUrl) && responseUrl !== "") {
@@ -724,16 +728,16 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
724
728
  * @param payload {string} - The data payload to be sent.
725
729
  * @param isAsync {boolean} - not used
726
730
  */
727
- function _fetchSender(payload: string[], isAsync: boolean) {
728
- _doFetchSender(payload, true);
729
- }
731
+ function _fetchSender(payload: string[], isAsync: boolean) {
732
+ _doFetchSender(payload, true);
733
+ }
730
734
 
731
735
  /**
732
736
  * Send fetch API request
733
737
  * @param payload {string} - The data payload to be sent.
734
738
  * @param isAsync {boolean} - For fetch this identifies whether we are "unloading" (false) or a normal request
735
739
  */
736
- function _doFetchSender(payload: string[], isAsync: boolean) {
740
+ function _doFetchSender(payload: string[], isAsync: boolean) {
737
741
  const endPointUrl = _self._senderConfig.endpointUrl();
738
742
  const batch = _self._buffer.batchPayloads(payload);
739
743
  const plainTextBatch = new Blob([batch], { type: "application/json" });
@@ -964,7 +968,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
964
968
  _InternalMessageId.TransmissionFailed, ". " +
965
969
  "Cannot send XDomain request. The endpoint URL protocol doesn't match the hosting page protocol.");
966
970
 
967
- buffer.clear();
971
+ buffer.clear();
968
972
  return;
969
973
  }
970
974
 
@@ -1081,10 +1085,6 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
1081
1085
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
1082
1086
  }
1083
1087
 
1084
- public teardown(): void {
1085
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
1086
- }
1087
-
1088
1088
  public initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain): void {
1089
1089
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
1090
1090
  }
@@ -1142,7 +1142,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
1142
1142
  * @param name - Header name.
1143
1143
  * @param value - Header value.
1144
1144
  */
1145
- public addHeader(name: string, value: string) {
1145
+ public addHeader(name: string, value: string) {
1146
1146
  // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
1147
1147
  }
1148
1148
  }
package/src/Serializer.ts CHANGED
@@ -139,12 +139,10 @@ export class Serializer {
139
139
  output[field] = "null";
140
140
  } else if (!value.toString) {
141
141
  output[field] = "invalid field: toString() is not defined.";
142
- }
143
- else {
142
+ } else {
144
143
  output[field] = value.toString();
145
144
  }
146
- }
147
- else if (expectedType === "number") {
145
+ } else if (expectedType === "number") {
148
146
  if (value === undefined) {
149
147
  output[field] = "undefined";
150
148
  } else if (value === null) {
@@ -153,13 +151,11 @@ export class Serializer {
153
151
  const num = parseFloat(value);
154
152
  if (isNaN(num)) {
155
153
  output[field] = "NaN";
156
- }
157
- else {
154
+ } else {
158
155
  output[field] = num;
159
156
  }
160
157
  }
161
- }
162
- else {
158
+ } else {
163
159
  output[field] = "invalid field: " + name + " is of unknown type.";
164
160
  logger.throwInternal(LoggingSeverity.CRITICAL, output[field], null, true);
165
161
  }
@@ -27,7 +27,7 @@ export class Sample implements ISample {
27
27
  this.samplingScoreGenerator = new SamplingScoreGenerator();
28
28
  }
29
29
 
30
- /**
30
+ /**
31
31
  * Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).
32
32
  */
33
33
  public isSampledIn(envelope: ITelemetryItem): boolean {
@@ -14,7 +14,9 @@ export class HashCodeScoreGenerator {
14
14
  }
15
15
 
16
16
  public getHashCode(input: string): number {
17
- if (input === "") { return 0; }
17
+ if (input === "") {
18
+ return 0;
19
+ }
18
20
 
19
21
  while (input.length < MIN_INPUT_LENGTH) {
20
22
  input = input.concat(input);
package/types/Sender.d.ts CHANGED
@@ -47,7 +47,6 @@ export declare class Sender extends BaseTelemetryPlugin implements IChannelContr
47
47
  * Will not flush if the Send has been paused.
48
48
  */
49
49
  onunloadFlush(): void;
50
- teardown(): void;
51
50
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
52
51
  processTelemetry(telemetryItem: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
53
52
  /**
@@ -6,7 +6,7 @@ export declare class Sample implements ISample {
6
6
  private samplingScoreGenerator;
7
7
  constructor(sampleRate: number, logger?: IDiagnosticLogger);
8
8
  /**
9
- * Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).
10
- */
9
+ * Determines if an envelope is sampled in (i.e. will be sent) or not (i.e. will be dropped).
10
+ */
11
11
  isSampledIn(envelope: ITelemetryItem): boolean;
12
12
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.19.4"
8
+ "packageVersion": "7.19.5"
9
9
  }
10
10
  ]
11
11
  }