From c58a1fc92548ac5866be2f95b45edc559a5dfda2 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 24 Sep 2026 09:50:21 -0400 Subject: [PATCH] fix: set alert_type on OPTIONS-ping and registration alerts (#154) * fix: set alert_type on OPTIONS-ping and registration alerts The three writeAlerts() calls in sip-trunk-options-ping.js and the two in regbot.js omitted alert_type, so the alerts were stored as 'undefined'. Use AlertType.SIP_GATEWAY_OPTIONS_FAILURE / SIP_GATEWAY_REGISTRATION_FAILURE. Co-Authored-By: Claude Opus 5.5 * chore: bump @jambonz/time-series to ^0.5.4 Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- lib/regbot.js | 4 +++- lib/sip-trunk-options-ping.js | 5 ++++- package-lock.json | 9 +++++---- package.json | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/regbot.js b/lib/regbot.js index 90553f5..b2acc4f 100644 --- a/lib/regbot.js +++ b/lib/regbot.js @@ -176,7 +176,7 @@ class Regbot { async register(srf) { const { createEphemeralGateway } = srf.locals.realtimeDbHelpers; const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers; - const { writeAlerts, localSIPDomain } = srf.locals; + const { writeAlerts, AlertType, localSIPDomain } = srf.locals; // stamp this attempt so a late/stale response (e.g. after a watchdog-driven retry) is ignored const epoch = ++this.epoch; try { @@ -283,6 +283,7 @@ class Regbot { // eslint-disable-next-line max-len this.logger.info(`Disabling Outbound Registration for carrier ${carrier.name} (sid:${carrier.voip_carrier_sid})`); writeAlerts({ + alert_type: AlertType.SIP_GATEWAY_REGISTRATION_FAILURE, account_sid: carrier.account_sid, service_provider_sid: carrier.service_provider_sid, // eslint-disable-next-line max-len @@ -293,6 +294,7 @@ class Regbot { // eslint-disable-next-line max-len this.logger.info(`Deactivating carrier ${carrier.name} (sid:${carrier.voip_carrier_sid}) due to registration errors`); writeAlerts({ + alert_type: AlertType.SIP_GATEWAY_REGISTRATION_FAILURE, account_sid: carrier.account_sid, service_provider_sid: carrier.service_provider_sid, // eslint-disable-next-line max-len diff --git a/lib/sip-trunk-options-ping.js b/lib/sip-trunk-options-ping.js index a714fc9..147267f 100644 --- a/lib/sip-trunk-options-ping.js +++ b/lib/sip-trunk-options-ping.js @@ -25,7 +25,7 @@ class OptionsBot { async options(srf) { const { lookupCarrierBySid } = srf.locals.dbHelpers; - const { writeAlerts, logger, realtimeDbHelpers } = srf.locals; + const { writeAlerts, AlertType, logger, realtimeDbHelpers } = srf.locals; try { const req = await srf.request({ uri: this.uri, @@ -43,6 +43,7 @@ class OptionsBot { const carrier = await lookupCarrierBySid(this.voip_carrier_sid); if (carrier) { writeAlerts({ + alert_type: AlertType.SIP_GATEWAY_OPTIONS_FAILURE, account_sid: carrier.account_sid, service_provider_sid: carrier.service_provider_sid, // eslint-disable-next-line max-len @@ -58,6 +59,7 @@ class OptionsBot { // eslint-disable-next-line max-len this.logger.info(`Disabling Options ping for ${this.ipv4} in carrier ${carrier.name}:${carrier.voip_carrier_sid} due to ${res.status}`); writeAlerts({ + alert_type: AlertType.SIP_GATEWAY_OPTIONS_FAILURE, account_sid: carrier.account_sid, service_provider_sid: carrier.service_provider_sid, // eslint-disable-next-line max-len @@ -80,6 +82,7 @@ class OptionsBot { const carrier = await lookupCarrierBySid(this.voip_carrier_sid); if (carrier) { writeAlerts({ + alert_type: AlertType.SIP_GATEWAY_OPTIONS_FAILURE, account_sid: carrier.account_sid, service_provider_sid: carrier.service_provider_sid, // eslint-disable-next-line max-len diff --git a/package-lock.json b/package-lock.json index 5f8dcd9..b67f2b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@jambonz/mw-registrar": "^0.2.7", "@jambonz/realtimedb-helpers": "^0.8.21", "@jambonz/stats-collector": "^0.1.10", - "@jambonz/time-series": "^0.2.8", + "@jambonz/time-series": "^0.5.4", "debug": "^4.4.3", "drachtio-mw-registration-parser": "^0.1.2", "drachtio-mw-response-time": "^1.0.2", @@ -596,9 +596,10 @@ } }, "node_modules/@jambonz/time-series": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.13.tgz", - "integrity": "sha512-Kj+l+YUnI27zZA4qoPRzjN7L82W7GuMXYq9ttDjXQ0ZBIdOLAzJjB6R3jJ3b+mvoNEQ6qG5MUtfoc6CpTFH5lw==", + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.5.4.tgz", + "integrity": "sha512-XNGSsNdYSD9cdBoaZ4xOWbNBNMLMpd6lfJ/b6ws3D4rEQ3UYg/vDtnakW8XMjMTAHq8lGJNrLN7gMgF6JLoCZw==", + "license": "MIT", "dependencies": { "debug": "^4.3.1", "influx": "^5.9.3" diff --git a/package.json b/package.json index fc76c9f..f3b48d0 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@jambonz/mw-registrar": "^0.2.7", "@jambonz/realtimedb-helpers": "^0.8.21", "@jambonz/stats-collector": "^0.1.10", - "@jambonz/time-series": "^0.2.8", + "@jambonz/time-series": "^0.5.4", "debug": "^4.4.3", "drachtio-mw-registration-parser": "^0.1.2", "drachtio-mw-response-time": "^1.0.2",