diff --git a/src/metrics.ts b/src/metrics.ts index 2cb3eb2d..7fe75a8f 100644 --- a/src/metrics.ts +++ b/src/metrics.ts @@ -141,3 +141,9 @@ export const relayPoolSubscriptionsSizeGauge = new Gauge({ name: 'ditto_relay_pool_subscriptions_size', help: 'Number of active subscriptions to the relay pool', }); + +export const webPushNotificationsCounter = new Counter({ + name: 'ditto_web_push_notifications_total', + help: 'Total number of Web Push notifications sent', + labelNames: ['type'], +}); diff --git a/src/pipeline.ts b/src/pipeline.ts index 8f2f284d..9125c505 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -9,7 +9,7 @@ import { Conf } from '@/config.ts'; import { DittoTables } from '@/db/DittoTables.ts'; import { DittoPush } from '@/DittoPush.ts'; import { DittoEvent } from '@/interfaces/DittoEvent.ts'; -import { pipelineEventsCounter, policyEventsCounter } from '@/metrics.ts'; +import { pipelineEventsCounter, policyEventsCounter, webPushNotificationsCounter } from '@/metrics.ts'; import { RelayError } from '@/RelayError.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { hydrateEvents } from '@/storages/hydrate.ts'; @@ -67,15 +67,21 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise + Promise.all([ + streamOut(event), + webPush(event), + ]) + ) + .catch(console.warn); } } @@ -280,6 +286,7 @@ async function webPush(event: NostrEvent): Promise { }; await DittoPush.push(subscription, message); + webPushNotificationsCounter.inc({ type: notification.type }); } }