Skip to content

Commit fda3a91

Browse files
committed
refactor(nostr): Reduce noisy logging in notification service
- Removed excessive logging for every event received in nostr-notification.service.ts. - Changed logging for receivedEvent to only log on the first event from each relay. - Made decryption failure logs silent, as these are expected for events not intended for the current user.
1 parent 4897d10 commit fda3a91

1 file changed

Lines changed: 5 additions & 23 deletions

File tree

src/app/services/nostr-notification.service.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -219,37 +219,25 @@ export class NostrNotificationService {
219219
let eoseCount = 0;
220220
let eventCount = 0;
221221

222-
console.log(
223-
`[Nostr] Subscription starting - will log EVERY event received`,
224-
);
225-
226222
const sub = this.pool.subscribeMany(this.defaultRelays, filter, {
227223
onevent: (event: Event) => {
228224
eventCount++;
229-
console.log(`[Nostr] 🔔 EVENT #${eventCount} RECEIVED:`, {
230-
id: event.id,
231-
kind: event.kind,
232-
pubkey: event.pubkey?.slice(0, 16) + "...",
233-
created_at: event.created_at,
234-
created_at_human: new Date(event.created_at * 1000).toISOString(),
235-
tags: event.tags,
236-
content_length: event.content?.length || 0,
237-
});
225+
// Only process event, don't log every single one (too noisy - thousands of events)
238226
this.handleIncomingEvent(event, nostrPrivate);
239227
},
240228

241229
// Track which relays are responding (uses relay.url from AbstractRelay)
242230
receivedEvent: (relay: any, id: string) => {
243231
const relayUrl = relay.url;
244-
console.log(`[Nostr] 📨 receivedEvent from ${relayUrl}: ${id}`);
245232

233+
// Only log on first event from each relay (connection confirmation)
246234
if (!this.relayFirstSeen.has(relayUrl)) {
247235
this.relayFirstSeen.set(relayUrl, Date.now());
248236
console.log(`[Nostr] ✅ ${relayUrl} connected and responding`);
249237
this.updateRelayStatus(relayUrl, true);
250238
}
251239

252-
// Track event counts for statistics
240+
// Track event counts for statistics (silent)
253241
const count = (this.relayEventCount.get(relayUrl) || 0) + 1;
254242
this.relayEventCount.set(relayUrl, count);
255243
},
@@ -311,18 +299,12 @@ export class NostrNotificationService {
311299
unwrapped = nip59.unwrapEvent(event, nostrPrivate);
312300
} catch (decryptError) {
313301
// Expected - this event is encrypted for a different recipient
314-
// TEMP: Add logging for debugging
315-
console.log(
316-
`[Nostr] Decryption failed for event ${event.id.slice(0, 8)}... (Error: ${decryptError.message})`,
317-
);
302+
// Silent fail - this is normal behavior (most events are not for us)
318303
return;
319304
}
320305

321306
if (!unwrapped) {
322-
// SILENT: Don't log expected decryption failures
323-
console.log(
324-
`[Nostr] Event ${event.id.slice(0, 8)} unwrapped to null/undefined (not for us)`,
325-
);
307+
// Silent fail - event not for us
326308
return;
327309
}
328310

0 commit comments

Comments
 (0)