npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cds-event-monitoring

v0.1.2

Published

CAP cds-plugin providing event monitoring service out-of-the-box.

Readme

CDS Event Monitoring Plugin

The Event Monitoring Plugin provides a robust event monitoring service capable of hooking into multiple topics and storing event data in a database table. It exposes this data through a CDS service that users can extend as needed. This is perfect if you want to keep track of your event data and need retry/resend functionalities. For an example of how to use this package, refer to the testProject folder of the github repository.

Features

  • Event Monitoring for Multiple Topics
  • Stores event data in a customizable CDS entity/table.
  • Provides a default CDS service (EventMonitoringService) to interact with event data.
  • Actions to resend individual events, all events, or dead-message queue events.
  • Monitors and consumes messages from specified DMQs.
  • Configurable retentionInDays setting to automatically delete old events.
  • Duplicate Event Filtering

Table of Content

Setup

To enable event monitoring, add this plugin package to your project with the following command:

 npm add cds-event-monitoring

Adding Required Configurations

This package requires specific configurations in your package.json or .cdsrc.json.

  "cds": {
    "requires": {
      ...
      "event-monitoring": {
        "retentionInDays": 7,
        "topics": [
          "<namespace>/<topic-name>"
        ],
        "dead-message-queues": [
          "<namespace>/<dead-message-queue-name>"
        ]
      }
    }
  }

| Configuration Option | Type | Description | | -------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | topics | Array of Strings | Defines the topics that the package will monitor. | | retentionInDays (optional) | Integer | Specifies the number of days to retain events in the database. Events are deleted when a new event is detected. If no events are received, no deletion occurs. | | ignoreIdenticalEvents (optional) | Boolean | If you want to ignore events with the same data (e.g., from retries), set this flag to true. Default: false. | | dead-message-queues (optional) | Array of Strings | Defines the dead-message queues that will be monitored. Be aware that messages from the DMQ will be consumed and acknowledged. |

Default service definition

The package includes a default service definition, providing an endpoint for interacting with event data.

service EventMonitoringService {

  action resendAll(topic : String, startTimestamp : Timestamp, endTimestamp : Timestamp);
  action resendDeadMessageQueue(queue : String);
  action sendToTopic(topic : String, message : LargeString);

  entity Events as projection on EventData
    actions {
      action resend();
      action resendToTopic(topic : String);
    };

}

The resend action allows requeuing the event back into the original topic.

Extending the Service

To extend the existing service, add a new CDS service to your project and import the event monitoring service from the package:

using {EventMonitoringService} from 'cds-event-monitoring/srv';

extend EventMonitoringService with @(requires: 'admin');

In this example, the service is extended with a custom scope.

Extending the Service and Event Logic

You can create your own service implementation that extends the existing one. Use the @impl annotation to reference an implementation file.

extend EventMonitoringService with @(impl: 'srv/event-ext.js');

Next, import the existing service implementation and extend it with your own logic:

const cds = require('@sap/cds');
const EventServiceHandler = require('cds-event-monitoring/srv');
module.exports = class EventServiceExt extends EventServiceHandler {
  async init() {
    const messaging = await cds.connect.to('messaging');

    // extend messaging behavior
    messaging.on('*', (msg) => {
      const { data, event } = msg;
      console.log(data);
      console.log(event);
    });

    // hook into CRUD events
    this.after('each', (data) => {
      console.log(data);
    });

    return super.init();
  }
};

Note: New messaging handlers will execute before the event logic provided by the package, ensuring you do not overwrite existing logic.

Service extensions are also compatible with TS projects.

import cds from '@sap/cds';

import EventServiceHandler from 'cds-event-monitoring/srv';

export default class EventServiceExt extends EventServiceHandler {
  async init() {
    const messaging = await cds.connect.to('messaging');

    // extend messaging behavior
    messaging.on('*', (msg) => {
      const { data, event } = msg;
      console.log(data);
      console.log(event);
    });

    return super.init();
  }
}

Fiori annotations

The Events includes several predefined Fiori annotations, which can be used and extended to develop an event monitoring UI. You can find an example in the testProject/app folder of the github repository.

Extending the database table

If you want to store specific fields in separate database columns (for example for searching purposes) you can do so, by extending the cds entity EventData.

using {event.monitoring.EventData} from 'cds-event-monitoring/db';

extend EventData with {
  description : String;
}

The new fields will be automatically filled with the data of the incoming event. Make sure, that a corresponding data field is present in the event body. In this example e.g.

{
  "data": {
    ...,
    "description": "<description-string>"
  }
}