From 563f1deb76b75653a4222d0d7ccb24732d3bd44f Mon Sep 17 00:00:00 2001 From: Tanmaya Panda Date: Thu, 11 Jan 2024 10:51:45 +0530 Subject: [PATCH 1/3] added kusto specific headers --- package-lock.json | 6 +++--- src/ServerClient/ADXClient.ts | 7 ++++++- tsconfig.json | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc9d14b6..51065491 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3290,9 +3290,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.4", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", + "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", "dev": true, "funding": [ { diff --git a/src/ServerClient/ADXClient.ts b/src/ServerClient/ADXClient.ts index faf804cd..74163cc8 100644 --- a/src/ServerClient/ADXClient.ts +++ b/src/ServerClient/ADXClient.ts @@ -1,5 +1,8 @@ import { ADXResponse, RawADXResponse } from "./ADXResponse"; +const packageJson = require('../../package.json'); + type ADXTokenProvider = () => Promise; +const version = packageJson.version; declare global { interface Crypto { @@ -69,7 +72,9 @@ export class ADXClient { "Content-Type": "application/json", Authorization: `Bearer ${token}`, "x-ms-client-request-id": `KTrender;${self.crypto.randomUUID()}`, - "x-ms-app": "KustoTrender" + "x-ms-app": "KustoTrender", + "x-ms-client-version": version, + "x-ms-user" : "KustoTrender" }, body: JSON.stringify(body), }); diff --git a/tsconfig.json b/tsconfig.json index 78f152a3..96e5b3a8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,9 @@ "lib" : ["es5", "es2015.promise", "dom", "es6"], "moduleResolution": "Node", "declaration": true, - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true, + "esModuleInterop": true }, "include": [ "src" From 6793bd742a958354a09a934618104e5a8b8d6bee Mon Sep 17 00:00:00 2001 From: Tanmaya Panda Date: Thu, 11 Jan 2024 10:53:30 +0530 Subject: [PATCH 2/3] removed unnecessary constant --- src/ServerClient/ADXClient.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ServerClient/ADXClient.ts b/src/ServerClient/ADXClient.ts index 74163cc8..df3f6f11 100644 --- a/src/ServerClient/ADXClient.ts +++ b/src/ServerClient/ADXClient.ts @@ -2,7 +2,6 @@ import { ADXResponse, RawADXResponse } from "./ADXResponse"; const packageJson = require('../../package.json'); type ADXTokenProvider = () => Promise; -const version = packageJson.version; declare global { interface Crypto { @@ -73,7 +72,7 @@ export class ADXClient { Authorization: `Bearer ${token}`, "x-ms-client-request-id": `KTrender;${self.crypto.randomUUID()}`, "x-ms-app": "KustoTrender", - "x-ms-client-version": version, + "x-ms-client-version": packageJson.version, "x-ms-user" : "KustoTrender" }, body: JSON.stringify(body), From e54e690caa9bfa8b42111f02b33b05ee790a1e9e Mon Sep 17 00:00:00 2001 From: Tanmaya Panda Date: Mon, 15 Jan 2024 17:11:15 +0530 Subject: [PATCH 3/3] addressed review comments --- src/ServerClient/ADXClient.ts | 6 +++--- webpack.common.js | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ServerClient/ADXClient.ts b/src/ServerClient/ADXClient.ts index df3f6f11..4aa5da72 100644 --- a/src/ServerClient/ADXClient.ts +++ b/src/ServerClient/ADXClient.ts @@ -1,5 +1,4 @@ import { ADXResponse, RawADXResponse } from "./ADXResponse"; -const packageJson = require('../../package.json'); type ADXTokenProvider = () => Promise; @@ -72,8 +71,9 @@ export class ADXClient { Authorization: `Bearer ${token}`, "x-ms-client-request-id": `KTrender;${self.crypto.randomUUID()}`, "x-ms-app": "KustoTrender", - "x-ms-client-version": packageJson.version, - "x-ms-user" : "KustoTrender" + "x-ms-client-version": process.env.PACKAGE_VERSION, + "x-ms-user" : "KustoTrender", + "User-Agent" : navigator.userAgent }, body: JSON.stringify(body), }); diff --git a/webpack.common.js b/webpack.common.js index aa5e400e..e8f799ed 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -1,5 +1,7 @@ const path = require('path'); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const packageJson = require('./package.json'); +const webpack = require('webpack'); module.exports = { entry: './src/KustoTrender.ts', @@ -48,4 +50,9 @@ module.exports = { publicPath: '/dist/', libraryTarget: 'umd' }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env.PACKAGE_VERSION': JSON.stringify(packageJson.version) + }) + ] }; \ No newline at end of file