Skip to content

Implement Comprehensive Fraud Detection Logging - #497

Open
Buildwithlevo wants to merge 1 commit into
Pidoko257:mainfrom
Buildwithlevo:feat/fraud-detection-comprehensive-logging
Open

Implement Comprehensive Fraud Detection Logging#497
Buildwithlevo wants to merge 1 commit into
Pidoko257:mainfrom
Buildwithlevo:feat/fraud-detection-comprehensive-logging

Conversation

@Buildwithlevo

Copy link
Copy Markdown

Summary

This PR implements comprehensive fraud detection logging to help security teams investigate false positives and improve detection rules.

Changes

  • FraudService (src/services/fraud.ts):

    • Replaced all console.log/warn calls with centralized pino logger
    • Added structured logging for each of the 12 fraud heuristics:
      • Velocity check
      • Rapid succession
      • Amount anomaly
      • Geographic anomaly
      • High-risk phone number
      • IP geolocation mismatch
      • Unusual hours
      • Pattern detection (failed attempts)
      • Device fingerprint anomaly
      • New account risk
      • KYC level risk
      • Transaction frequency spike
    • Added comprehensive fraud detection result logging with score, risk level, recommended action, heuristic details, and duration
    • Added structured logging for review queue operations
  • FraudDetectionMiddleware (src/middleware/fraudDetection.ts):

    • Replaced console.log/warn/error with centralized pino logger
    • Added structured logging for suspicious transaction handling
  • Tests (tests/services/fraud.test.ts):

    • Updated tests to mock Redis client properly
    • Updated tests to use FraudTransactionInput interface
    • Updated tests to use pino logger spies instead of console spies
    • Fixed test expectations to match new scoring logic

Issue References

Closes #362
Closes #360
Closes #361
Closes #359

- Replace console.log/warn with centralized pino logger in FraudService and FraudDetectionMiddleware
- Add structured logging for each fraud heuristic triggered (velocity, rapid_succession, amount_anomaly, geographic_anomaly, high_risk_number, ip_geolocation_mismatch, unusual_hours, pattern_detection, device_anomaly, new_account_risk, kyc_risk, frequency_spike)
- Log comprehensive fraud detection results with score, risk level, recommended action, and heuristic details
- Add detailed logging for review queue operations
- Update tests to work with new logging implementation

Closes Pidoko257#362
Closes Pidoko257#360
Closes Pidoko257#361
Closes Pidoko257#359
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@Buildwithlevo 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant