From 2a1c332f7039eb3e13711a0fa3732541c562b58f Mon Sep 17 00:00:00 2001 From: siyuniu-ms <123212536+siyuniu-ms@users.noreply.github.com> Date: Wed, 3 Apr 2024 01:40:22 -0700 Subject: [PATCH] [main] implement Osplugin, extracting windows 11 info and put into telemetry (#2294) --- .aiAutoMinify.json | 3 + AISKU/Tests/Manual/testVersionConflict.html | 26 +- AISKU/typedoc.json | 2 +- .../Tests/Unit/src/AISKULightSize.Tests.ts | 4 +- AISKULight/typedoc.json | 2 +- .../Tests/Unit/src/Sender.tests.ts | 7 +- .../src/EnvelopeCreator.ts | 1 + .../typedoc.json | 2 +- channels/offline-channel-js/typedoc.json | 2 +- channels/tee-channel-js/typedoc.json | 2 +- common/config/rush/npm-shrinkwrap.json | 305 +++++++------- docs/webSdk/README.md | 2 + .../typedoc.json | 2 +- .../typedoc.json | 2 +- .../typedoc.json | 2 +- .../typedoc.json | 2 +- .../typedoc.json | 2 +- .../.npmignore | 21 + .../applicationinsights-osplugin-js/README.md | 81 ++++ .../Tests/Unit/src/OsPluginTest.ts | 390 ++++++++++++++++++ .../src/applicationinsights-osplugin.tests.ts | 7 + .../Tests/UnitTests.html | 45 ++ .../Tests/tsconfig.json | 13 + .../api-extractor.json | 361 ++++++++++++++++ .../package.json | 56 +++ .../rollup.config.js | 37 ++ .../src/DataModels.ts | 28 ++ .../src/OsPlugin.ts | 262 ++++++++++++ .../src/applicationinsights-osplugin-js.ts | 7 + .../tsconfig.json | 28 ++ .../typedoc.json | 62 +++ .../typedoc.json | 2 +- .../typedoc.json | 2 +- gruntfile.js | 10 + rush.json | 5 + shared/AppInsightsCommon/typedoc.json | 2 +- .../typedoc.json | 2 +- tools/release-tools/package_groups.json | 2 + version.json | 4 + 39 files changed, 1629 insertions(+), 166 deletions(-) create mode 100644 extensions/applicationinsights-osplugin-js/.npmignore create mode 100644 extensions/applicationinsights-osplugin-js/README.md create mode 100644 extensions/applicationinsights-osplugin-js/Tests/Unit/src/OsPluginTest.ts create mode 100644 extensions/applicationinsights-osplugin-js/Tests/Unit/src/applicationinsights-osplugin.tests.ts create mode 100644 extensions/applicationinsights-osplugin-js/Tests/UnitTests.html create mode 100644 extensions/applicationinsights-osplugin-js/Tests/tsconfig.json create mode 100644 extensions/applicationinsights-osplugin-js/api-extractor.json create mode 100644 extensions/applicationinsights-osplugin-js/package.json create mode 100644 extensions/applicationinsights-osplugin-js/rollup.config.js create mode 100644 extensions/applicationinsights-osplugin-js/src/DataModels.ts create mode 100644 extensions/applicationinsights-osplugin-js/src/OsPlugin.ts create mode 100644 extensions/applicationinsights-osplugin-js/src/applicationinsights-osplugin-js.ts create mode 100644 extensions/applicationinsights-osplugin-js/tsconfig.json create mode 100644 extensions/applicationinsights-osplugin-js/typedoc.json diff --git a/.aiAutoMinify.json b/.aiAutoMinify.json index e7c503172..aa6199cf1 100644 --- a/.aiAutoMinify.json +++ b/.aiAutoMinify.json @@ -102,6 +102,9 @@ "eStorageProviders", "ValueQueryType" ] + }, + "@microsoft/applicationinsights-osplugin-js": { + "constEnums": [] } } } \ No newline at end of file diff --git a/AISKU/Tests/Manual/testVersionConflict.html b/AISKU/Tests/Manual/testVersionConflict.html index de9b6ca32..f055cc11d 100644 --- a/AISKU/Tests/Manual/testVersionConflict.html +++ b/AISKU/Tests/Manual/testVersionConflict.html @@ -1,20 +1,30 @@ + AISKU Sample - - - - - - + +

Microsoft Application Insights JavaScript SDK - AISKU

diff --git a/AISKU/typedoc.json b/AISKU/typedoc.json index f746d4177..6393e1991 100644 --- a/AISKU/typedoc.json +++ b/AISKU/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/AISKU/README.md" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/AISKULight/Tests/Unit/src/AISKULightSize.Tests.ts b/AISKULight/Tests/Unit/src/AISKULightSize.Tests.ts index 23eb2be78..ddee291c9 100644 --- a/AISKULight/Tests/Unit/src/AISKULightSize.Tests.ts +++ b/AISKULight/Tests/Unit/src/AISKULightSize.Tests.ts @@ -2,8 +2,8 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework"; 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_SIZE = 87; + private readonly MAX_BUNDLE_SIZE = 87; private readonly MAX_RAW_DEFLATE_SIZE = 36; private readonly MAX_BUNDLE_DEFLATE_SIZE = 36; private readonly rawFilePath = "../dist/es5/applicationinsights-web-basic.min.js"; diff --git a/AISKULight/typedoc.json b/AISKULight/typedoc.json index 7ac9ee884..4dc2e566b 100644 --- a/AISKULight/typedoc.json +++ b/AISKULight/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/AISKULight/README.md" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts b/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts index 1e91a7086..dafa3ac01 100644 --- a/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts +++ b/channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts @@ -2533,8 +2533,10 @@ export class SenderTests extends AITestClass { device: { deviceClass: "Browser", localId: "browser" + }, + os: { + osVer: "Windows11" } - }, tags: [{"ai.internal.sdkVersion": "javascript:2.5.1"}], data: { @@ -2580,6 +2582,9 @@ export class SenderTests extends AITestClass { QUnit.assert.ok(appInsightsEnvelope.tags); QUnit.assert.equal("d041d2e5fa834b4f9eee41ac163bf402", appInsightsEnvelope.tags["ai.session.id"]); QUnit.assert.equal("browser", appInsightsEnvelope.tags["ai.device.id"]); + QUnit.assert.equal("browser", appInsightsEnvelope.tags["ai.device.id"]); + QUnit.assert.equal("Windows11", appInsightsEnvelope.tags["ai.device.osVersion"]); + QUnit.assert.equal("Browser", appInsightsEnvelope.tags["ai.device.type"]); QUnit.assert.equal("javascript:2.5.1", appInsightsEnvelope.tags["ai.internal.sdkVersion"]); diff --git a/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts b/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts index 1da6a2af1..b843672f8 100644 --- a/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts +++ b/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts @@ -67,6 +67,7 @@ function _extractPartAExtensions(logger: IDiagnosticLogger, item: ITelemetryItem let extOs = itmExt.os; if (extOs) { _setValueIf(envTags, CtxTagKeys.deviceOS, extOs.name); + _setValueIf(envTags, CtxTagKeys.deviceOSVersion, extOs.osVer); } // No support for mapping Trace.traceState to 2.0 as it is currently empty diff --git a/channels/applicationinsights-channel-js/typedoc.json b/channels/applicationinsights-channel-js/typedoc.json index 6c2d255d8..14af0e3b4 100644 --- a/channels/applicationinsights-channel-js/typedoc.json +++ b/channels/applicationinsights-channel-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/channels/applicationinsights-channel-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/channels/offline-channel-js/typedoc.json b/channels/offline-channel-js/typedoc.json index 491c6de2f..3b1c9981b 100644 --- a/channels/offline-channel-js/typedoc.json +++ b/channels/offline-channel-js/typedoc.json @@ -46,7 +46,7 @@ }, "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", - "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/channels/offline-channel-js", + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/channels/offline-channel-js", }, "navigationLinks": { "GitHub": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/channels/offline-channel-js", diff --git a/channels/tee-channel-js/typedoc.json b/channels/tee-channel-js/typedoc.json index be26bef9f..6f7c3fb33 100644 --- a/channels/tee-channel-js/typedoc.json +++ b/channels/tee-channel-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/channels/tee-channel-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index 136780f3a..8b0587d0f 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -35,6 +35,7 @@ "@rush-temp/applicationinsights-example-shared-worker": "file:./projects/applicationinsights-example-shared-worker.tgz", "@rush-temp/applicationinsights-js-release-tools": "file:./projects/applicationinsights-js-release-tools.tgz", "@rush-temp/applicationinsights-offlinechannel-js": "file:./projects/applicationinsights-offlinechannel-js.tgz", + "@rush-temp/applicationinsights-osplugin-js": "file:./projects/applicationinsights-osplugin-js.tgz", "@rush-temp/applicationinsights-perfmarkmeasure-js": "file:./projects/applicationinsights-perfmarkmeasure-js.tgz", "@rush-temp/applicationinsights-properties-js": "file:./projects/applicationinsights-properties-js.tgz", "@rush-temp/applicationinsights-rollup-es5": "file:./projects/applicationinsights-rollup-es5.tgz", @@ -285,9 +286,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "peer": true }, "node_modules/@jridgewell/sourcemap-codec": { @@ -408,17 +409,17 @@ } }, "node_modules/@nevware21/ts-async": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.5.0.tgz", - "integrity": "sha512-fJ2wSl5fd4UWoWbnXpPVKRg2Uw6u4+o9RsBHb35tiaOajVxJ97LrKAtrCGi6E19GpgfQbAWRFvz/iDXe3XCjWQ==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.4.0.tgz", + "integrity": "sha512-dbV826TTehQIBIJjh8GDSbwn1Z6+cnkyNbRlpcpdBPH8mROD2zabIUKqWcw9WRdTjjUIm21K+OR4DXWlAyOVTQ==", "dependencies": { - "@nevware21/ts-utils": ">= 0.11.0 < 2.x" + "@nevware21/ts-utils": ">= 0.10.0 < 2.x" } }, "node_modules/@nevware21/ts-utils": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.11.1.tgz", - "integrity": "sha512-1QZSZ39UzjC8MR0+LRO2l8ITFHYdCZeHfBG9p3XUCz0hQ22I0Pf/XE5EF+TPSJK3LLME3pUNx2MCQ4XEtOHv+g==" + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.11.0.tgz", + "integrity": "sha512-3yrohCSKYBLKrW41fYkZorN2rf9GYr/4Cb4Xu9fWCyXgVDyt1uLgMaCinhx0kEkEUfME3Smqs+2itJRhXgCo8Q==" }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", @@ -1014,6 +1015,27 @@ "typescript": "^4.9.3" } }, + "node_modules/@rush-temp/applicationinsights-osplugin-js": { + "version": "0.0.0", + "resolved": "file:projects/applicationinsights-osplugin-js.tgz", + "integrity": "sha512-ny6VsvgAUdQPjUtzZMhLl0uNvDr3vWGw2R05WITvIWwQ9+F5qpxsqv4kGYLiF7NIOimSVJ5wNPWk64wM6wFmng==", + "dependencies": { + "@microsoft/api-extractor": "^7.40.0", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-async": ">= 0.3.0 < 2.x", + "@nevware21/ts-utils": ">= 0.11.0 < 2.x", + "@rollup/plugin-commonjs": "^24.0.0", + "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-replace": "^5.0.2", + "@types/sinon": "4.3.3", + "globby": "^11.0.0", + "grunt": "^1.5.3", + "rollup": "^3.20.0", + "rollup-plugin-cleanup": "^3.2.1", + "sinon": "^7.3.1", + "typescript": "^4.9.3" + } + }, "node_modules/@rush-temp/applicationinsights-perfmarkmeasure-js": { "version": "0.0.0", "resolved": "file:projects/applicationinsights-perfmarkmeasure-js.tgz", @@ -1546,16 +1568,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.5.0.tgz", - "integrity": "sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz", + "integrity": "sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==", "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/type-utils": "7.5.0", - "@typescript-eslint/utils": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/scope-manager": "7.4.0", + "@typescript-eslint/type-utils": "7.4.0", + "@typescript-eslint/utils": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -1581,15 +1603,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.5.0.tgz", - "integrity": "sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.4.0.tgz", + "integrity": "sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==", "peer": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/typescript-estree": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/scope-manager": "7.4.0", + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/typescript-estree": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4" }, "engines": { @@ -1609,13 +1631,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.5.0.tgz", - "integrity": "sha512-Z1r7uJY0MDeUlql9XJ6kRVgk/sP11sr3HKXn268HZyqL7i4cEfrdFuSSY/0tUqT37l5zT0tJOsuDP16kio85iA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz", + "integrity": "sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw==", "peer": true, "dependencies": { - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0" + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -1626,13 +1648,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.5.0.tgz", - "integrity": "sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz", + "integrity": "sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==", "peer": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.5.0", - "@typescript-eslint/utils": "7.5.0", + "@typescript-eslint/typescript-estree": "7.4.0", + "@typescript-eslint/utils": "7.4.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1653,9 +1675,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.5.0.tgz", - "integrity": "sha512-tv5B4IHeAdhR7uS4+bf8Ov3k793VEVHd45viRRkehIUZxm0WF82VPiLgHzA/Xl4TGPg1ZD49vfxBKFPecD5/mg==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.4.0.tgz", + "integrity": "sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw==", "peer": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -1666,13 +1688,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.5.0.tgz", - "integrity": "sha512-YklQQfe0Rv2PZEueLTUffiQGKQneiIEKKnfIqPIOxgM9lKSZFCjT5Ad4VqRKj/U4+kQE3fa8YQpskViL7WjdPQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz", + "integrity": "sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==", "peer": true, "dependencies": { - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1718,17 +1740,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.5.0.tgz", - "integrity": "sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.4.0.tgz", + "integrity": "sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==", "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/typescript-estree": "7.5.0", + "@typescript-eslint/scope-manager": "7.4.0", + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/typescript-estree": "7.4.0", "semver": "^7.5.4" }, "engines": { @@ -1743,12 +1765,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.5.0.tgz", - "integrity": "sha512-mcuHM/QircmA6O7fy6nn2w/3ditQkj+SgtOc8DW3uQ10Yfj42amm2i+6F2K4YAOPNNTmE6iM1ynM6lrSwdendA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz", + "integrity": "sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA==", "peer": true, "dependencies": { - "@typescript-eslint/types": "7.5.0", + "@typescript-eslint/types": "7.4.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -2181,9 +2203,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001605", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001605.tgz", - "integrity": "sha512-nXwGlFWo34uliI9z3n6Qc0wZaf7zaZWA1CPZ169La5mV3I/gem7bst0vr5XQH5TJXZIMfDeZyOrZnSlVzKxxHQ==", + "version": "1.0.30001600", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001600.tgz", + "integrity": "sha512-+2S9/2JFhYmYaDpZvo0lKkfvuKIglrx68MwOBqMGHhQsNkLjB5xtc/TGoEPs+MxjSyN/72qer2g97nzR641mOQ==", "funding": [ { "type": "opencollective", @@ -2577,9 +2599,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.723", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.723.tgz", - "integrity": "sha512-rxFVtrMGMFROr4qqU6n95rUi9IlfIm+lIAt+hOToy/9r6CDv0XiEcQdC3VP71y1pE5CFTzKV0RvxOGYCPWWHPw==" + "version": "1.4.717", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.717.tgz", + "integrity": "sha512-6Fmg8QkkumNOwuZ/5mIbMU9WI3H2fmn5ajcVya64I5Yr5CcNmO7vcLt0Y7c96DCiMO5/9G+4sI2r6eEvdg1F7A==" }, "node_modules/encodeurl": { "version": "1.0.2", @@ -3172,19 +3194,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -5928,9 +5937,9 @@ } }, "node_modules/typedoc/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -6434,9 +6443,9 @@ "peer": true }, "@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "peer": true }, "@jridgewell/sourcemap-codec": { @@ -6531,17 +6540,17 @@ "requires": {} }, "@nevware21/ts-async": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.5.0.tgz", - "integrity": "sha512-fJ2wSl5fd4UWoWbnXpPVKRg2Uw6u4+o9RsBHb35tiaOajVxJ97LrKAtrCGi6E19GpgfQbAWRFvz/iDXe3XCjWQ==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.4.0.tgz", + "integrity": "sha512-dbV826TTehQIBIJjh8GDSbwn1Z6+cnkyNbRlpcpdBPH8mROD2zabIUKqWcw9WRdTjjUIm21K+OR4DXWlAyOVTQ==", "requires": { - "@nevware21/ts-utils": ">= 0.11.0 < 2.x" + "@nevware21/ts-utils": ">= 0.10.0 < 2.x" } }, "@nevware21/ts-utils": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.11.1.tgz", - "integrity": "sha512-1QZSZ39UzjC8MR0+LRO2l8ITFHYdCZeHfBG9p3XUCz0hQ22I0Pf/XE5EF+TPSJK3LLME3pUNx2MCQ4XEtOHv+g==" + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.11.0.tgz", + "integrity": "sha512-3yrohCSKYBLKrW41fYkZorN2rf9GYr/4Cb4Xu9fWCyXgVDyt1uLgMaCinhx0kEkEUfME3Smqs+2itJRhXgCo8Q==" }, "@nodelib/fs.scandir": { "version": "2.1.5", @@ -7064,6 +7073,26 @@ "typescript": "^4.9.3" } }, + "@rush-temp/applicationinsights-osplugin-js": { + "version": "file:projects\\applicationinsights-osplugin-js.tgz", + "integrity": "sha512-ny6VsvgAUdQPjUtzZMhLl0uNvDr3vWGw2R05WITvIWwQ9+F5qpxsqv4kGYLiF7NIOimSVJ5wNPWk64wM6wFmng==", + "requires": { + "@microsoft/api-extractor": "^7.40.0", + "@microsoft/dynamicproto-js": "^2.0.3", + "@nevware21/ts-async": ">= 0.3.0 < 2.x", + "@nevware21/ts-utils": ">= 0.11.0 < 2.x", + "@rollup/plugin-commonjs": "^24.0.0", + "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-replace": "^5.0.2", + "@types/sinon": "4.3.3", + "globby": "^11.0.0", + "grunt": "^1.5.3", + "rollup": "^3.20.0", + "rollup-plugin-cleanup": "^3.2.1", + "sinon": "^7.3.1", + "typescript": "^4.9.3" + } + }, "@rush-temp/applicationinsights-perfmarkmeasure-js": { "version": "file:projects\\applicationinsights-perfmarkmeasure-js.tgz", "integrity": "sha512-qsqW5OIUFHCJ7RGXHRj4svPnocbxq5+UEgzzWXRtBiNIcUCTzG1Fe6ROwUfmLUJbId96dGTD91MY9cmZwSVT5Q==", @@ -7560,16 +7589,16 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.5.0.tgz", - "integrity": "sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz", + "integrity": "sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==", "peer": true, "requires": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/type-utils": "7.5.0", - "@typescript-eslint/utils": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/scope-manager": "7.4.0", + "@typescript-eslint/type-utils": "7.4.0", + "@typescript-eslint/utils": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -7579,54 +7608,54 @@ } }, "@typescript-eslint/parser": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.5.0.tgz", - "integrity": "sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.4.0.tgz", + "integrity": "sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==", "peer": true, "requires": { - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/typescript-estree": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/scope-manager": "7.4.0", + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/typescript-estree": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.5.0.tgz", - "integrity": "sha512-Z1r7uJY0MDeUlql9XJ6kRVgk/sP11sr3HKXn268HZyqL7i4cEfrdFuSSY/0tUqT37l5zT0tJOsuDP16kio85iA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz", + "integrity": "sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw==", "peer": true, "requires": { - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0" + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0" } }, "@typescript-eslint/type-utils": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.5.0.tgz", - "integrity": "sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz", + "integrity": "sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==", "peer": true, "requires": { - "@typescript-eslint/typescript-estree": "7.5.0", - "@typescript-eslint/utils": "7.5.0", + "@typescript-eslint/typescript-estree": "7.4.0", + "@typescript-eslint/utils": "7.4.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" } }, "@typescript-eslint/types": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.5.0.tgz", - "integrity": "sha512-tv5B4IHeAdhR7uS4+bf8Ov3k793VEVHd45viRRkehIUZxm0WF82VPiLgHzA/Xl4TGPg1ZD49vfxBKFPecD5/mg==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.4.0.tgz", + "integrity": "sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw==", "peer": true }, "@typescript-eslint/typescript-estree": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.5.0.tgz", - "integrity": "sha512-YklQQfe0Rv2PZEueLTUffiQGKQneiIEKKnfIqPIOxgM9lKSZFCjT5Ad4VqRKj/U4+kQE3fa8YQpskViL7WjdPQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz", + "integrity": "sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==", "peer": true, "requires": { - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/visitor-keys": "7.5.0", + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/visitor-keys": "7.4.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -7656,27 +7685,27 @@ } }, "@typescript-eslint/utils": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.5.0.tgz", - "integrity": "sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.4.0.tgz", + "integrity": "sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==", "peer": true, "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.5.0", - "@typescript-eslint/types": "7.5.0", - "@typescript-eslint/typescript-estree": "7.5.0", + "@typescript-eslint/scope-manager": "7.4.0", + "@typescript-eslint/types": "7.4.0", + "@typescript-eslint/typescript-estree": "7.4.0", "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.5.0.tgz", - "integrity": "sha512-mcuHM/QircmA6O7fy6nn2w/3ditQkj+SgtOc8DW3uQ10Yfj42amm2i+6F2K4YAOPNNTmE6iM1ynM6lrSwdendA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz", + "integrity": "sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA==", "peer": true, "requires": { - "@typescript-eslint/types": "7.5.0", + "@typescript-eslint/types": "7.4.0", "eslint-visitor-keys": "^3.4.1" } }, @@ -7975,9 +8004,9 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" }, "caniuse-lite": { - "version": "1.0.30001605", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001605.tgz", - "integrity": "sha512-nXwGlFWo34uliI9z3n6Qc0wZaf7zaZWA1CPZ169La5mV3I/gem7bst0vr5XQH5TJXZIMfDeZyOrZnSlVzKxxHQ==" + "version": "1.0.30001600", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001600.tgz", + "integrity": "sha512-+2S9/2JFhYmYaDpZvo0lKkfvuKIglrx68MwOBqMGHhQsNkLjB5xtc/TGoEPs+MxjSyN/72qer2g97nzR641mOQ==" }, "chalk": { "version": "4.1.2", @@ -8267,9 +8296,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "electron-to-chromium": { - "version": "1.4.723", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.723.tgz", - "integrity": "sha512-rxFVtrMGMFROr4qqU6n95rUi9IlfIm+lIAt+hOToy/9r6CDv0XiEcQdC3VP71y1pE5CFTzKV0RvxOGYCPWWHPw==" + "version": "1.4.717", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.717.tgz", + "integrity": "sha512-6Fmg8QkkumNOwuZ/5mIbMU9WI3H2fmn5ajcVya64I5Yr5CcNmO7vcLt0Y7c96DCiMO5/9G+4sI2r6eEvdg1F7A==" }, "encodeurl": { "version": "1.0.2", @@ -8736,12 +8765,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, - "fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "optional": true - }, "function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -10796,9 +10819,9 @@ } }, "minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "requires": { "brace-expansion": "^2.0.1" } diff --git a/docs/webSdk/README.md b/docs/webSdk/README.md index ecede793f..659976a2b 100644 --- a/docs/webSdk/README.md +++ b/docs/webSdk/README.md @@ -33,6 +33,8 @@ Placeholder for auto-generated API documentation [Click Analytics extension](./applicationinsights-clickanalytics-js/index.html) +[OS Plugin extension](./applicationinsights-osplugin-js/index.html) + [Debug Plugin extension](./applicationinsights-debugplugin-js/index.html) [XHR dependencies plugin](./applicationinsights-dependencies-js/index.html) diff --git a/extensions/applicationinsights-analytics-js/typedoc.json b/extensions/applicationinsights-analytics-js/typedoc.json index 4b29b786c..3aea6c595 100644 --- a/extensions/applicationinsights-analytics-js/typedoc.json +++ b/extensions/applicationinsights-analytics-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-analytics-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/extensions/applicationinsights-cfgsync-js/typedoc.json b/extensions/applicationinsights-cfgsync-js/typedoc.json index 357647a00..7ed0d5c63 100644 --- a/extensions/applicationinsights-cfgsync-js/typedoc.json +++ b/extensions/applicationinsights-cfgsync-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-cfgsync-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/extensions/applicationinsights-clickanalytics-js/typedoc.json b/extensions/applicationinsights-clickanalytics-js/typedoc.json index 02acabee3..16f74cec4 100644 --- a/extensions/applicationinsights-clickanalytics-js/typedoc.json +++ b/extensions/applicationinsights-clickanalytics-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-clickanalytics-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/extensions/applicationinsights-debugplugin-js/typedoc.json b/extensions/applicationinsights-debugplugin-js/typedoc.json index 11e96752c..980f601ed 100644 --- a/extensions/applicationinsights-debugplugin-js/typedoc.json +++ b/extensions/applicationinsights-debugplugin-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-debugplugin-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/extensions/applicationinsights-dependencies-js/typedoc.json b/extensions/applicationinsights-dependencies-js/typedoc.json index f5a705427..6c87940d4 100644 --- a/extensions/applicationinsights-dependencies-js/typedoc.json +++ b/extensions/applicationinsights-dependencies-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-dependencies-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/extensions/applicationinsights-osplugin-js/.npmignore b/extensions/applicationinsights-osplugin-js/.npmignore new file mode 100644 index 000000000..df983f461 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/.npmignore @@ -0,0 +1,21 @@ +# NPM Ignore + +# ignore everything +* + +# ... but these files +!package.json +!tsconfig.json +!/CODE_OF_CONDUCT.md +!/CONTRIBUTING.md +!/README.md +!/SECURITY.md +!/SUPPORT.md +!/NOTICE +!/PRIVACY +!/LICENSE +!/LICENSE.TXT +!dist-es*/** +!dist/** +!browser/** +!types/** \ No newline at end of file diff --git a/extensions/applicationinsights-osplugin-js/README.md b/extensions/applicationinsights-osplugin-js/README.md new file mode 100644 index 000000000..da8f27113 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/README.md @@ -0,0 +1,81 @@ +# Microsoft Application Insights JavaScript SDK - Operating System Plugin + +[![GitHub Workflow Status (main)](https://img.shields.io/github/actions/workflow/status/microsoft/ApplicationInsights-JS/ci.yml?branch=main)](https://github.com/microsoft/ApplicationInsights-JS/tree/main) +[![Build Status](https://dev.azure.com/mseng/AppInsights/_apis/build/status%2FAppInsights%20-%20DevTools%2F1DS%20JavaScript%20SDK%20web%20SKU%20(main%3B%20master)?branchName=main)](https://dev.azure.com/mseng/AppInsights/_build/latest?definitionId=8184&branchName=main) +[![npm version](https://badge.fury.io/js/%40microsoft%2Fapplicationinsights-osplugin-js.svg)](https://badge.fury.io/js/%40microsoft%2Fapplicationinsights-osplugin-js) + +Microsoft Application Insights OS Plugin + +## Description +1DS OS Plugin provides the functionality to retrieve customers system version, such as "Windows 11". + +## NPM Setup (ignore if using Snippet Setup) + +Install npm package: + +```bash +npm install --save @microsoft/applicationinsights-osplugin-js @microsoft/applicationinsights-web +``` + +```js + +import { ApplicationInsights } from '@microsoft/applicationinsights-web'; +import {OsPlugin} from '@microsoft/applicationinsights-osplugin-js'; + +const osPlugin = new OsPlugin(); +const appInsights = new ApplicationInsights({ + config: { + connectionString: "YOUR_CONNECTION_STRING", + extensionConfig:{ + [osPlugin.identifier]: { + maxTimeout: 10000, + mergeOsNameVersion: true + }}, + extensions: [osPlugin] + } +}); +appInsights.loadAppInsights(); +appInsights.trackEvent({name: "testEvent", properties: {testProperty: "testValue"}}); + +``` +## Configuration + +| Name | Type | Default | Description | +|------|------|---------|-------------| +| maxTimeout | number[Optional]| 200 | Maximum time to wait for the OS plugin to return the OS information | +| mergeOsNameVersion | boolean[Optional] | false | Whether to merge the OS name and version into one field change details. | + + +## Run unit tests: +``` +npm run test +``` + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require you to +agree to a Contributor License Agreement (CLA) declaring that you have the right to, +and actually do, grant us the rights to use your contribution. For details, visit +https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need +to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the +instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + +## Data Collection + +As this SDK is designed to enable applications to perform data collection which is sent to the Microsoft collection endpoints the following is required to identify our privacy statement. + +The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices. + +## Trademarks + +This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft’s Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies. + +## License + +[MIT](LICENSE) \ No newline at end of file diff --git a/extensions/applicationinsights-osplugin-js/Tests/Unit/src/OsPluginTest.ts b/extensions/applicationinsights-osplugin-js/Tests/Unit/src/OsPluginTest.ts new file mode 100644 index 000000000..019ef3102 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/Tests/Unit/src/OsPluginTest.ts @@ -0,0 +1,390 @@ +/** + * @copyright Microsoft 2024 + */ + +import { Assert, AITestClass } from '@microsoft/ai-test-framework'; +import { IOSPluginConfiguration, OsPlugin } from '../../../src/applicationinsights-osplugin-js'; +import { createAsyncPromise, ResolvePromiseHandler, RejectPromiseHandler } from "@nevware21/ts-async"; +import {getWindow, AppInsightsCore, IChannelControls, ITelemetryPlugin, + IConfiguration, ITelemetryItem} from "@microsoft/applicationinsights-core-js"; + +const defaultmaxTimeout = 5000; +const _platformVersion = {"brands":[{"brand":"Chromium","version":"122"}, +{"brand":"Microsoft Edge","version":"122"}],"mobile":false,"platform":"Windows", +"platformVersion":"15.0.0"} +interface CustomNavigator extends Navigator { + userAgentData?: { + getHighEntropyValues?: (args: any[]) => Promise; + }; +} + +export class OsPluginTest extends AITestClass { + + private _config; + private _plugin: OsPlugin; + private _core: AppInsightsCore; + private _channelExtension: IChannelControls; + private _osConfig: IOSPluginConfiguration = { + maxTimeout: 6000, // set a big number to avoid timeout for test + mergeOsNameVersion: false + }; + private _testChannelPlugin: TestChannelPlugin; + + private _resolvedGetHighEntrophyPromise: ResolvePromiseHandler | undefined; + private _rejectedGetHighEntrophyPromise: RejectPromiseHandler | undefined; + private _channelSpy: any; + + public testInitialize() { + this._core = new AppInsightsCore(); + this._plugin = new OsPlugin(); + this._testChannelPlugin = new TestChannelPlugin(); + this._config = { + instrumentationKey: 'testIkey', + endpointUrl: 'testEndpoint', + extensionConfig: [] + }; + + let navigator = { + userAgentData: { + getHighEntropyValues: (args) => { + if (args[0] === "platformVersion") { + return createAsyncPromise((resolve, reject) => { + this._resolvedGetHighEntrophyPromise = resolve; + this._rejectedGetHighEntrophyPromise = reject; + }); + } + } + } + } as CustomNavigator; + + this.setNavigator(navigator, true); + + this._channelSpy = this.sandbox.spy(this._testChannelPlugin, 'processTelemetry'); + + } + + public testFinishedCleanup(): void { + let window = getWindow(); + let sessionStorage = window.sessionStorage; + sessionStorage.clear(); + if (this._core && this._core.isInitialized()) { + this._core.unload(false); + } + } + + public registerTests() { + this.testCase({ + name: "OsPlugin: Dynamic and Default Configuration Tests", + useFakeTimers: true, + test: () => { + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + config.extensionConfig[this._plugin.identifier] = this._osConfig; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + this.clock.tick(100); + Assert.deepEqual(this._osConfig.maxTimeout, this._core.config.extensionConfig[this._plugin.identifier].maxTimeout, "maxTimeout should be changed"); + } + }); + + this.testCase({ + name: "OsPlugin: Events will be queued if OS is not available and will be sent after timeout", + useFakeTimers: true, + test: () => { + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + let event = { + name: 'testEvent', + baseType: 'testBaseType', + baseData: {} + }; + this._core.track(event); + Assert.equal(this._channelSpy.called, false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1][0].item.name, event.name); + this.clock.tick(defaultmaxTimeout); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._channelSpy.called, true); + } + }); + + this.testCase({ + name: "OsPlugin: Can get OS version from user agent and release the queue", + useFakeTimers: true, + test: () => { + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + config.extensionConfig[this._plugin.identifier] = this._osConfig; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + let event = { + name: 'testEvent', + baseType: 'testBaseType', + baseData: {} + }; + this._core.track(event); + Assert.equal(this._channelSpy.called, false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1][0].item.name, event.name); + this._resolvedGetHighEntrophyPromise(_platformVersion); + this.clock.tick(1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._channelSpy.called, true); + let telemetry = this._channelSpy.getCall(0).args[0]; + console.log("telemetry", JSON.stringify(telemetry)); + Assert.equal(JSON.stringify(telemetry).includes("osVer"), true, "before timeout, get os version"); + Assert.deepEqual(telemetry.ext.os.os, _platformVersion.platform, "OS should be changed"); + Assert.deepEqual(telemetry.ext.os.osVer, 11, "windows 11 is detected"); + } + }); + + this.testCase({ + name: "OsPlugin: Get reject from navigator, queue is released", + useFakeTimers: true, + test: () => { + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + config.extensionConfig[this._plugin.identifier] = this._osConfig; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + let event = { + name: 'testEvent', + baseType: 'testBaseType', + baseData: {} + }; + this._core.track(event); + Assert.equal(this._channelSpy.called, false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1][0].item.name, event.name); + this._rejectedGetHighEntrophyPromise(new Error("error")); + this.clock.tick(1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + } + }); + + this.testCase({ + name: "OsPlugin: Get OS version wait for too long, timeout will release the queue", + useFakeTimers: true, + test: () => { + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + config.extensionConfig[this._plugin.identifier] = { + maxTimeout: 1000 + };; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + let event = { + name: 'testEvent', + baseType: 'testBaseType', + baseData: {} + }; + this._core.track(event); + Assert.equal(this._channelSpy.called, false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1][0].item.name, event.name); + this.clock.tick(500); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + this.clock.tick(500); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._channelSpy.called, true); + let telemetry = this._channelSpy.getCall(0).args[0]; + Assert.equal(JSON.stringify(telemetry).includes("osVer"), false, "timeout would not get os version"); + } + }); + + this.testCase({ + name: "OsPlugin: If first telemetry didn't get the OS version, the following telemetry will not try again", + useFakeTimers: true, + test: () => { + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + config.extensionConfig[this._plugin.identifier] = { + maxTimeout: 1000, + mergeOsNameVersion: false + };; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + let event = { + name: 'testEvent', + baseType: 'testBaseType', + baseData: {} + }; + this._core.track(event); + Assert.equal(this._channelSpy.called, false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1][0].item.name, event.name); + this.clock.tick(1200); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._channelSpy.called, true); + let telemetry = this._channelSpy.getCall(0).args[0]; + Assert.equal(JSON.stringify(telemetry).includes("osVer"), false, "timeout would not get os version"); + + // send another event + this._core.track(event); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + this._resolvedGetHighEntrophyPromise(_platformVersion); + this.clock.tick(1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._channelSpy.called, true); + telemetry = this._channelSpy.getCall(0).args[0]; + Assert.equal(JSON.stringify(telemetry).includes("osVer"), false, "second event should not attempt to get os version"); + } + }); + + this.testCase({ + name: "OsPlugin: If first telemetryget the OS version, the following telemetry do not need to try again", + useFakeTimers: true, + test: () => { + let window = getWindow(); + let sessionStorage = window.sessionStorage; + QUnit.assert.ok(sessionStorage, "sessionStorage API is supported"); + sessionStorage.clear(); + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + config.extensionConfig[this._plugin.identifier] = { + maxTimeout: 1000, + mergeOsNameVersion: false + }; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + let event = { + name: 'testEvent', + baseType: 'testBaseType', + baseData: {} + }; + this._core.track(event); + Assert.equal(this._channelSpy.called, false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1][0].item.name, event.name); + this._resolvedGetHighEntrophyPromise(_platformVersion); + this.clock.tick(1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._channelSpy.called, true); + let telemetry = this._channelSpy.getCall(0).args[0]; + Assert.deepEqual(telemetry.ext.os.os, _platformVersion.platform, "OS should be changed"); + Assert.deepEqual(telemetry.ext.os.osVer, 11, "windows 11 is detected"); + let storedOs = JSON.parse(sessionStorage.getItem("ai_osplugin")); + QUnit.assert.equal(storedOs.platform, _platformVersion.platform, "os is stored in session storage"); + QUnit.assert.equal(storedOs.platformVersion, 11, "os ver is stored in session storage"); + // send another event + this._core.track(event); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._channelSpy.called, true); + telemetry = this._channelSpy.getCall(0).args[0]; + Assert.equal(JSON.stringify(telemetry).includes("osVer"), true, "before timeout, get os version"); + Assert.deepEqual(telemetry.ext.os.os, _platformVersion.platform, "OS should be changed"); + Assert.deepEqual(telemetry.ext.os.osVer, 11, "Windows 11 is detected"); + } + }); + + this.testCase({ + name: "OsPlugin: test merged version", + useFakeTimers: true, + test: () => { + let window = getWindow(); + let sessionStorage = window.sessionStorage; + QUnit.assert.ok(sessionStorage, "sessionStorage API is supported"); + sessionStorage.clear(); + let config = this._config; + let plugin = this._plugin; + config.extensionConfig = this._config.extensionConfig || {}; + config.extensionConfig[this._plugin.identifier] = { + maxTimeout: 1000, + mergeOsNameVersion: true + }; + this._core.initialize(config, [plugin, this._testChannelPlugin]); + let event = { + name: 'testEvent', + baseType: 'testBaseType', + baseData: {} + }; + this._core.track(event); + Assert.equal(this._channelSpy.called, false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], true); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1][0].item.name, event.name); + this._resolvedGetHighEntrophyPromise(_platformVersion); + this.clock.tick(1); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._channelSpy.called, true); + let telemetry = this._channelSpy.getCall(0).args[0]; + Assert.deepEqual(telemetry.ext.os.osVer, "Windows11", "windows 11 is detected"); + let storedOs = JSON.parse(sessionStorage.getItem("ai_osplugin")); + QUnit.assert.equal(storedOs.platform, _platformVersion.platform, "os is stored in session storage"); + QUnit.assert.equal(storedOs.platformVersion, 11, "os ver is stored in session storage"); + // send another event + this._core.track(event); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[2], false); + Assert.equal(this._plugin["_getDbgPlgTargets"]()[1].length, 0); + Assert.equal(this._channelSpy.called, true); + telemetry = this._channelSpy.getCall(0).args[0]; + Assert.equal(JSON.stringify(telemetry).includes("osVer"), true, "before timeout, get os version"); + Assert.deepEqual(telemetry.ext.os.osVer, "Windows11", "windows 11 is detected"); + } + }); + } +} + +class TestChannelPlugin implements IChannelControls { + + public isFlushInvoked = false; + public isUnloadInvoked = false; + public isTearDownInvoked = false; + public isResumeInvoked = false; + public isPauseInvoked = false; + + constructor() { + this.processTelemetry = this._processTelemetry.bind(this); + } + public pause(): void { + this.isPauseInvoked = true; + } + + public resume(): void { + this.isResumeInvoked = true; + } + + public teardown(): void { + this.isTearDownInvoked = true; + } + + flush(async?: boolean, callBack?: () => void): void { + this.isFlushInvoked = true; + if (callBack) { + callBack(); + } + } + + public processTelemetry; + + public identifier = "Sender"; + + setNextPlugin(next: ITelemetryPlugin) { + // no next setup + } + + public priority: number = 1001; + + public initialize = (config: IConfiguration) => { + } + + private _processTelemetry(env: ITelemetryItem) { + } +} diff --git a/extensions/applicationinsights-osplugin-js/Tests/Unit/src/applicationinsights-osplugin.tests.ts b/extensions/applicationinsights-osplugin-js/Tests/Unit/src/applicationinsights-osplugin.tests.ts new file mode 100644 index 000000000..da41a7213 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/Tests/Unit/src/applicationinsights-osplugin.tests.ts @@ -0,0 +1,7 @@ +import { OsPluginTest } from './OsPluginTest'; + +export function runTests() { + new OsPluginTest().registerTests(); +} + +runTests(); \ No newline at end of file diff --git a/extensions/applicationinsights-osplugin-js/Tests/UnitTests.html b/extensions/applicationinsights-osplugin-js/Tests/UnitTests.html new file mode 100644 index 000000000..0b1ff637d --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/Tests/UnitTests.html @@ -0,0 +1,45 @@ + + + + + + + Tests for Application Insights JavaScript API + + + + + + + + + +
+
+
+ + + \ No newline at end of file diff --git a/extensions/applicationinsights-osplugin-js/Tests/tsconfig.json b/extensions/applicationinsights-osplugin-js/Tests/tsconfig.json new file mode 100644 index 000000000..d1b20db2c --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/Tests/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "sourceMap": true, + "inlineSources": true, + "noImplicitAny": false, + "module": "amd", + "moduleResolution": "Node", + "target": "es5", + "alwaysStrict": true, + "declaration": true + }, + "files": [] +} \ No newline at end of file diff --git a/extensions/applicationinsights-osplugin-js/api-extractor.json b/extensions/applicationinsights-osplugin-js/api-extractor.json new file mode 100644 index 000000000..ec9bfbd37 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/api-extractor.json @@ -0,0 +1,361 @@ +/** + * Config file for API Extractor. For more info, please visit: https://api-extractor.com + */ + { + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + + /** + * Optionally specifies another JSON config file that this file extends from. This provides a way for + * standard settings to be shared across multiple projects. + * + * If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains + * the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be + * resolved using NodeJS require(). + * + * SUPPORTED TOKENS: none + * DEFAULT VALUE: "" + */ + // "extends": "./shared/api-extractor-base.json" + // "extends": "my-package/include/api-extractor-base.json" + + /** + * Determines the "" token that can be used with other config file settings. The project folder + * typically contains the tsconfig.json and package.json config files, but the path is user-defined. + * + * The path is resolved relative to the folder of the config file that contains the setting. + * + * The default value for "projectFolder" is the token "", which means the folder is determined by traversing + * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder + * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error + * will be reported. + * + * SUPPORTED TOKENS: + * DEFAULT VALUE: "" + */ + "projectFolder": ".", + + /** + * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor + * analyzes the symbols exported by this module. + * + * The file extension must be ".d.ts" and not ".ts". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + */ + "mainEntryPointFilePath": "/build/types/applicationinsights-osplugin-js.d.ts", + + /** + * A list of NPM package names whose exports should be treated as part of this package. + * + * For example, suppose that Webpack is used to generate a distributed bundle for the project "library1", + * and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part + * of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly + * imports library2. To avoid this, we can specify: + * + * "bundledPackages": [ "library2" ], + * + * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been + * local files for library1. + */ + "bundledPackages": [ + ], + + /** + * Determines how the TypeScript compiler engine will be invoked by API Extractor. + */ + "compiler": { + /** + * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * Note: This setting will be ignored if "overrideTsconfig" is used. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/tsconfig.json" + */ + // "tsconfigFilePath": "/tsconfig.json", + + /** + * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk. + * The object must conform to the TypeScript tsconfig schema: + * + * http://json.schemastore.org/tsconfig + * + * If omitted, then the tsconfig.json file will be read from the "projectFolder". + * + * DEFAULT VALUE: no overrideTsconfig section + */ + // "overrideTsconfig": { + // . . . + // } + + /** + * This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended + * and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when + * dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses + * for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck. + * + * DEFAULT VALUE: false + */ + // "skipLibCheck": true, + }, + + /** + * Configures how the API report file (*.api.md) will be generated. + */ + "apiReport": { + /** + * (REQUIRED) Whether to generate an API report. + */ + "enabled": true, + + /** + * The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce + * a full file path. + * + * The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/". + * + * SUPPORTED TOKENS: , + * DEFAULT VALUE: ".api.md" + */ + "reportFileName": ".api.md", + + /** + * Specifies the folder where the API report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy, + * e.g. for an API review. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/etc/" + */ + "reportFolder": "/build/dts/", + + /** + * Specifies the folder where the temporary report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * After the temporary file is written to disk, it is compared with the file in the "reportFolder". + * If they are different, a production build will fail. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/" + */ + // "reportTempFolder": "/temp/" + }, + + /** + * Configures how the doc model file (*.api.json) will be generated. + */ + "docModel": { + /** + * (REQUIRED) Whether to generate a doc model file. + */ + "enabled": true, + + /** + * The output path for the doc model file. The file extension should be ".api.json". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/.api.json" + */ + "apiJsonFilePath": "/build/dts/.api.json" + }, + + /** + * Configures how the .d.ts rollup file will be generated. + */ + "dtsRollup": { + /** + * (REQUIRED) Whether to generate the .d.ts rollup file. + */ + "enabled": true, + + /** + * Specifies the output path for a .d.ts rollup file to be generated without any trimming. + * This file will include all declarations that are exported by the main entry point. + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/dist/.d.ts" + */ + "untrimmedFilePath": "/build/dts/.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release. + * This file will include only declarations that are marked as "@public" or "@beta". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "betaTrimmedFilePath": "/build/dts/-beta.d.ts", + + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release. + * This file will include only declarations that are marked as "@public". + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "publicTrimmedFilePath": "/build/dts/-public.d.ts", + + /** + * When a declaration is trimmed, by default it will be replaced by a code comment such as + * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the + * declaration completely. + * + * DEFAULT VALUE: false + */ + // "omitTrimmingComments": true + }, + + /** + * Configures how the tsdoc-metadata.json file will be generated. + */ + "tsdocMetadata": { + /** + * Whether to generate the tsdoc-metadata.json file. + * + * DEFAULT VALUE: true + */ + "enabled": false, + + /** + * Specifies where the TSDoc metadata file should be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * The default value is "", which causes the path to be automatically inferred from the "tsdocMetadata", + * "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup + * falls back to "tsdoc-metadata.json" in the package folder. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + "tsdocMetadataFilePath": "/build/dts/tsdoc-metadata.json" + }, + + /** + * Configures how API Extractor reports error and warning messages produced during analysis. + * + * There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages. + */ + "messages": { + /** + * Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing + * the input .d.ts files. + * + * TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "compilerMessageReporting": { + /** + * Configures the default routing for messages that don't match an explicit rule in this table. + */ + "default": { + /** + * Specifies whether the message should be written to the the tool's output log. Note that + * the "addToApiReportFile" property may supersede this option. + * + * Possible values: "error", "warning", "none" + * + * Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail + * and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes + * the "--local" option), the warning is displayed but the build will not fail. + * + * DEFAULT VALUE: "warning" + */ + "logLevel": "warning", + + /** + * When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md), + * then the message will be written inside that file; otherwise, the message is instead logged according to + * the "logLevel" option. + * + * DEFAULT VALUE: false + */ + // "addToApiReportFile": false + }, + + // "TS2551": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + }, + + /** + * Configures handling of messages reported by API Extractor during its analysis. + * + * API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag" + * + * DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings + */ + "extractorMessageReporting": { + "default": { + "logLevel": "warning", + // "addToApiReportFile": false + }, + + "ae-missing-release-tag": { + "logLevel": "none" + }, + // + // . . . + }, + + /** + * Configures handling of messages reported by the TSDoc parser when analyzing code comments. + * + * TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "tsdocMessageReporting": { + "default": { + "logLevel": "warning", + // "addToApiReportFile": false + } + + // "tsdoc-link-tag-unescaped-text": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + } + } + + } + \ No newline at end of file diff --git a/extensions/applicationinsights-osplugin-js/package.json b/extensions/applicationinsights-osplugin-js/package.json new file mode 100644 index 000000000..8f5716f8b --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/package.json @@ -0,0 +1,56 @@ +{ + "name": "@microsoft/applicationinsights-osplugin-js", + "version": "3.1.2", + "description": "Microsoft Application Insights OS Plugin", + "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme", + "author": "Microsoft Application Insights Team", + "main": "dist/es5/applicationinsights-osplugin-js.js", + "module": "dist-es5/applicationinsights-osplugin-js.js", + "types": "types/applicationinsights-osplugin-js.d.ts", + "sideEffects": false, + "repository": { + "type": "git", + "url": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-osplugin-js" + }, + "scripts": { + "clean": "git clean -xdf", + "build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen", + "build:esm": "grunt osplugin", + "build:browser": "rollup -c rollup.config.js --bundleConfigAsCjs", + "rebuild": "npm run build", + "test": "grunt osplugintests", + "mintest": "grunt osplugin-mintests", + "lint": "tslint -p tsconfig.json", + "dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights osplugin plugin\"", + "sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js", + "ai-min": "grunt osplugin-min", + "ai-restore": "grunt osplugin-restore", + "npm-pack": "npm pack", + "api-docs": "typedoc" + }, + "dependencies": { + "@microsoft/applicationinsights-shims": "3.0.1", + "@microsoft/applicationinsights-common": "3.1.2", + "@microsoft/dynamicproto-js": "^2.0.3", + "@microsoft/applicationinsights-core-js": "3.1.2", + "@nevware21/ts-utils": ">= 0.11.0 < 2.x", + "@nevware21/ts-async": ">= 0.3.0 < 2.x" + }, + "devDependencies": { + "@microsoft/ai-test-framework": "0.0.1", + "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0", + "@microsoft/applicationinsights-rollup-es5": "1.0.2", + "@microsoft/api-extractor": "^7.40.0", + "@types/sinon": "4.3.3", + "grunt": "^1.5.3", + "sinon": "^7.3.1", + "globby": "^11.0.0", + "@rollup/plugin-commonjs": "^24.0.0", + "@rollup/plugin-node-resolve": "^15.0.1", + "@rollup/plugin-replace": "^5.0.2", + "rollup-plugin-cleanup": "^3.2.1", + "rollup": "^3.20.0", + "typescript": "^4.9.3" + }, + "license": "MIT" +} diff --git a/extensions/applicationinsights-osplugin-js/rollup.config.js b/extensions/applicationinsights-osplugin-js/rollup.config.js new file mode 100644 index 000000000..20bb6fe92 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/rollup.config.js @@ -0,0 +1,37 @@ +import { createConfig } from "../../rollup.base.config"; +import { updateDistEsmFiles } from "../../tools/updateDistEsm/updateDistEsm"; + +const version = require("./package.json").version; +const browserEntryPointName = "applicationinsights-osplugin-js"; +const browserOutputName = "ai.osplugin"; +const entryPointName = "applicationinsights-osplugin-js"; +const outputName = "applicationinsights-osplugin-js"; + +const banner = [ + "/*!", + ` * Application Insights JavaScript SDK - OS Plugin, ${version}`, + " * Copyright (c) Microsoft and contributors. All rights reserved.", + " */" +].join("\n"); + +const replaceValues = { + "// Copyright (c) Microsoft Corporation. All rights reserved.": "", + "// Licensed under the MIT License.": "" +}; + +updateDistEsmFiles(replaceValues, banner, true, true, "dist-es5"); + +export default createConfig(banner, + { + namespace: "Microsoft.ApplicationInsights", + version: version, + node: { + entryPoint: entryPointName, + outputName: outputName + }, + browser: { + entryPoint: browserEntryPointName, + outputName: browserOutputName + } + }, + [ outputName ]); diff --git a/extensions/applicationinsights-osplugin-js/src/DataModels.ts b/extensions/applicationinsights-osplugin-js/src/DataModels.ts new file mode 100644 index 000000000..9648b6b91 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/src/DataModels.ts @@ -0,0 +1,28 @@ +/** +* DataModels.ts +* @author Siyu Niu (siyuniu) +* @copyright Microsoft 2024 +* File containing the interfaces for OS Plugin SDK. +*/ + +/** + * Interface for OS Plugin SDK config + * @maxTimeout: Maximum time to wait for the OS plugin to return the OS information + * @mergeOsNameVersion: Whether to merge the OS name and version into one field + */ +export interface IOSPluginConfiguration { + /** + * Maximum time to wait for the OS plugin to return the OS information + * Default: 200 + * @type {number} + * @memberof IOSPluginConfiguration + */ + maxTimeout?: number; + /** + * Whether to merge the OS name and version into one field + * Default: undefined + * @type {boolean} + * @memberof IOSPluginConfiguration + */ + mergeOsNameVersion?: boolean; +} diff --git a/extensions/applicationinsights-osplugin-js/src/OsPlugin.ts b/extensions/applicationinsights-osplugin-js/src/OsPlugin.ts new file mode 100644 index 000000000..f51f7c55d --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/src/OsPlugin.ts @@ -0,0 +1,262 @@ +/** +* OsPlugin.ts +* @author Siyu Niu (siyuniu) +* @copyright Microsoft 2024 +*/ +import dynamicProto from "@microsoft/dynamicproto-js"; +import { + Extensions, IConfig, utlCanUseSessionStorage, utlGetSessionStorage, utlSetSessionStorage +} from "@microsoft/applicationinsights-common"; +import { + BaseTelemetryPlugin, IAppInsightsCore, IConfigDefaults, IConfiguration, IPlugin, IProcessTelemetryContext, + IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryUnloadState, _eInternalMessageId, _throwInternal, addPageHideEventListener, + addPageUnloadEventListener, arrForEach, createProcessTelemetryContext, createUniqueNamespace, eLoggingSeverity, getSetValue, + mergeEvtNamespace, onConfigChange, removePageHideEventListener, removePageUnloadEventListener, setValue +} from "@microsoft/applicationinsights-core-js"; +import { IPromise, doAwaitResponse } from "@nevware21/ts-async"; +import { ITimerHandler, isString, objDeepFreeze, scheduleTimeout } from "@nevware21/ts-utils"; +import { IOSPluginConfiguration } from "./DataModels"; + +const defaultMaxTimeout = 200; +const strExt = "ext"; +interface platformVersionInterface { + platform?: string, + platformVersion?: string +} +interface UserAgentHighEntropyData { + platformVersion: platformVersionInterface +} +interface ModernNavigator { + userAgentData?: { + getHighEntropyValues?: (fields: ["platformVersion"]) => IPromise; + }; + } +const defaultOSConfig: IConfigDefaults = objDeepFreeze({ + maxTimeout: defaultMaxTimeout, + mergeOsNameVersion: undefined +}); + +interface IDelayedEvent { + ctx: IProcessTelemetryContext; + item: ITelemetryItem; +} + +export class OsPlugin extends BaseTelemetryPlugin { + public identifier = "OsPlugin"; + public priority = 195; + public version = "#version#"; + + constructor() { + super(); + let _core: IAppInsightsCore; + let _ocConfig: IOSPluginConfiguration; + let _getOSInProgress: boolean; + let _getOSTimeout: ITimerHandler; + let _maxTimeout: number; + + let _platformVersionResponse: platformVersionInterface; + let _retrieveFullVersion: boolean; + let _mergeOsNameVersion: boolean; + + let _eventQueue: IDelayedEvent[]; + let _evtNamespace: string | string[]; + let _excludePageUnloadEvents: string[]; + + let _os: string; + let _osVer: number; + let _firstAttempt: boolean; + + dynamicProto(OsPlugin, this, (_self, _base) => { + + _initDefaults(); + + _self.initialize = (coreConfig: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[]) => { + let _self = this; + _core = core; + super.initialize(coreConfig, core, extensions); + let identifier = _self.identifier; + _evtNamespace = mergeEvtNamespace(createUniqueNamespace(identifier), core.evtNamespace && core.evtNamespace()); + if (utlCanUseSessionStorage) { + try { + _platformVersionResponse = JSON.parse(utlGetSessionStorage(core.logger, "ai_osplugin")); + } catch (error) { + // do nothing + } + } + if(_platformVersionResponse){ + _retrieveFullVersion = true; + _osVer = parseInt(_platformVersionResponse.platformVersion); + _os = _platformVersionResponse.platform; + } + _self._addHook(onConfigChange(coreConfig, (details)=> { + let coreConfig = details.cfg; + let ctx = createProcessTelemetryContext(null, coreConfig, core); + _ocConfig = ctx.getExtCfg(identifier, defaultOSConfig); + _maxTimeout = _ocConfig.maxTimeout; + if (_ocConfig.mergeOsNameVersion !== undefined){ + _mergeOsNameVersion = _ocConfig.mergeOsNameVersion; + } else if (core.getPlugin("Sender").plugin){ + _mergeOsNameVersion = true; + } else { + _mergeOsNameVersion = false; + } + + let excludePageUnloadEvents = coreConfig.disablePageUnloadEvents || []; + + if (_excludePageUnloadEvents && _excludePageUnloadEvents !== excludePageUnloadEvents) { + removePageUnloadEventListener(null, _evtNamespace); + removePageHideEventListener(null, _evtNamespace); + _excludePageUnloadEvents = null; + } + + if (!_excludePageUnloadEvents) { + // If page is closed release queue + addPageUnloadEventListener(_doUnload, excludePageUnloadEvents, _evtNamespace); + addPageHideEventListener(_doUnload, excludePageUnloadEvents, _evtNamespace); + } + _excludePageUnloadEvents = excludePageUnloadEvents; + })); + function _doUnload() { + _releaseEventQueue(); + } + }; + + _self.processTelemetry = (event: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => { + itemCtx = _self._getTelCtx(itemCtx); + + if (!_retrieveFullVersion && !_getOSInProgress && _firstAttempt) { + // Start Requesting OS version process + _getOSInProgress = true; + startRetrieveOsVersion(); + _firstAttempt = false; + } + + if (_getOSInProgress) { + _eventQueue.push({ + ctx: itemCtx, + item: event + }); + } else { + updateTeleItemWithOs(event); + _self.processNext(event, itemCtx); + } + }; + + _self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => { + _completeOsRetrieve(); + removePageUnloadEventListener(null, _evtNamespace); + removePageHideEventListener(null, _evtNamespace); + // Just register to remove all events associated with this namespace + _initDefaults(); + }; + + + /** + * Wait for the response from the browser for the OS version and store info in the session storage + */ + function startRetrieveOsVersion() { + // Timeout request if it takes more than 5 seconds (by default) + + _getOSTimeout = scheduleTimeout(() => { + _completeOsRetrieve(); + }, _maxTimeout); + + if (navigator.userAgent) { + const getHighEntropyValues = (navigator as ModernNavigator).userAgentData?.getHighEntropyValues; + if (getHighEntropyValues) { + doAwaitResponse((navigator as ModernNavigator).userAgentData.getHighEntropyValues(["platformVersion"]), (response:any) => { + if (!response.rejected) { + _platformVersionResponse = response.value; + _retrieveFullVersion = true; + if (_platformVersionResponse.platformVersion && _platformVersionResponse.platform) { + _os = _platformVersionResponse.platform; + _osVer = parseInt(_platformVersionResponse.platformVersion); + if (_os === "Windows"){ + if (_osVer == 0){ + _osVer = 8; + } else if (_osVer < 13){ + _osVer = 10; + } else{ + _osVer = 11; + } + } + utlSetSessionStorage(_core.logger, "ai_osplugin", JSON.stringify({platform: _os, platformVersion: _osVer})); + } + } else { + _throwInternal(_core.logger, + eLoggingSeverity.CRITICAL, + _eInternalMessageId.PluginException, + "Could not retrieve operating system: " + response.reason); + } + _completeOsRetrieve(); + }); + } + } + } + + function updateTeleItemWithOs(event: ITelemetryItem) { + if (_retrieveFullVersion){ + let extOS = getSetValue(getSetValue(event, strExt), Extensions.OSExt); + if (_mergeOsNameVersion){ + setValue(extOS, "osVer", _os + _osVer, isString); + } else { + setValue(extOS, "osVer", _osVer); + setValue(extOS, "os", _os, isString); + } + } + } + + /** + * Complete retrieving operating system info process, cleanup and release the event queue + */ + function _completeOsRetrieve() { + if (_getOSTimeout) { + _getOSTimeout.cancel(); + } + _getOSInProgress = false; + _releaseEventQueue(); + } + + /** + * Release internal event queue + */ + function _releaseEventQueue() { + arrForEach(_eventQueue, (evt) => { + updateTeleItemWithOs(evt.item); + _self.processNext(evt.item, evt.ctx); + }); + _eventQueue = []; + } + + function _initDefaults() { + _core = null; + _ocConfig = null; + _getOSInProgress = false; + _getOSTimeout = null; + _maxTimeout = null; + _retrieveFullVersion = false; + _eventQueue = []; + _firstAttempt = true; + } + + // Special internal method to allow the DebugPlugin to hook embedded objects + _self["_getDbgPlgTargets"] = () => { + return [_platformVersionResponse, _eventQueue, _getOSInProgress]; + }; + }); + } + public initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[]) { + // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging + } + + /** + * Process the event and add it to an internal queue if handshake in process + * @param event - The event to process + * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances + * can optionally use this to access the current core instance or define / pass additional information + * to later plugins (vs appending items to the telemetry item) + */ + public processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext) { + // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging + } +} diff --git a/extensions/applicationinsights-osplugin-js/src/applicationinsights-osplugin-js.ts b/extensions/applicationinsights-osplugin-js/src/applicationinsights-osplugin-js.ts new file mode 100644 index 000000000..9b09aac20 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/src/applicationinsights-osplugin-js.ts @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import { IOSPluginConfiguration } from "./DataModels"; +import { OsPlugin } from "./OsPlugin"; + +export { OsPlugin, IOSPluginConfiguration }; diff --git a/extensions/applicationinsights-osplugin-js/tsconfig.json b/extensions/applicationinsights-osplugin-js/tsconfig.json new file mode 100644 index 000000000..e8450c352 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "sourceMap": true, + "inlineSources": true, + "noImplicitAny": true, + "module": "es6", + "moduleResolution": "Node", + "target": "es5", + "alwaysStrict": true, + "suppressImplicitAnyIndexErrors": true, + "allowSyntheticDefaultImports": true, + "importHelpers": true, + "noEmitHelpers": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "declaration": true, + "declarationDir": "build/types", + "outDir": "dist-es5", + "rootDir": "./src", + "removeComments": false + }, + "include": [ + "./src/**/*.ts" + ], + "exclude": [ + "./node_modules/**" + ] +} \ No newline at end of file diff --git a/extensions/applicationinsights-osplugin-js/typedoc.json b/extensions/applicationinsights-osplugin-js/typedoc.json new file mode 100644 index 000000000..4416728e1 --- /dev/null +++ b/extensions/applicationinsights-osplugin-js/typedoc.json @@ -0,0 +1,62 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "entryPoints": [ "./src/applicationinsights-osplugin-js.ts" ], + "exclude": [ "**/internal/**/*.ts", "node_modules/**" ], + "externalPattern": [ + "**/node_modules/**", + "node_modules/**" + ], + "sort": [ + "alphabetical", + "kind", + "instance-first" + ], + "basePath": "./src", + "sourceLinkTemplate": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/{path}#L{line}", + "cleanOutputDir": true, + "excludeExternals": false, + "excludeInternal": true, + "excludePrivate": true, + "includeVersion": true, + "groupOrder": [ + "Entrypoint", + "Modules", + "Namespaces", + "Enumerations", + "Enumeration Members", + "Classes", + "Interfaces", + "Type Aliases", + "Constructors", + "Properties", + "Variables", + "Functions", + "Accessors", + "Methods", + "References", + "*" + ], + "tsconfig": "./tsconfig.json", + "out": "../../docs/webSdk/applicationinsights-osplugin-js", + "readme": "none", + "githubPages": true, + "gitRevision": "main", + "compilerOptions": { + "stripInternal": true + }, + "sidebarLinks": { + "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", + "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-osplugin-js" + }, + "navigationLinks": { + "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", + "npm": "https://www.npmjs.com/package/@microsoft/applicationinsights-osplugin-js" + }, + "visibilityFilters": { + "protected": false, + "private": false, + "inherited": true, + "external": true + } +} \ No newline at end of file diff --git a/extensions/applicationinsights-perfmarkmeasure-js/typedoc.json b/extensions/applicationinsights-perfmarkmeasure-js/typedoc.json index 0d1884d40..c9413dc9b 100644 --- a/extensions/applicationinsights-perfmarkmeasure-js/typedoc.json +++ b/extensions/applicationinsights-perfmarkmeasure-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-perfmarkmeasure-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/extensions/applicationinsights-properties-js/typedoc.json b/extensions/applicationinsights-properties-js/typedoc.json index ba8facdb5..f1617c83e 100644 --- a/extensions/applicationinsights-properties-js/typedoc.json +++ b/extensions/applicationinsights-properties-js/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/extensions/applicationinsights-properties-js" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/gruntfile.js b/gruntfile.js index b0f25a324..bcaf721a3 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -546,6 +546,10 @@ module.exports = function (grunt) { path: "./extensions/applicationinsights-properties-js", unitTestName: "prop.tests.js" }, + "osplugin": { + path: "./extensions/applicationinsights-osplugin-js", + unitTestName: "applicationinsights-osplugin.tests.js" + }, "cfgsync": { path: "./extensions/applicationinsights-cfgsync-js", unitTestName: "cfgsync.tests.js" @@ -924,6 +928,12 @@ module.exports = function (grunt) { grunt.registerTask("clickanalyticstests", tsTestActions("clickanalytics")); grunt.registerTask("clickanalytics-mintests", tsTestActions("clickanalytics", true)); + grunt.registerTask("osplugin", tsBuildActions("osplugin")); + grunt.registerTask("osplugin-min", minTasks("osplugin")); + grunt.registerTask("osplugin-restore", restoreTasks("osplugin")); + grunt.registerTask("osplugintests", tsTestActions("osplugin")); + grunt.registerTask("osplugin-mintests", tsTestActions("osplugin", true)); + grunt.registerTask("1dsCoreBuild", tsBuildActions("1dsCore")); grunt.registerTask("1dsCoreTest", tsTestActions("1dsCore")); grunt.registerTask("1dsCore", tsTestActions("1dsCore", true)); diff --git a/rush.json b/rush.json index 03f973226..913e4e0db 100644 --- a/rush.json +++ b/rush.json @@ -79,6 +79,11 @@ "projectFolder": "extensions/applicationinsights-clickanalytics-js", "shouldPublish": true }, + { + "packageName": "@microsoft/applicationinsights-osplugin-js", + "projectFolder": "extensions/applicationinsights-osplugin-js", + "shouldPublish": true + }, { "packageName": "@microsoft/applicationinsights-channel-js", "projectFolder": "channels/applicationinsights-channel-js", diff --git a/shared/AppInsightsCommon/typedoc.json b/shared/AppInsightsCommon/typedoc.json index ec4541759..f727385da 100644 --- a/shared/AppInsightsCommon/typedoc.json +++ b/shared/AppInsightsCommon/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/shared/AppInsightsCommon" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/tools/applicationinsights-web-snippet/typedoc.json b/tools/applicationinsights-web-snippet/typedoc.json index 79ab57b18..4bee20a76 100644 --- a/tools/applicationinsights-web-snippet/typedoc.json +++ b/tools/applicationinsights-web-snippet/typedoc.json @@ -47,7 +47,7 @@ "sidebarLinks": { "Changelog": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/RELEASES.md", "Examples": "https://github.com/microsoft/ApplicationInsights-JS/blob/main/examples/README.md", - "Readme": "https://github.com/Microsoft/ApplicationInsights-JS" + "Readme": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/tools/applicationinsights-web-snippet" }, "navigationLinks": { "GitHub": "https://github.com/Microsoft/ApplicationInsights-JS", diff --git a/tools/release-tools/package_groups.json b/tools/release-tools/package_groups.json index f82406a7b..5ff4e3444 100644 --- a/tools/release-tools/package_groups.json +++ b/tools/release-tools/package_groups.json @@ -10,6 +10,7 @@ "./AISKULight", "./extensions/applicationinsights-analytics-js", "./extensions/applicationinsights-properties-js", + "./extensions/applicationinsights-osplugin-js", "./channels/applicationinsights-channel-js", "./extensions/applicationinsights-dependencies-js", "./extensions/applicationinsights-clickanalytics-js", @@ -32,6 +33,7 @@ "./AISKULight", "./extensions/applicationinsights-analytics-js", "./extensions/applicationinsights-properties-js", + "./extensions/applicationinsights-osplugin-js", "./channels/applicationinsights-channel-js", "./extensions/applicationinsights-dependencies-js", "./extensions/applicationinsights-clickanalytics-js", diff --git a/version.json b/version.json index 2e344d16c..b231cea83 100644 --- a/version.json +++ b/version.json @@ -24,6 +24,10 @@ "package": "extensions/applicationinsights-clickanalytics-js/package.json", "release": "3.1.2" }, + "@microsoft/applicationinsights-osplugin-js": { + "package": "extensions/applicationinsights-osplugin-js/package.json", + "release": "3.1.2" + }, "@microsoft/applicationinsights-debugplugin-js": { "package": "extensions/applicationinsights-debugplugin-js/package.json", "release": "3.1.2"