Skip to content

feat: add structured logging for alert registration and deletion - #527

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
wagmiiii:feat/505-structured-log-alerts
Jun 27, 2026
Merged

feat: add structured logging for alert registration and deletion#527
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
wagmiiii:feat/505-structured-log-alerts

Conversation

@wagmiiii

Copy link
Copy Markdown
Contributor

Closes #505

Summary

Adds structured observability logs when price alerts are successfully registered or manually cancelled. This allows monitoring alert activity without querying the database and provides debugging context for unexpectedly fired alerts.

What Changed

  • Added logger.info to createAlert emitting alert_id, creator_id, direction, target_price, and registered_at.
  • Added logger.info to deleteAlert emitting alert_id, creator_id, and cancelled_at.
  • Created a maskWalletAddress helper inside the alert service to log wallet addresses safely.
  • Updated alert.service.test.ts to mock logger.info and assert payload structures.

Key Design Decisions

  • Included the masked wallet_address explicitly in the log payloads. Because alerts operate on behalf of a wallet, auditing who acted is highly logical and provides useful context without leaking full addresses.
  • Used the existing toNumber helper inside the service to safely serialise Prisma Decimal instances for the logger.

Acceptance Criteria

  • Registration log emitted with all five fields
  • Cancellation log emitted on manual delete
  • Wallet address masked (first 4 and last 4 characters), callback URL absent from all logs

Test Output & Coverage

  • 7/7 tests passed in alert.service.test.ts
  • Tests cover both successful logs, ensuring masked data correctness and the explicit absence of callback_url.

Security Note

PII is completely isolated. callback_url is omitted entirely from these logs, and the wallet_address is strictly masked to its first and last 4 characters (GAAA***AAAA) before passing to the logger payload.

Follow-ups

  • Consider standardising wallet address masking across modules (currently there's a slightly different maskAddress in ownership.service.ts and wallet.utils.ts).

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@wagmiiii Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093
Chucks1093 merged commit 9690b7a into accesslayerorg:main Jun 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add structured log for alert registration with creator ID, direction, and target price

2 participants