Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Karlie-777 committed Apr 2, 2024
2 parents 2a44bf9 + 44d1055 commit fc2f9d6
Show file tree
Hide file tree
Showing 88 changed files with 1,033 additions and 580 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [ 14, 16, 18, 20 ]
node-version: [ 16, 18, 20 ]

steps:
- uses: actions/checkout@v4
Expand Down
26 changes: 15 additions & 11 deletions AISKU/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion AISKU/Tests/Perf/src/AISKUPerf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppInsightsInitPerfTestClass {
* should update version after new release
* version with doperf(): after 2.5.6
* */
var defaultVer = "3.1.0";
var defaultVer = "3.1.2";
this.version = ver? ver:this._getQueryParameterVersion(defaultVer);
this.perfEventsBuffer = [];
this.perfEventWaitBuffer = [];
Expand Down
6 changes: 3 additions & 3 deletions AISKU/Tests/Unit/src/AISKUSize.Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { Snippet } from "../../../src/Snippet";
import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-common";

export class AISKUSizeCheck extends AITestClass {
private readonly MAX_RAW_SIZE = 139;
private readonly MAX_BUNDLE_SIZE = 139;
private readonly MAX_RAW_SIZE = 140;
private readonly MAX_BUNDLE_SIZE = 140;
private readonly MAX_RAW_DEFLATE_SIZE = 56;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 56;
private readonly rawFilePath = "../dist/es5/applicationinsights-web.min.js";
// Automatically updated by version scripts
private readonly currentVer = "3.1.0";
private readonly currentVer = "3.1.2";
private readonly prodFilePath = `../browser/es5/ai.${this.currentVer[0]}.min.js`;

public testInitialize() {
Expand Down
2 changes: 1 addition & 1 deletion AISKU/Tests/Unit/src/CdnPackaging.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const enum CdnFormat {

export class CdnPackagingChecks extends AITestClass {
// Automatically updated by version scripts
private readonly currentVer = "3.1.0";
private readonly currentVer = "3.1.2";

public testInitialize() {
}
Expand Down
13 changes: 13 additions & 0 deletions AISKU/Tests/Unit/src/GlobalTestHooks.Test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
2 changes: 2 additions & 0 deletions AISKU/Tests/Unit/src/aiskuunittests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AISKUSizeCheck } from "./AISKUSize.Tests";
import { ApplicationInsightsTests } from './applicationinsights.e2e.tests';
import { ApplicationInsightsFetchTests } from './applicationinsights.e2e.fetch.tests';
import { CdnPackagingChecks } from './CdnPackaging.tests';
import { GlobalTestHooks } from './GlobalTestHooks.Test';
import { SanitizerE2ETests } from './sanitizer.e2e.tests';
import { ValidateE2ETests } from './validate.e2e.tests';
import { SenderE2ETests } from './sender.e2e.tests';
Expand All @@ -10,6 +11,7 @@ import { CdnThrottle} from "./CdnThrottle.tests";
import { ThrottleSentMessage } from "./ThrottleSentMessage.tests";

export function runTests() {
new GlobalTestHooks().registerTests();
new AISKUSizeCheck().registerTests();
new ApplicationInsightsTests().registerTests();
new ApplicationInsightsFetchTests().registerTests();
Expand Down
6 changes: 3 additions & 3 deletions AISKU/Tests/es6-module-type-check/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/applicationinsights-test-module-type-check",
"author": "Microsoft Application Insights Team and Contributors",
"version": "3.1.0",
"version": "3.1.2",
"description": "Microsoft Application Insights ES6 Module and Type check Example",
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
"keywords": [
Expand Down Expand Up @@ -32,7 +32,7 @@
"tslib": "*"
},
"dependencies": {
"@microsoft/applicationinsights-common": "3.1.0",
"@microsoft/applicationinsights-web": "3.1.0"
"@microsoft/applicationinsights-common": "3.1.2",
"@microsoft/applicationinsights-web": "3.1.2"
}
}
18 changes: 9 additions & 9 deletions AISKU/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/applicationinsights-web",
"version": "3.1.0",
"version": "3.1.2",
"description": "Microsoft Application Insights JavaScript SDK - Web",
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
"author": "Microsoft Application Insights Team",
Expand Down Expand Up @@ -63,14 +63,14 @@
"dependencies": {
"@microsoft/dynamicproto-js": "^2.0.3",
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/applicationinsights-analytics-js": "3.1.0",
"@microsoft/applicationinsights-channel-js": "3.1.0",
"@microsoft/applicationinsights-cfgsync-js": "3.1.0",
"@microsoft/applicationinsights-common": "3.1.0",
"@microsoft/applicationinsights-core-js": "3.1.0",
"@microsoft/applicationinsights-dependencies-js": "3.1.0",
"@microsoft/applicationinsights-properties-js": "3.1.0",
"@nevware21/ts-utils": ">= 0.10.5 < 2.x",
"@microsoft/applicationinsights-analytics-js": "3.1.2",
"@microsoft/applicationinsights-channel-js": "3.1.2",
"@microsoft/applicationinsights-cfgsync-js": "3.1.2",
"@microsoft/applicationinsights-common": "3.1.2",
"@microsoft/applicationinsights-core-js": "3.1.2",
"@microsoft/applicationinsights-dependencies-js": "3.1.2",
"@microsoft/applicationinsights-properties-js": "3.1.2",
"@nevware21/ts-utils": ">= 0.11.0 < 2.x",
"@nevware21/ts-async": ">= 0.3.0 < 2.x"
},
"license": "MIT"
Expand Down
6 changes: 3 additions & 3 deletions AISKULight/Tests/Unit/src/AISKULightSize.Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import * as pako from "pako";
export class AISKULightSizeCheck extends AITestClass {
private readonly MAX_RAW_SIZE = 86;
private readonly MAX_BUNDLE_SIZE = 86;
private readonly MAX_RAW_DEFLATE_SIZE = 35;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 35;
private readonly MAX_RAW_DEFLATE_SIZE = 36;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 36;
private readonly rawFilePath = "../dist/es5/applicationinsights-web-basic.min.js";
private readonly currentVer = "3.1.0";
private readonly currentVer = "3.1.2";
private readonly prodFilePath = `../browser/es5/aib.${this.currentVer[0]}.min.js`;

public testInitialize() {
Expand Down
13 changes: 13 additions & 0 deletions AISKULight/Tests/Unit/src/GlobalTestHooks.Test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
2 changes: 2 additions & 0 deletions AISKULight/Tests/Unit/src/aiskuliteunittests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { AISKULightSizeCheck } from "./AISKULightSize.Tests";
import { ApplicationInsightsDynamicConfigTests } from "./dynamicconfig.tests";
import { ApplicationInsightsConfigTests } from "./config.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new AISKULightSizeCheck().registerTests();
new ApplicationInsightsDynamicConfigTests().registerTests();
new ApplicationInsightsConfigTests().registerTests();
Expand Down
10 changes: 5 additions & 5 deletions AISKULight/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/applicationinsights-web-basic",
"version": "3.1.0",
"version": "3.1.2",
"description": "Microsoft Application Insights JavaScript SDK - Web Basic",
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
"author": "Microsoft Application Insights Team",
Expand Down Expand Up @@ -57,10 +57,10 @@
"dependencies": {
"@microsoft/dynamicproto-js": "^2.0.3",
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/applicationinsights-common": "3.1.0",
"@microsoft/applicationinsights-channel-js": "3.1.0",
"@microsoft/applicationinsights-core-js": "3.1.0",
"@nevware21/ts-utils": ">= 0.10.5 < 2.x",
"@microsoft/applicationinsights-common": "3.1.2",
"@microsoft/applicationinsights-channel-js": "3.1.2",
"@microsoft/applicationinsights-core-js": "3.1.2",
"@nevware21/ts-utils": ">= 0.11.0 < 2.x",
"@nevware21/ts-async": ">= 0.3.0 < 2.x"
},
"license": "MIT"
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ Most configuration fields are named such that they can be defaulted to falsey. A
| storagePrefix | string[] | undefined | [Optional] An optional value that will be added as name prefix for storage name. |
| featureOptIn <br/><sub>since 3.0.3</sub> | IFeatureOptIn | undefined | [Optional] Set Feature opt in details. |
| throttleMgrCfg <br/><sub>since 3.0.3</sub> | `{[key: number]: IThrottleMgrConfig}` | undefined | [Optional] Set throttle mgr configuration by key. |
| retryCodes | number[] | undefined | Identifies the status codes that will cause event batches to be resent, when `null` or `undefined` the SDK will use it's defaults `[401, 408, 429, 500, 502, 503, 504]`. `403` was removed in version 3.1.1. |

### ICookieMgrConfig

Expand Down Expand Up @@ -456,7 +457,11 @@ As part of changes being introduced in version 2.6.0 we are deprecating and remo

## Service Notification

As part of changes being introduced in version 3.0.3, we are intergrating [cfgSync plugin](https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-cfgsync-js) and [throttle manager](./docs/ThrottleMgr.md) to AISKU. By default, these components will be disabled during the current initial release, but they will be enabled by default in future releases once extensive production level testing is completed.
As part of changes being introduced in version 3.0.3, we are intergrating [cfgSync plugin](https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-cfgsync-js) and [throttle manager](./docs/ThrottleMgr.md) to AISKU.
For versions before 3.1.2, these components are disabled by default.

For versions after 3.1.2, these components are **turned on by default**.
See [feature opt-in status](./docs/WebConfig.md) for more details.

## Single Page Applications

Expand Down
29 changes: 29 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

> Note: ES3/IE8 compatibility will be removed in the future v3.x.x releases (scheduled for mid-late 2022), so if you need to retain ES3 compatibility you will need to remain on the 2.x.x versions of the SDK or your runtime will need install polyfill's to your ES3 environment before loading / initializing the SDK.
## 3.1.2 (Mar 21st, 2024)

!! Critical Bug fix for Memoery Leak !!
[#2311](https://github.com/microsoft/ApplicationInsights-JS/issues/2311)

It also contains a packaging fix for webpack [#2307](https://github.com/microsoft/ApplicationInsights-JS/issues/2307) (caused by [#2306]](https://github.com/microsoft/ApplicationInsights-JS/issues/2306) ) and

### Changelog

- #2307 ApplicationInsights-JS latest version 3.1.1 giving TypeError: Cannot read properties of undefined (reading 'getCrypto')
- #2306 [BUG] Circular dependencies
- #2311 [BUG] Excessive memory usage for SPA where unload hooks keep accumulating
- #2299 [Main][Task]27156360: Add json config cdn details to tool folder
- #2308 [Main][Task]27221819: Remove node 14 (from ci.yml)

## 3.1.1 (Mar 12th, 2024)

### Changelog

- #2296 [BUG] remove 403 as a “retriable” error code
- #2276 Update api-docs (typedoc) with the current 3.1.0 release details
- #2281 [Main][Task]26681188: Handle endpoint url change for offline channel and add notification mgr
- #2282 Addng two new PII Kind values for IPv6 scrubbing and dropping data.
- #2285 [Main][Task]25693679: Extract common sendPost implementation for online and offline sender
- #2197 [main] [BUG] using EndPointUrl (and IngestionEndpoint) results in Telemetry sent to incorrect urls
- #2288 [Main][Task]27064950: Add doc on adding offline support channel
- #2295 [Main][Task]27064983: Update post channel to use sender post common interfaces from core
- #2290 chore: remove extraneous console log from debug plugin

### Web snippet additional update to 1.1.2 (March 1st, 2024)
Refer to #2284 [Web-Snippet] [BUG] @microsoft/applicationinsights-web-snippet version 1.1.1 type problem

Expand Down
6 changes: 3 additions & 3 deletions channels/1ds-post-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/1ds-post-js",
"version": "4.1.0",
"version": "4.1.2",
"description": "Microsoft Application Insights JavaScript SDK - 1ds-post-channel-js",
"author": "Microsoft Application Insights Team",
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
Expand All @@ -27,8 +27,8 @@
"dependencies": {
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/dynamicproto-js": "^2.0.3",
"@microsoft/1ds-core-js": "4.1.0",
"@nevware21/ts-utils": ">= 0.10.5 < 2.x",
"@microsoft/1ds-core-js": "4.1.2",
"@nevware21/ts-utils": ">= 0.11.0 < 2.x",
"@nevware21/ts-async": ">= 0.3.0 < 2.x"
},
"devDependencies": {
Expand Down
13 changes: 13 additions & 0 deletions channels/1ds-post-js/test/Unit/src/GlobalTestHooks.Test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { _testHookMaxUnloadHooksCb } from "@microsoft/1ds-core-js";
import { Assert } from "@microsoft/ai-test-framework";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
2 changes: 2 additions & 0 deletions channels/1ds-post-js/test/Unit/src/post.unittests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { HttpManagerTest } from './HttpManagerTest';
import { KillSwitchTest } from './KillSwitchTest';
import { SerializerTest } from './SerializerTest';
import { FileSizeCheckTest } from "./FileSizeCheckTest"
import { GlobalTestHooks } from './GlobalTestHooks.Test';

export function registerTests() {
new GlobalTestHooks().registerTests();
new PostChannelTest("PostChannelTest").registerTests();
new HttpManagerTest("HttpManagerTest").registerTests();
new HttpManagerTest("HttpManagerTest", true).registerTests();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Assert } from "@microsoft/ai-test-framework";
import { _testHookMaxUnloadHooksCb } from "@microsoft/applicationinsights-core-js";
import { dumpObj } from "@nevware21/ts-utils";

export class GlobalTestHooks {

public registerTests() {
// Set a global maximum
_testHookMaxUnloadHooksCb(20, (state: string, hooks: Array<any>) => {
Assert.ok(false, "Max unload hooks exceeded [" + hooks.length + "] - " + state + " - " + dumpObj(hooks));
});
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { SenderTests } from "./Sender.tests";
import { SampleTests } from "./Sample.tests";
import { GlobalTestHooks } from "./GlobalTestHooks.Test";

export function runTests() {
new GlobalTestHooks().registerTests();
new SenderTests().registerTests();
new SampleTests().registerTests();
}
8 changes: 4 additions & 4 deletions channels/applicationinsights-channel-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/applicationinsights-channel-js",
"version": "3.1.0",
"version": "3.1.2",
"description": "Microsoft Application Insights JavaScript SDK Channel",
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
"author": "Microsoft Application Insights Team",
Expand Down Expand Up @@ -53,9 +53,9 @@
"dependencies": {
"@microsoft/dynamicproto-js": "^2.0.3",
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/applicationinsights-core-js": "3.1.0",
"@microsoft/applicationinsights-common": "3.1.0",
"@nevware21/ts-utils": ">= 0.10.5 < 2.x",
"@microsoft/applicationinsights-core-js": "3.1.2",
"@microsoft/applicationinsights-common": "3.1.2",
"@nevware21/ts-utils": ">= 0.11.0 < 2.x",
"@nevware21/ts-async": ">= 0.3.0 < 2.x"
},
"license": "MIT"
Expand Down
10 changes: 7 additions & 3 deletions channels/applicationinsights-channel-js/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,20 @@ export interface ISenderConfig {
* [Optional] Either an array or single value identifying the requested TransportType type that should be used.
* This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided.
*/
transports?: number | number[];
transports?: number | number[];

/**
* [Optional] Either an array or single value identifying the requested TransportType type(s) that should be used during unload or events
* marked as sendBeacon. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride
* is provided and alwaysUseXhrOverride is true.
*/
unloadTransports?: number | number[];
unloadTransports?: number | number[];


/**
* (Optional) The specific error codes that will cause a retry of sending data to the backend.
* @since 3.1.1
*/
retryCodes?: number[];
}

export interface IBackendResponse {
Expand Down
13 changes: 11 additions & 2 deletions channels/applicationinsights-channel-js/src/Sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const defaultAppInsightsChannelConfig: IConfigDefaults<ISenderConfig> = objDeepF
bufferOverride: false,
httpXHROverride: { isVal: isOverrideFn, v:UNDEFINED_VALUE },
alwaysUseXhrOverride: cfgDfBoolean(),
transports: UNDEFINED_VALUE
transports: UNDEFINED_VALUE,
retryCodes: UNDEFINED_VALUE
});

function _chkSampling(value: number) {
Expand Down Expand Up @@ -176,6 +177,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControls {
let _fallbackSend: SenderFunction;
let _disableBeaconSplit: boolean;
let _sendPostMgr: SenderPostManager;
let _retryCodes: number[];

dynamicProto(Sender, this, (_self, _base) => {

Expand Down Expand Up @@ -289,6 +291,7 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControls {

_alwaysUseCustomSend = senderConfig.alwaysUseXhrOverride;
_disableXhr = !!senderConfig.disableXhr;
_retryCodes = senderConfig.retryCodes;

let bufferOverride = senderConfig.bufferOverride;
let canUseSessionStorage = !!senderConfig.enableSessionStorageBuffer &&
Expand Down Expand Up @@ -1116,8 +1119,14 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControls {
* @param statusCode
*/
function _isRetriable(statusCode: number): boolean {
// retryCodes = [] means should not retry
if (!isNullOrUndefined(_retryCodes)) {
return _retryCodes.length && _retryCodes.indexOf(statusCode) > -1;
}

return statusCode === 401 // Unauthorized
|| statusCode === 403 // Forbidden
// Removing as private links can return a 403 which causes excessive retries and session storage usage
// || statusCode === 403 // Forbidden
|| statusCode === 408 // Timeout
|| statusCode === 429 // Too many requests.
|| statusCode === 500 // Internal server error.
Expand Down
Loading

0 comments on commit fc2f9d6

Please sign in to comment.