Skip to content

announcements: integration with notifications #4378 #4816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lavanya-sainik-ericsson
Copy link
Contributor

Hey, I just made a Pull Request!

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@lavanya-sainik-ericsson
Copy link
Contributor Author

lavanya-sainik-ericsson commented Jul 30, 2025

Hello @kurtaking, @gaelgoth, @04kash ,

I have to raise this new PR for issue #4378 with all the comments addressed from @kurtaking as the old PR #4793 had merge conflicts and it was not allowing me to resolve them locally. So I have to use the UI option "Discard 1 commit" & then create this new PR again. Kindly have a look at this PR and let me know if any comments / concerns

@lavanya-sainik-ericsson lavanya-sainik-ericsson force-pushed the announcement_notification_improvement branch from fa2d8c6 to 5d67d89 Compare July 30, 2025 15:04
@backstage-goalie
Copy link
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-announcements-backend workspaces/announcements/plugins/announcements-backend minor v0.9.0

@04kash
Copy link
Member

04kash commented Jul 30, 2025

Looks like you need to run yarn install and commit your yarn.lock file to fix the failing CI

@backstage-goalie
Copy link
Contributor

Thanks for the contribution!
All commits need to be DCO signed before they are reviewed. Please refer to the the DCO section in CONTRIBUTING.md or the DCO status for more info.

lavanya-sainik-ericsson and others added 4 commits July 31, 2025 10:57
…and dev app (backstage#4798)

Signed-off-by: Christoph Jerolimov <[email protected]>
Signed-off-by: Lavanya Sainik <[email protected]>
v1.40.2 version bump

---------

Signed-off-by: Saif Chaudhry <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Saif Chaudhry <[email protected]>
Signed-off-by: Lavanya Sainik <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Lavanya Sainik <[email protected]>
@lavanya-sainik-ericsson lavanya-sainik-ericsson force-pushed the announcement_notification_improvement branch from f83091c to 6fd4a54 Compare July 31, 2025 10:00
@lavanya-sainik-ericsson
Copy link
Contributor Author

lavanya-sainik-ericsson commented Jul 31, 2025

Hello @04kash and All,

Thanks for your comment. I have added the yarn.lock file . Looks like other issues are also solved related to build.

Kindly have a look and let me know if any further comments or concerns.

Comment on lines 71 to 72
title: 'New Announcement',
description: 'New announcement has been added',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow the user to specify the title and description via params?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 51 to 56
const notificationsConfig =
announcementNotificationOpts.config.getOptionalConfig(
'announcements.notification',
);

const notifications = announcementNotificationOpts.notifications;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking - you could consider destructuring right here

const { config, notifications } = announcementNotificationOpts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed now based on @gaelgoth next comment. But do revert if nay concern.

Copy link
Member

@gaelgoth gaelgoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you could set up Notifications on the Backstage dev instance 🙏🏾. This will help with trying/testing notifications locally.

lavanya-sainik-ericsson and others added 2 commits August 6, 2025 11:37
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Lavanya Sainik <[email protected]>
@lavanya-sainik-ericsson
Copy link
Contributor Author

lavanya-sainik-ericsson commented Aug 6, 2025

Hello @kurtaking , @gaelgoth

Thanks a lot for your comments. Have updated the PR with the comments included. Kindly review and do let me know if any further concerns or improvements.

Also @gaelgoth , could you please guide on how to set up the Backstage dev instance for you to test as you have mentioned in the comment ?
I am happy to do that but don't know link of instance and if you have any specific instructions as we have tested in our local backstage installation. So kindly guide here .

Copy link
Member

@kurtaking kurtaking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lavanya-sainik-ericsson, thank you for iterating through this. It's looking great. I've got another round of review for you.

@@ -209,6 +211,9 @@ export async function createRouter(
tags: validatedTags,
});

// Send announcement notification
sendAnnouncementNotification(req, announcement.id, notifications);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notifications plugin requires events. We need to put this next to await signalAnnouncement(announcement, signals).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what happens if we call both signalAnnouncement and sendAnnouncementNotification. Does that cause two separate signals to go out?

I'm wondering if they have notifications enabled, we call sendAnnouncementNotification, else if they have have signals enabled, we call signalAnnouncement, else do nothing.

Comment on lines +19 to +24
export const sendAnnouncementNotification = (
request: any,
announcementId: string,
notifications?: NotificationService,
) => {
const reqData: AnnouncementRequest = request.body;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendAnnouncementNotification shouldn't need to know about the request object. Notice how you now have to import from the router now. This is a circular dependency and tightly couples sending an announcement notification to a request object.

By the time you call your function, you should already have a complete announcement that you can pass in. I highly recommend aligning this as closely to the signalAnnouncements fn as possible.


interface AnnouncementRequest {
export interface AnnouncementRequest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this based on this thread.

Comment on lines +33 to +35
title: `New Announcement "${reqData.title}"`,
description: reqData.excerpt,
link: `/announcements/view/${announcementId}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also get type safety back if the function is updated to take an announcement. Right now we are blindly trusting an any.

@gaelgoth
Copy link
Member

gaelgoth commented Aug 7, 2025

Hello @kurtaking , @gaelgoth

Thanks a lot for your comments. Have updated the PR with the comments included. Kindly review and do let me know if any further concerns or improvements.

Also @gaelgoth , could you please guide on how to set up the Backstage dev instance for you to test as you have mentioned in the comment ? I am happy to do that but don't know link of instance and if you have any specific instructions as we have tested in our local backstage installation. So kindly guide here .

Hi @lavanya-sainik-ericsson,

You can follow the installation guide here: https://backstage.io/docs/notifications/#installation

Run the yarn add commands from the announcements root workspace cd workspaces/announcements, and then add the notifications backend and frontend as described in the documentation.

The signals backend is already installed, you can skip that step.

I did try the set up on my side, so far it's look good 😄

image

Copy link
Member

@gaelgoth gaelgoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be necessary to update the documentation to mention the prerequisites for Notifications

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants