Phase 2 of legacy notification retirement: drop the production push refresh chain and dead debug/composable paths while keeping FCM registration, AlertSearch, daily reminder, and dual notifications intact.
77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
/**
|
|
* Shared observability helpers for notification flows (console + debug panel).
|
|
*/
|
|
|
|
import { logNotification } from "./NotificationDebugEvents";
|
|
|
|
export function truncateFcmTokenForLog(token: string): string {
|
|
const t = token.trim();
|
|
if (t.length <= 24) {
|
|
return t;
|
|
}
|
|
return `${t.slice(0, 12)}…${t.slice(-8)}`;
|
|
}
|
|
|
|
export function logPushNotificationReceived(notification: {
|
|
title?: string;
|
|
data?: Record<string, unknown>;
|
|
}): void {
|
|
const type =
|
|
typeof notification.data?.type === "string"
|
|
? notification.data.type
|
|
: "(none)";
|
|
logNotification(`pushNotificationReceived type=${type}`, {
|
|
title: notification.title,
|
|
dataType: type,
|
|
});
|
|
}
|
|
|
|
export function logPushNotificationActionPerformed(action: {
|
|
actionId?: string;
|
|
notification?: { title?: string; data?: Record<string, unknown> };
|
|
}): void {
|
|
const type =
|
|
typeof action.notification?.data?.type === "string"
|
|
? action.notification.data.type
|
|
: "(none)";
|
|
logNotification(
|
|
`pushNotificationActionPerformed actionId=${action.actionId ?? "(none)"} type=${type}`,
|
|
{
|
|
actionId: action.actionId,
|
|
dataType: type,
|
|
},
|
|
);
|
|
}
|
|
|
|
export function logTokenRegistrationStarted(token: string): void {
|
|
logNotification("Token registration started", {
|
|
token: truncateFcmTokenForLog(token),
|
|
});
|
|
}
|
|
|
|
export function logTokenRegistrationSuccess(token: string): void {
|
|
logNotification("Token registration success", {
|
|
token: truncateFcmTokenForLog(token),
|
|
});
|
|
}
|
|
|
|
export function logTokenRegistrationSkippedDuplicate(token: string): void {
|
|
logNotification("Token registration skipped (duplicate token)", {
|
|
token: truncateFcmTokenForLog(token),
|
|
});
|
|
}
|
|
|
|
export function logTokenRegistrationFailure(
|
|
token: string,
|
|
error: unknown,
|
|
): void {
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
logNotification(`Token registration failure: ${message}`, {
|
|
token: truncateFcmTokenForLog(token),
|
|
});
|
|
}
|
|
|
|
export function logNotificationClearing(method: string): void {
|
|
logNotification(`Clearing notifications via ${method}`);
|
|
}
|