Skip to main content

Notifications & Preferences

PreferenceAwareNotifier centralizes contact resolution, preference checks, and deduplication before emitting notifications.

Usage

import { PreferenceAwareNotifier } from '@digiwedge/auth';
import { NotificationType } from '@digiwedge/messaging-notifications';
import { Channel } from '@prisma/messaging';

await notifier.sendIfAllowed(
{
scope: NotificationType.ACTIVITY_FEED,
channel: Channel.EMAIL,
tenantId,
identifiers: { authUserId: user.id, email: user.email },
variables: { event: 'login_success', ipAddress, userAgent },
},
{ dedupKey: jti, failOpenOnResolveError: true },
);

Notes

FeatureDescription
Tenant IDProvide tenantId for strict preference enforcement; omit only for non-critical flows
OTP scopeUse scope='OTP' and fail-open on lookup errors to avoid lockouts
Dedup keyKeeps downstream queues idempotent
Missing templatesLogged and the channel is skipped without blocking other sends