Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

February Developer Challenge - CAP Plugins: Week 4

thomas_jung
Developer Advocate
Developer Advocate

If you missed week 1, you could find all the details: here
If you missed week 2, you could find all the details: here
If you missed week 3, you could find all the details: here

Now that the challenge is complete: here is my sample solution: jung-thomas/dev-challenge-feb-2024: Developer Challenge February 2024 (github.com)

For the final week we are going to go all in. We have several remaining plugins and your challenge this week is to integrate all of them into your application.

Audit Logging

The new Audit Log plugin provides out-of-the box support for logging personal data-related operations with the SAP Audit Log Service. All we need is annotations of respective entities and fields.

https://github.com/cap-js/audit-logging

Add the Audit Logging plugin to your application and add Personal Data Annotations to the Books entity. Share your screenshot of the audit entries after accessing the entity. 

auditLog.png

Bonus: Add a custom audit log entry when the submitOrder action is triggered 
auditLog2.png

Notifications

The Notifications plugin provides integration with the SAP Alert Notifications service to send notifications via email, Slack, Microsoft Teams, or SAP Fiori notifications. The client is implemented as a CAP service, which gives us a very simple programmatic API

https://github.com/cap-js/notifications

Add the Notifications plugin to your application. Throw a notification every time ListOfBooks entity is read and a discount has been applied. Post a screenshot of your notification in the log. 
notificationService.png

Telemetry

The Telemetry plugin provides observability features such as tracing and metrics, including automatic OpenTelemetry instrumentation. Simply add the plugin to your project and you will find telemetry output written to the console

https://github.com/cap-js/telemetry

Add the Telemetry plugin to your application. Post a screenshot of the telemetry output in our log.

telemetry.png

26 REPLIES 26

satya-dev
Participant

brunonalon
Explorer

smok1
Explorer

Audit Logging:

smok1_0-1709202715154.png

Bonus: Submit Order:

smok1_1-1709202750592.png

Notifications:

smok1_2-1709202783606.png

Telemetry:

smok1_3-1709202827028.png

 

 

 

MarcelFarkas
Explorer

ajmaradiaga
Developer Advocate
Developer Advocate

CAP Plugins - screenshots

Audit LoggingAudit Logging

 

NotificationNotification

TelemetryTelemetry

SandipAgarwalla
Active Contributor

Does it matter where you write the annotations for these plug-ins? I added annotations for audit log, but I can not see those details in console when I access the entity. 

Thanks

I had the same issue. Had to debug the plugin to find out why. There must be at least a 

@PersonalData.IsPotentiallySensitive annotation for it to work. It won't work if only 
@PersonalData.IsPotentiallyPersonal exist, which i find it weird. Not sure if this is a bug or by design?
Maybe @thomas_jung can shed some light.

thomas_jung
Developer Advocate
Developer Advocate

Sounds like you generally got your solution. It shouldn't matter where you place your annotations as long as the file is reachable by the CDS compiler. I will share my solution. I did just happen to use IsPontentiallyPersonal and IsPotentiallySensitive on the same entity. I didn't know of any requirement to have both; maybe it was just dumb luck on my part. I don't think it's supposed to be a requirement to have both on the same entity.  There is an example in the documentation that only has IsPotentiallyPersonal. 

Spoiler
//Audit Log
annotate Authors with @PersonalData: {
  DataSubjectRole : 'Author',
  EntitySemantics : 'DataSubject'
}{
  ID @PersonalData.FieldSemantics: 'DataSubjectID';
  name @PersonalData.IsPotentiallyPersonal;
  dateOfBirth @PersonalData.IsPotentiallySensitive;  
}

The example on the plugin documentation is not complete. It is missing the DataSubjectRole and EntitySemantics on the annotation.

Here you can find some more complete documentation about the plugin.

https://cap.cloud.sap/docs/guides/data-privacy/annotations#annotated-model

 

Ruthiel
Product and Topic Expert
Product and Topic Expert
  • Audit-log:
    Ruthiel_1-1709290626372.png

     

  • Notifications:
    Ruthiel_2-1709290655075.png

     

  • Telemetry:
    Ruthiel_3-1709290678539.png

     

Thanks a lot @thomas_jung for this great opportunity to learn!

 

 

RameshShrestha
Contributor

Audit Logging :

RameshShrestha_0-1709296427064.png

Bonus 1: Done but it shows tenant as undefined for me but your screenshot gives t1.

RameshShrestha_1-1709296452634.png

Notification

RameshShrestha_2-1709296506291.png

Telemetry

RameshShrestha_3-1709296583788.png

With Reagrds,

Ramesh Shrestha

 

 

 

 

 

MioYasutake
Active Contributor

Hi,
I am facing issues with audit-log.
I have installed the @cap-js/audit-logging plugin and added annotations as described below.

using { sap.capire.bookshop as db } from '../db/schema';

annotate db.Books with @PersonalData: {
    EntitySemantics : 'DataSubject'
}
{
  ID @PersonalData.FieldSemantics: 'DataSubjectID';
  title @PersonalData.IsPotentiallyPersonal;
};

However, I am not seeing the 'SensitiveDataRead' logs, nor do I see the '[cds] connected to audit-log' message in the console. Am I missing any steps?

MioYasutake
Active Contributor

SandipAgarwalla
Active Contributor

Jarek
Explorer

Alpesa1990
Participant

tobiasz_h
Active Participant

Hello,

Audit-logging:

tobiasz_h_2-1709563896257.png

 

Notifications:

tobiasz_h_1-1709563580767.png

 

Telementry:

tobiasz_h_0-1709563498827.png

 

MatLakaemper
Participant

MatLakaemper
Participant

Hello Thomas,
can you give us at the end of the challenge a complete example Project (as a git-Repository) with all Topics?
I could not find out all special topics.

Kind Regards, 
Matthias

sabarna17
Contributor

qmacro
Developer Advocate
Developer Advocate

Nagarajan-K
Explorer
0 Kudos

Here are my tryouts.

Audit Log - 

NagarajanK_0-1709777290226.png

 

Notifications 

NagarajanK_1-1709777342926.png

Telemetry

NagarajanK_2-1709777387916.png

 

 

Cmdd
Participant
0 Kudos

Late submission but this week I have been busy playing with Flexible Programming Model 🙂

Cmdd_0-1709889966604.jpeg

Cmdd_1-1709890025082.jpegCmdd_2-1709890053457.jpegCmdd_3-1709890073346.jpeg