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.
This commit is contained in:
padreug 2025-09-08 14:09:20 +02:00
parent 4ecec1aa78
commit b8ba41d088
2 changed files with 16 additions and 3 deletions

View file

@ -663,7 +663,11 @@ const createMerchantProfile = async () => {
merchantCreateError.value = null merchantCreateError.value = null
try { 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 // Create merchant with empty config, exactly like the nostrmarket extension
const merchantData = { const merchantData = {

View file

@ -97,13 +97,22 @@ export class NostrmarketAPI extends BaseService {
): Promise<T> { ): Promise<T> {
const url = `${this.baseUrl}/nostrmarket${endpoint}` const url = `${this.baseUrl}/nostrmarket${endpoint}`
this.debug('NostrmarketAPI request:', { endpoint, fullUrl: url })
const headers: HeadersInit = { const headers: HeadersInit = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'X-API-KEY': walletKey, 'X-API-KEY': walletKey,
...options.headers, ...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, { const response = await fetch(url, {
...options, ...options,