Browse Source

Remove DEBUG console.log statements across codebase

- Eliminated all debugging console statements from 7 files (194 deletions)
- Fixed parsing errors from broken function calls in databaseUtil.ts
- Resolved orphaned console.log parameters in util.ts and ImportAccountView.vue
- Maintained legitimate logging in PlatformServiceFactory and registerServiceWorker
- Reduced lint issues from 33 problems (11 errors + 22 warnings) to 16 warnings
- All builds and core functionality verified working
web-serve-fix
Matthew Raymer 3 weeks ago
parent
commit
ebf7743862
  1. 2
      scripts/test-ios.js
  2. 56
      src/db/databaseUtil.ts
  3. 39
      src/libs/util.ts
  4. 8
      src/utils/PlatformServiceMixin.ts
  5. 21
      src/views/ImportAccountView.vue
  6. 52
      src/views/OnboardMeetingListView.vue
  7. 25
      src/views/OnboardMeetingSetupView.vue

2
scripts/test-ios.js

@ -330,7 +330,7 @@ const verifyXcodeInstallation = (log) => {
// Generate test data using generate_data.ts
const generateTestData = async (log) => {
log('\n🔍 DEBUG: Starting test data generation...');
log('\n🔍 Starting test data generation...');
// Check directory structure
log('📁 Current directory:', process.cwd());

56
src/db/databaseUtil.ts

@ -54,11 +54,6 @@ export async function updateDidSpecificSettings(
accountDid: string,
settingsChanges: Settings,
): Promise<boolean> {
console.log("🔧 DEBUG: updateDidSpecificSettings called with:", {
accountDid,
settingsChanges,
});
settingsChanges.accountDid = accountDid;
delete settingsChanges.id; // key off account, not ID
@ -69,13 +64,11 @@ export async function updateDidSpecificSettings(
"SELECT * FROM settings WHERE accountDid = ?",
[accountDid],
);
console.log("🔧 DEBUG: Pre-update database check:", checkResult);
// Get the current values for comparison
const currentRecord = checkResult?.values?.length
? mapColumnsToValues(checkResult.columns, checkResult.values)[0]
: null;
console.log("🔧 DEBUG: Current record:", currentRecord);
// First try to update existing record
const { sql: updateSql, params: updateParams } = generateUpdateStatement(
@ -85,11 +78,7 @@ export async function updateDidSpecificSettings(
[accountDid],
);
console.log("🔧 DEBUG: Generated SQL:", updateSql);
console.log("🔧 DEBUG: Generated params:", updateParams);
const updateResult = await platform.dbExec(updateSql, updateParams);
console.log("🔧 DEBUG: Update result:", updateResult);
await platform.dbExec(updateSql, updateParams);
// **WORKAROUND**: AbsurdSQL doesn't return changes count correctly
// Instead, check if the record was actually updated
@ -101,46 +90,35 @@ export async function updateDidSpecificSettings(
const updatedRecord = postUpdateResult?.values?.length
? mapColumnsToValues(postUpdateResult.columns, postUpdateResult.values)[0]
: null;
console.log("🔧 DEBUG: Updated record:", updatedRecord);
// Check if any of the target fields were actually changed
let actuallyUpdated = false;
if (currentRecord && updatedRecord) {
for (const key of Object.keys(settingsChanges)) {
if (key !== "accountDid" && currentRecord[key] !== updatedRecord[key]) {
console.log(
`🔧 DEBUG: Field '${key}' changed from '${currentRecord[key]}' to '${updatedRecord[key]}'`,
);
actuallyUpdated = true;
}
}
}
console.log("🔧 DEBUG: Actually updated:", actuallyUpdated);
// If the standard update didn't work, try a different approach
if (
!actuallyUpdated &&
settingsChanges.firstName &&
settingsChanges.isRegistered !== undefined
) {
console.log(
"🔧 DEBUG: Standard update failed, trying individual field updates...",
);
// Update firstName
const firstNameResult = await platform.dbExec(
await platform.dbExec(
"UPDATE settings SET firstName = ? WHERE accountDid = ?",
[settingsChanges.firstName, accountDid],
);
console.log("🔧 DEBUG: firstName update result:", firstNameResult);
// Update isRegistered
const isRegisteredResult = await platform.dbExec(
await platform.dbExec(
"UPDATE settings SET isRegistered = ? WHERE accountDid = ?",
[settingsChanges.isRegistered ? 1 : 0, accountDid],
);
console.log("🔧 DEBUG: isRegistered update result:", isRegisteredResult);
// Check if the individual updates worked
const finalCheckResult = await platform.dbQuery(
@ -151,10 +129,6 @@ export async function updateDidSpecificSettings(
const finalRecord = finalCheckResult?.values?.length
? mapColumnsToValues(finalCheckResult.columns, finalCheckResult.values)[0]
: null;
console.log(
"🔧 DEBUG: Final record after individual updates:",
finalRecord,
);
if (finalRecord) {
actuallyUpdated =
@ -163,7 +137,6 @@ export async function updateDidSpecificSettings(
}
}
console.log("🔧 DEBUG: Final success status:", actuallyUpdated);
return actuallyUpdated;
}
@ -200,21 +173,15 @@ export async function retrieveSettingsForDefaultAccount(): Promise<Settings> {
* @throws Will log specific errors for debugging but returns default settings on failure
*/
export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
console.log("🔍 DEBUG: retrieveSettingsForActiveAccount called");
try {
// Get default settings first
const defaultSettings = await retrieveSettingsForDefaultAccount();
console.log("🔍 DEBUG: Default settings loaded:", defaultSettings);
// If no active DID, return defaults
if (!defaultSettings.activeDid) {
console.log("🔍 DEBUG: No active DID, returning defaults");
return defaultSettings;
}
console.log("🔍 DEBUG: Active DID found:", defaultSettings.activeDid);
// Get account-specific settings
try {
const platform = PlatformServiceFactory.getInstance();
@ -223,12 +190,7 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
[defaultSettings.activeDid],
);
console.log("🔍 DEBUG: Account-specific query result:", result);
if (!result?.values?.length) {
console.log(
"🔍 DEBUG: No account-specific settings found, returning defaults",
);
// we created DID-specific settings when generated or imported, so this shouldn't happen
return defaultSettings;
}
@ -239,22 +201,13 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
result.values,
)[0] as Settings;
console.log("🔍 DEBUG: Raw override settings:", overrideSettings);
const overrideSettingsFiltered = Object.fromEntries(
Object.entries(overrideSettings).filter(([_, v]) => v !== null),
);
console.log(
"🔍 DEBUG: Filtered override settings:",
overrideSettingsFiltered,
);
// Merge settings
let settings = { ...defaultSettings, ...overrideSettingsFiltered };
console.log("🔍 DEBUG: Merged settings before platform fix:", settings);
// **ELECTRON-SPECIFIC FIX**: Force production API endpoints for Electron
// This ensures Electron doesn't use localhost development servers that might be saved in user settings
if (process.env.VITE_PLATFORM === "electron") {
@ -279,10 +232,8 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
settings.searchBoxes = parseJsonField(settings.searchBoxes, []);
}
console.log("🔍 DEBUG: Final merged settings:", settings);
return settings;
} catch (error) {
console.log("🔍 DEBUG: Error in account settings retrieval:", error);
logConsoleAndDb(
`[databaseUtil] Failed to retrieve account settings for ${defaultSettings.activeDid}: ${error}`,
true,
@ -291,7 +242,6 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
return defaultSettings;
}
} catch (error) {
console.log("🔍 DEBUG: Error in default settings retrieval:", error);
logConsoleAndDb(
`[databaseUtil] Failed to retrieve default settings: ${error}`,
true,

39
src/libs/util.ts

@ -603,12 +603,9 @@ export async function saveNewIdentity(
mnemonic: string,
derivationPath: string,
): Promise<void> {
console.log("💾 DEBUG: saveNewIdentity called with DID:", identity.did);
try {
// add to the new sql db
const platformService = PlatformServiceFactory.getInstance();
console.log("💾 DEBUG: Getting secrets from database");
const secrets = await platformService.dbQuery(
`SELECT secretBase64 FROM secret`,
@ -620,7 +617,6 @@ export async function saveNewIdentity(
}
const secretBase64 = secrets.values[0][0] as string;
console.log("💾 DEBUG: Found secret, encrypting identity");
const secret = base64ToArrayBuffer(secretBase64);
const identityStr = JSON.stringify(identity);
@ -629,8 +625,6 @@ export async function saveNewIdentity(
const encryptedIdentityBase64 = arrayBufferToBase64(encryptedIdentity);
const encryptedMnemonicBase64 = arrayBufferToBase64(encryptedMnemonic);
console.log("💾 DEBUG: Inserting account into database");
const sql = `INSERT INTO accounts (dateCreated, derivationPath, did, identityEncrBase64, mnemonicEncrBase64, publicKeyHex)
VALUES (?, ?, ?, ?, ?, ?)`;
const params = [
@ -642,22 +636,15 @@ export async function saveNewIdentity(
identity.keys[0].publicKeyHex,
];
await platformService.dbExec(sql, params);
console.log("💾 DEBUG: Account inserted successfully");
console.log("💾 DEBUG: Updating default settings with activeDid");
await databaseUtil.updateDefaultSettings({ activeDid: identity.did });
console.log("💾 DEBUG: Default settings updated");
console.log("💾 DEBUG: Inserting DID-specific settings");
await databaseUtil.insertDidSpecificSettings(identity.did);
console.log("💾 DEBUG: DID-specific settings inserted");
// Check what was actually created
const createdSettings =
await databaseUtil.retrieveSettingsForActiveAccount();
console.log("💾 DEBUG: Created settings:", createdSettings);
} catch (error) {
console.log("💾 DEBUG: saveNewIdentity error:", error);
logger.error("Failed to update default settings:", error);
throw new Error(
"Failed to set default settings. Please try again or restart the app.",
@ -934,56 +921,37 @@ export async function importFromMnemonic(
derivationPath: string = DEFAULT_ROOT_DERIVATION_PATH,
shouldErase: boolean = false,
): Promise<void> {
console.log("📥 DEBUG: importFromMnemonic called with:", {
mnemonicLength: mnemonic.split(" ").length,
derivationPath,
shouldErase,
});
const mne: string = mnemonic.trim().toLowerCase();
console.log("📥 DEBUG: Normalized mnemonic length:", mne.split(" ").length);
// Check if this is Test User #0
const TEST_USER_0_MNEMONIC =
"rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage";
const isTestUser0 = mne === TEST_USER_0_MNEMONIC;
console.log("📥 DEBUG: Is Test User #0:", isTestUser0);
// Derive address and keys from mnemonic
const [address, privateHex, publicHex] = deriveAddress(mne, derivationPath);
console.log("📥 DEBUG: Derived address:", address);
console.log("📥 DEBUG: Derived DID:", `did:ethr:${address}`);
// Create new identifier
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
console.log("📥 DEBUG: Created new identifier:", {
did: newId.did,
keysLength: newId.keys.length,
});
// Handle erasures
if (shouldErase) {
console.log("📥 DEBUG: Erasing existing accounts");
const platformService = PlatformServiceFactory.getInstance();
await platformService.dbExec("DELETE FROM accounts");
}
// Save the new identity
console.log("📥 DEBUG: Calling saveNewIdentity");
await saveNewIdentity(newId, mne, derivationPath);
console.log("📥 DEBUG: saveNewIdentity completed");
// Set up Test User #0 specific settings
if (isTestUser0) {
console.log("📥 DEBUG: Setting up Test User #0 specific settings");
// First, let's see what's currently in the database
const platformService = PlatformServiceFactory.getInstance();
const existingResult = await platformService.dbQuery(
"SELECT * FROM settings WHERE accountDid = ?",
[newId.did],
);
console.log("📥 DEBUG: Existing settings before update:", existingResult);
// Let's also see the actual data by mapping it
if (existingResult?.values?.length) {
@ -991,7 +959,6 @@ export async function importFromMnemonic(
existingResult.columns,
existingResult.values,
)[0];
console.log("📥 DEBUG: Existing settings mapped:", existingData);
}
// Let's also check what's in the master settings
@ -999,7 +966,6 @@ export async function importFromMnemonic(
"SELECT * FROM settings WHERE id = ?",
["MASTER"],
);
console.log("📥 DEBUG: Master settings:", masterResult);
// Now try the UPDATE with better debugging
const updateResult = await databaseUtil.updateDidSpecificSettings(
@ -1009,29 +975,24 @@ export async function importFromMnemonic(
isRegistered: true,
},
);
console.log("📥 DEBUG: Test User #0 settings update result:", updateResult);
// Verify the settings were saved
const verifyResult = await platformService.dbQuery(
"SELECT * FROM settings WHERE accountDid = ?",
[newId.did],
);
console.log("📥 DEBUG: Settings after update attempt:", verifyResult);
if (verifyResult?.values?.length) {
const verifiedData = databaseUtil.mapColumnsToValues(
verifyResult.columns,
verifyResult.values,
)[0];
console.log("📥 DEBUG: Settings after update mapped:", verifiedData);
}
console.log("📥 DEBUG: Test User #0 settings applied");
}
// Check what settings were created
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
console.log("📥 DEBUG: Final settings after import:", settings);
}
/**

8
src/utils/PlatformServiceMixin.ts

@ -616,8 +616,6 @@ export const PlatformServiceMixin = {
did?: string,
defaults: Settings = {},
): Promise<Settings> {
console.log("💫 DEBUG: $accountSettings called with:", { did, defaults });
// Import the working retrieveSettingsForActiveAccount function
const { retrieveSettingsForActiveAccount } = await import(
"@/db/databaseUtil"
@ -626,18 +624,12 @@ export const PlatformServiceMixin = {
try {
// Use the working function that properly merges settings
const settings = await retrieveSettingsForActiveAccount();
console.log(
"💫 DEBUG: retrieveSettingsForActiveAccount returned:",
settings,
);
// Merge with any provided defaults
const mergedSettings = { ...defaults, ...settings };
console.log("💫 DEBUG: Final merged settings:", mergedSettings);
return mergedSettings;
} catch (error) {
console.log("💫 DEBUG: Error in $accountSettings:", error);
logger.error(
"[PlatformServiceMixin] Error in $accountSettings:",
error,

21
src/views/ImportAccountView.vue

@ -189,12 +189,6 @@ export default class ImportAccountView extends Vue {
* Uses importFromMnemonic utility for secure import
*/
public async onImportClick() {
console.log("🔑 DEBUG: Import process started");
console.log("🔑 DEBUG: Mnemonic length:", this.mnemonic.split(" ").length);
console.log("🔑 DEBUG: Derivation path:", this.derivationPath);
console.log("🔑 DEBUG: Should erase:", this.shouldErase);
console.log("🔑 DEBUG: API Server:", this.apiServer);
if (!this.mnemonic?.trim()) {
this.notify.warning(
"Seed phrase is required to import an account.",
@ -204,17 +198,14 @@ export default class ImportAccountView extends Vue {
}
try {
console.log("🔑 DEBUG: Calling importFromMnemonic...");
await importFromMnemonic(
this.mnemonic,
this.derivationPath,
this.shouldErase,
);
console.log("🔑 DEBUG: importFromMnemonic completed successfully");
// Check what was actually imported
const settings = await this.$accountSettings();
console.log("🔑 DEBUG: Post-import settings:", settings);
// Check account-specific settings
if (settings?.activeDid) {
@ -223,25 +214,13 @@ export default class ImportAccountView extends Vue {
"SELECT * FROM settings WHERE accountDid = ?",
[settings.activeDid],
);
console.log(
"🔑 DEBUG: Post-import account-specific settings:",
accountSettings,
);
} catch (error) {
console.log("🔑 DEBUG: Error checking post-import settings:", error);
}
}
this.notify.success("Account imported successfully!", TIMEOUTS.STANDARD);
this.$router.push({ name: "account" });
} catch (error: any) {
console.log("🔑 DEBUG: Import failed with error:", error);
console.log("🔑 DEBUG: Error details:", {
message: error.message,
stack: error.stack,
name: error.name,
});
this.$logError("Import failed: " + error);
this.notify.error(
error.message || "Failed to import account.",

52
src/views/OnboardMeetingListView.vue

@ -154,43 +154,32 @@ export default class OnboardMeetingListView extends Vue {
showPasswordDialog = false;
async created() {
console.log("📋 DEBUG: OnboardMeetingListView created() called");
const settings = await this.$accountSettings();
console.log("📋 DEBUG: Settings loaded:", settings);
// 🔍 TEMPORARY DEBUG: Check raw database for test user registration state
if (settings?.activeDid) {
console.log(
"📋 DEBUG: Checking raw database settings for DID:",
settings.activeDid,
);
try {
// Check master settings
const masterSettings = await this.$query(
"SELECT * FROM settings WHERE id = ?",
[1],
);
console.log("📋 DEBUG: Master settings:", masterSettings);
// Check account-specific settings
const accountSettings = await this.$query(
"SELECT * FROM settings WHERE accountDid = ?",
[settings.activeDid],
);
console.log("📋 DEBUG: Account-specific settings:", accountSettings);
// Check if there are any settings with isRegistered = 1
const registeredSettings = await this.$query(
"SELECT * FROM settings WHERE isRegistered = 1",
);
console.log("📋 DEBUG: All registered settings:", registeredSettings);
// Check all settings for this user
const allSettings = await this.$query("SELECT * FROM settings");
console.log("📋 DEBUG: All settings in database:", allSettings);
} catch (error) {
console.log("📋 DEBUG: Error checking raw database:", error);
logger.error("Error checking raw database:", error);
}
}
@ -199,86 +188,56 @@ export default class OnboardMeetingListView extends Vue {
this.firstName = settings?.firstName || "";
this.isRegistered = !!settings?.isRegistered;
console.log("📋 DEBUG: activeDid =", this.activeDid);
console.log("📋 DEBUG: apiServer =", this.apiServer);
console.log("📋 DEBUG: firstName =", this.firstName);
console.log("📋 DEBUG: isRegistered =", this.isRegistered);
if (this.isRegistered) {
console.log("📋 DEBUG: User is registered, checking for meetings...");
await this.fetchMeetings();
} else {
console.log("📋 DEBUG: User is NOT registered, skipping meeting check");
}
}
async fetchMeetings() {
console.log("📋 DEBUG: fetchMeetings() called");
console.log("📋 DEBUG: activeDid =", this.activeDid);
console.log("📋 DEBUG: apiServer =", this.apiServer);
this.isLoading = true;
try {
console.log("📋 DEBUG: Checking if user is attending a meeting...");
const headers = await getHeaders(this.activeDid);
console.log("📋 DEBUG: Headers obtained:", headers);
const response = await this.axios.get(
this.apiServer + "/api/partner/groupOnboardMember",
{ headers },
);
console.log("📋 DEBUG: Member response:", response.data);
if (response.data?.data) {
console.log(
"📋 DEBUG: User is attending a meeting, fetching details...",
);
const attendingMeetingId = response.data.data.groupId;
console.log("📋 DEBUG: Attending meeting ID:", attendingMeetingId);
const headers2 = await getHeaders(this.activeDid);
const response2 = await this.axios.get(
this.apiServer + "/api/partner/groupOnboard/" + attendingMeetingId,
{ headers: headers2 },
);
console.log("📋 DEBUG: Meeting details response:", response2.data);
if (response2.data?.data) {
console.log("📋 DEBUG: Setting attendingMeeting");
this.attendingMeeting = response2.data.data;
console.log("📋 DEBUG: attendingMeeting set:", this.attendingMeeting);
return;
} else {
console.log(
"📋 DEBUG: ERROR: No meeting details found for attending meeting",
);
this.$logAndConsole(
"Error fetching meeting for user after saying they are in one.",
true,
);
}
} else {
console.log("📋 DEBUG: User is NOT attending a meeting");
this.$logAndConsole(
"Error fetching meeting for user after saying they are in one.",
true,
);
}
console.log("📋 DEBUG: Fetching available meetings...");
const headers2 = await getHeaders(this.activeDid);
const response2 = await this.axios.get(
this.apiServer + "/api/partner/groupsOnboarding",
{ headers: headers2 },
);
console.log("📋 DEBUG: Available meetings response:", response2.data);
if (response2.data?.data) {
console.log("📋 DEBUG: Setting meetings list");
this.meetings = response2.data.data;
console.log("📋 DEBUG: meetings set:", this.meetings);
} else {
console.log("📋 DEBUG: No meetings found");
}
} catch (error: any) {
console.log("📋 DEBUG: Error fetching meetings:", error);
console.log("📋 DEBUG: Error response:", error.response?.data);
this.$logAndConsole(
"Error fetching meetings: " + errorStringForLog(error),
true,
@ -437,7 +396,6 @@ export default class OnboardMeetingListView extends Vue {
}
createMeeting() {
console.log("📋 DEBUG: createMeeting() called - routing to meeting setup");
this.$router.push({ name: "onboard-meeting-setup" });
}
}

25
src/views/OnboardMeetingSetupView.vue

@ -398,52 +398,27 @@ export default class OnboardMeetingView extends Vue {
}
async fetchCurrentMeeting() {
console.log("🏗️ DEBUG: fetchCurrentMeeting() called");
console.log("🏗️ DEBUG: activeDid =", this.activeDid);
console.log("🏗️ DEBUG: apiServer =", this.apiServer);
try {
const headers = await getHeaders(this.activeDid);
console.log("🏗️ DEBUG: Headers obtained:", headers);
const response = await this.axios.get(
this.apiServer + "/api/partner/groupOnboard",
{ headers },
);
console.log("🏗️ DEBUG: Meeting response:", response.data);
const queryPassword = this.$route.query["password"] as string;
console.log("🏗️ DEBUG: Query password:", queryPassword);
if (response?.data?.data) {
console.log("🏗️ DEBUG: Meeting found, setting currentMeeting");
this.currentMeeting = {
...response.data.data,
userFullName: this.fullName,
password: this.currentMeeting?.password || queryPassword || "",
};
console.log("🏗️ DEBUG: currentMeeting set:", this.currentMeeting);
} else {
console.log(
"🏗️ DEBUG: No meeting found, setting up blank meeting for creation",
);
this.newOrUpdatedMeetingInputs = this.blankMeeting();
console.log(
"🏗️ DEBUG: newOrUpdatedMeetingInputs set:",
this.newOrUpdatedMeetingInputs,
);
}
} catch (error: any) {
console.log("🏗️ DEBUG: Error fetching meeting:", error);
console.log("🏗️ DEBUG: Error response:", error.response?.data);
console.log(
"🏗️ DEBUG: Setting up blank meeting for creation due to error",
);
this.newOrUpdatedMeetingInputs = this.blankMeeting();
console.log(
"🏗️ DEBUG: newOrUpdatedMeetingInputs set:",
this.newOrUpdatedMeetingInputs,
);
}
}

Loading…
Cancel
Save