diff --git a/src/alerts.js b/src/alerts.js index b24ac56..fc062cd 100644 --- a/src/alerts.js +++ b/src/alerts.js @@ -22,8 +22,8 @@ function legacy(alert) { case 'streak': return ['watch_streak', String(alert.streak)]; case 'hype': return ['hype_train', alert.phase]; case 'tip': return ['tip', `${alert.amount} ${alert.currency}`]; - case 'redeem': return [{ reward: 'channel_points', auto_reward: 'auto_reward', power_up: 'power_up' }[alert.kind], alert.key]; - default: return [alert.type, null]; + case 'redeem': return [{ reward: 'channel_points', auto_reward: 'auto_reward', power_up: 'power_up', custom_power_up: 'custom_power_up' }[alert.kind] || 'redeem', alert.key]; + default: return [alert.type || 'alert', null]; } } diff --git a/src/dispatch.js b/src/dispatch.js index 41fa79e..4b22c8e 100644 --- a/src/dispatch.js +++ b/src/dispatch.js @@ -32,7 +32,9 @@ function dispatchEvent(eventType, eventDetail = null, username = null, data = nu console.log(`[dispatch] Fired action ${action.id} (${action.name}) — event: ${eventType}, user: ${username}`); } - db.logActivity(eventType, eventDetail, username, data, fired, replay); + // the log must never take the server down (a bad row once crashed it mid-stream) + try { db.logActivity(eventType || 'unknown', eventDetail, username, data, fired, replay); } + catch (e) { console.error(`[dispatch] activity log failed (${eventType}):`, e.message); } } module.exports = { dispatchEvent };