Context
In production, developers need visibility into what BurnerGuard is doing — how many emails are being checked, what's matching, how often the allowlist overrides. The library should provide hooks for consumers to plug in their own logging, metrics, or alerting systems without BurnerGuard depending on any specific logging framework.
Proposed API
Event hooks at creation
const guard = await BurnerGuard.create({
onVerify: (result) => {
logger.info('BurnerGuard verify', {domain: result.domain, isMatch: result.isMatch});
},
onMatch: (result) => {
logger.warn('Disposable email detected', {domain: result.domain, matchedOn: result.matchedOn});
},
onError: (error, context) => {
logger.error('BurnerGuard error', {error: error.message, context});
}
});
Available hooks
| Hook |
Fires when |
Payload |
onVerify |
Every verify() call completes |
VerifyResult |
onMatch |
verify() returns isMatch: true |
VerifyResult |
onAllowlistOverride |
A blocklist match was overridden by the allowlist |
VerifyResult |
onError |
An error occurs (service mode failure, file load error, etc.) |
Error + context |
onDegradation |
Service mode falls back to static (see #11) |
VerifyResult + reason |
Design principles
- No built-in logger — zero dependencies means no winston, pino, bunyan
- Hooks are optional — if not provided, the library is silent
- Hooks are fire-and-forget — errors in hooks don't affect
verify() results
- Hooks receive readonly data — consumers can't mutate results through hooks
Acceptance criteria
Priority: 🟢 Nice-to-have — polish for production use
Context
In production, developers need visibility into what BurnerGuard is doing — how many emails are being checked, what's matching, how often the allowlist overrides. The library should provide hooks for consumers to plug in their own logging, metrics, or alerting systems without BurnerGuard depending on any specific logging framework.
Proposed API
Event hooks at creation
Available hooks
onVerifyverify()call completesVerifyResultonMatchverify()returnsisMatch: trueVerifyResultonAllowlistOverrideVerifyResultonErrorError+ contextonDegradationVerifyResult+ reasonDesign principles
verify()resultsAcceptance criteria
BurnerGuardOptionsverify())Priority: 🟢 Nice-to-have — polish for production use