From ebd4d4dd4c6f232fe75d64709a1183bd9b8da568 Mon Sep 17 00:00:00 2001 From: Marko Schulz Date: Mon, 13 Nov 2023 11:52:25 +0100 Subject: [PATCH] Minimal fix for #1226 A minimal fix for trying to load the default configuration during runtime which only exists in the source code. That loading previously failed when the code is bundled. So now the default configuration is already loaded when bundling the code. --- Library/JsonConfig.ts | 16 ++++++++++------ tsconfig.json | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Library/JsonConfig.ts b/Library/JsonConfig.ts index b01c1f3c..a5df4ff1 100644 --- a/Library/JsonConfig.ts +++ b/Library/JsonConfig.ts @@ -6,6 +6,8 @@ import { IJsonConfig } from "../Declarations/Interfaces"; import { DistributedTracingModes } from "../applicationinsights"; import { IDisabledExtendedMetrics } from "../AutoCollection/NativePerformance"; +import defaultConfig from '../applicationinsights.json'; + const ENV_CONFIGURATION_FILE = "APPLICATIONINSIGHTS_CONFIGURATION_FILE"; // Azure Connection String const ENV_connectionString = "APPLICATIONINSIGHTS_CONNECTION_STRING"; @@ -137,12 +139,14 @@ export class JsonConfig implements IJsonConfig { else { tempDir = path.join(rootPath, configFile);// Relative path to applicationinsights folder } - } - try { - jsonString = fs.readFileSync(tempDir, "utf8"); - } - catch (err) { - Logging.warn("Failed to read JSON config file: ", err); + try { + jsonString = fs.readFileSync(tempDir, "utf8"); + } + catch (err) { + Logging.warn("Failed to read JSON config file: ", err); + } + } else { + jsonString = JSON.stringify(defaultConfig); } } diff --git a/tsconfig.json b/tsconfig.json index db974fb0..c2a52245 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,8 @@ "declaration": true, "noImplicitAny": true, "outDir": "./out", + "resolveJsonModule": true, + "esModuleInterop": true, "typeRoots": [ "./node_modules/@types", "./types"