Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

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.

Eyal Toledano70fa5b00317e
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;
}
/**