Skip to main content

๐Ÿ”” Notification & Logging Standards

Overviewโ€‹

The RABS notification system provides a unified pipeline for delivering system events to users as toasts, badge updates, sounds, and log entries. All new features must use the DB2 pipeline (syslog schema). The legacy DB1 logging path exists for backward compatibility only.

Backend Pipeline (DB2)โ€‹

The modern notification pipeline flows through the syslog schema:

emitEntries.emitEntry()
โ†“
syslog.entries (persisted)
โ†“
bus.emit('syslog.entry.created')
โ†“
notifications-interpreter
โ†“
Expand targets (users, roles, curated)
โ†“
Determine tile routing via context.kind
โ†“
Insert โ†’ syslog.notifications
โ†“
SSE broadcast to connected clients

Legacy Pipeline (DB1)โ€‹

emitLog.emitLog() โ†’ admin.system_logs

Do NOT use the legacy pipeline for new features. It exists solely for backward compatibility with older modules.

Key Backend Filesโ€‹

FilePurpose
emit-entries.jsemitEntry() โ€” primary entry point for all new notifications
notifications-interpreter.jsExpands targets, determines routing, inserts notifications
emit-log-db2.jsDB2 syslog entry writer
logger.jsStructured console/file logging utility

emitEntry() Call Shapeโ€‹

Every notification originates from a call to emitEntry() with this structure:

{
platform, // e.g. 'admin', 'bot'
type, // event type identifier
delivery, // 'silent' | 'normal' | 'push' | 'alert'
bucket_slug, // context bucket for grouping
targets: {
users, // array of user IDs
roles, // array of role slugs
curated // custom target list
},
message, // human-readable notification text
context: {
kind, // routing key โ€” determines tile, sound, behaviour
// ...additional context fields
}
}

Frontend Notification Hubโ€‹

SSE Stream (notifications-hub.js)โ€‹

The frontend connects to a Server-Sent Events stream at:

GET /api/v1/notifications/stream

Three event types are emitted:

EventPurpose
badgeUpdate a tile's unread count
toastDisplay a toast notification
logAppend to the activity log

Toast System (error-handler.js)โ€‹

Toast Functionsโ€‹

FunctionDefault DurationUse Case
showToast(options)ConfigurableGeneral-purpose toast
showSuccess(message)DefaultConfirm successful operations
showError(message)7 secondsDisplay error messages
showWarning(message)6 secondsDisplay warning messages
showInfo(message)DefaultInformational messages

Toast Optionsโ€‹

{
type, // 'success' | 'error' | 'warning' | 'info'
duration, // milliseconds (0 = sticky)
title, // bold heading text
dismissible, // boolean โ€” show close button
icon, // Bootstrap icon class
onClose // callback when dismissed
}

Quick Access Tilesโ€‹

The header displays a 3ร—2 grid of quick-access tiles. Each tile shows a badge count driven by the context.kind field of incoming notifications.

TileIconBadge Source (context.kind)
Calendarcalendar4calendar.*
Inboxenvelopeemail.*
Profileperson-circleprofile*
Taskslist-tasktask*
Messengerchat-dotschat.*
Commstelephonecomms.*

context.kind Routingโ€‹

The context.kind field determines which tile receives the badge update and, where applicable, the notification sound:

Kind PatternRouted TileNotes
chat.*MessengerAll chat-related events
comms.*CommsPhone, SMS, voicemail
email.*InboxEmail receive/send events
calendar.*CalendarAppointments, reminders
profile*ProfileProfile updates, mentions
task*TasksTask assignments, completions
forum.*TasksForum posts route to tasks tile
auth.*Bell onlyLogin, session events โ€” no tile
presence.*Toast onlyOnline/offline โ€” no tile or badge

Delivery Modesโ€‹

Four delivery modes control how prominently a notification surfaces to the user:

ModeToastBellTile BadgeSoundNotes
silentNoNoNoYesSound only โ€” background awareness
normal5 secondsYesYesYesStandard notification
pushStickyYesYesYesRequires manual dismiss
alertStickyYesYesYesRequires explicit acknowledgement

Sound Mappingโ€‹

Thirteen notification sounds are available, selected based on context.kind and event type:

Sound FileTrigger Context
message_mention.wavDirect mention in chat
message_in.wavNew chat message
sms_in.mp3Incoming SMS
email.mp3New email received
phone1.wavIncoming call
error.wavError notifications
success.wavSuccess confirmations
presence_online.wavUser came online
birthday.wavBirthday notification
notification.wavGeneric notification
alert.wavAlert-level events
task_complete.wavTask completed
reminder.wavScheduled reminders