From 70fa5b00317e4696d26c8bb1cec77eae4fcb55bb Mon Sep 17 00:00:00 2001 From: Eyal Toledano Date: Fri, 16 May 2025 17:41:48 -0400 Subject: [PATCH] fix(config): adjusts getUserId to optionally create/fill in the (currently hardcoded) userId to the telemetry object if it is not found. This prevents the telemetry call from landing as null for users who may have a taskmasterconfig but no userId in the globals. --- scripts/modules/config-manager.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/modules/config-manager.js b/scripts/modules/config-manager.js index 217b2faf..258840da 100644 --- a/scripts/modules/config-manager.js +++ b/scripts/modules/config-manager.js @@ -676,7 +676,25 @@ function isConfigFilePresent(explicitRoot = null) { */ function getUserId(explicitRoot = null) { const config = getConfig(explicitRoot); - return config?.global?.userId || null; + if (!config.global) { + config.global = {}; // Ensure global object exists + } + if (!config.global.userId) { + config.global.userId = '1234567890'; + // Attempt to write the updated config. + // It's important that writeConfig correctly resolves the path + // using explicitRoot, similar to how getConfig does. + const success = writeConfig(config, explicitRoot); + if (!success) { + // Log an error or handle the failure to write, + // though for now, we'll proceed with the in-memory default. + log( + 'warning', + 'Failed to write updated configuration with new userId. Please let the developers know.' + ); + } + } + return config.global.userId; } /**