diff --git a/src/recorder.ts b/src/recorder.ts index c4d0313..e939b0b 100644 --- a/src/recorder.ts +++ b/src/recorder.ts @@ -13,7 +13,16 @@ import { FunctionInfo } from "./registry"; import commonPathPrefix from "./util/commonPathPrefix"; import { getTime } from "./util/getTime"; -const processRecordingShouldAlwaysBeActive = "APPMAP_RECORDER_PROCESS_ALWAYS" in process.env; +const kAppmapRecorderProcessAlwaysEnvar = "APPMAP_RECORDER_PROCESS_ALWAYS"; +const processRecordingShouldAlwaysBeActive = isTruthy( + process.env[kAppmapRecorderProcessAlwaysEnvar], +); + +function isTruthy(value?: string): boolean { + if (value == undefined) return false; + const truthyValues = ["true", "1", "on", "yes"]; + return truthyValues.includes(value.toLowerCase().trim()); +} // If APPMAP_RECORDER_PROCESS_ALWAYS is set we can have // two recordings active simultaneously. Always active