From b8ba41d088db3c36a6358b6c027f55cdb042eee7 Mon Sep 17 00:00:00 2001 From: padreug Date: Mon, 8 Sep 2025 14:09:20 +0200 Subject: [PATCH] Enhance logging in MerchantStore and NostrmarketAPI for better debugging - Update the MerchantStore component to include detailed logging during merchant profile creation, capturing wallet ID and admin key details. - Improve NostrmarketAPI request logging to include method type, headers with masked API key, and a preview of the request body. These changes aim to facilitate easier debugging and provide more context during API interactions and merchant profile creation. --- src/modules/market/components/MerchantStore.vue | 6 +++++- src/modules/market/services/nostrmarketAPI.ts | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/modules/market/components/MerchantStore.vue b/src/modules/market/components/MerchantStore.vue index ad6e366..0dcac61 100644 --- a/src/modules/market/components/MerchantStore.vue +++ b/src/modules/market/components/MerchantStore.vue @@ -663,7 +663,11 @@ const createMerchantProfile = async () => { merchantCreateError.value = null try { - console.log('Creating merchant profile...') + console.log('Creating merchant profile...', { + walletId: wallet.id, + adminKeyLength: wallet.adminkey.length, + adminKeyPreview: wallet.adminkey.substring(0, 8) + '...' + }) // Create merchant with empty config, exactly like the nostrmarket extension const merchantData = { diff --git a/src/modules/market/services/nostrmarketAPI.ts b/src/modules/market/services/nostrmarketAPI.ts index 2f584ab..11bfcae 100644 --- a/src/modules/market/services/nostrmarketAPI.ts +++ b/src/modules/market/services/nostrmarketAPI.ts @@ -97,13 +97,22 @@ export class NostrmarketAPI extends BaseService { ): Promise { const url = `${this.baseUrl}/nostrmarket${endpoint}` - this.debug('NostrmarketAPI request:', { endpoint, fullUrl: url }) - const headers: HeadersInit = { 'Content-Type': 'application/json', 'X-API-KEY': walletKey, ...options.headers, } + + this.debug('NostrmarketAPI request:', { + endpoint, + fullUrl: url, + method: options.method || 'GET', + headers: { + 'Content-Type': headers['Content-Type'], + 'X-API-KEY': walletKey.substring(0, 8) + '...' + walletKey.substring(walletKey.length - 4) + }, + bodyPreview: options.body ? JSON.stringify(JSON.parse(options.body as string), null, 2) : undefined + }) const response = await fetch(url, { ...options,