novu icon indicating copy to clipboard operation
novu copied to clipboard

[NV-1247] 🚀 Feature: Add websocket event for new notifications

Open SpencerMiller23 opened this issue 1 year ago • 7 comments

🔖 Feature description

This feature would resolve some issues that you might encounter when implementing some custom functionality on the frontend. In addition to the existing unseen_count_changed event, I propose to add another event such as notification_received which would contain all the relevant data for a new notification as follows:

{
    _id: "_id",
    _templateId: "_templateId",
    _environmentId: "_environmentId",
    _messageTemplateId: "_messageTemplateId",
    _organizationId: "_organizationId",
    _notificationId: "_notificationId",
    _subscriberId: "_subscriberId",
    subscriber: subscriber,
    template: template,
    templateIdentifier: "templateIdentifier",
    createdAt: "createdAt",
    content: "content",
    transactionId: "transactionId",
    channel: "channel",
    seen: true,
    email: "email",
    phone: "phone",
    directWebhookUrl: "directWebhookUrl",
    providerId: "providerId",
    deviceTokens: ["deviceTokens"],
    title: "title",
    lastSeenDate: "lastSeenDate",
    cta: cta,
    _feedId: "_feedId",
    status: "status",
    errorId: "errorId",
    errorText: "errorText",
    payload: payload,
    overrides: overrides,
    subject: "subject"
}

🎤 Why is this feature needed ?

While there are already nice solutions for displaying events in a UI such as the useNotifications hook and the Novu API, adding this event would give developers more flexibility when building their UIs. For example, you could reduce the load on the client by fetching events using the API, and then simply listen for new events by websocket and update the UI when appropriate.

✌️ How do you aim to achieve this?

By creating a new event that users can subscribe to and execute relevant logic when such an event is emitted.

🔄️ Additional Information

No response

👀 Have you spent some time to check if this feature request has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

Yes I am willing to submit a PR!

NV-1247

SpencerMiller23 avatar Sep 06 '22 12:09 SpencerMiller23

@SpencerMiller23 let me know if you want me to assign you to this one :)

scopsy avatar Sep 07 '22 07:09 scopsy

@scopsy I will look into it when I have some spare time but feel free to assign to someone else in the meantime

SpencerMiller23 avatar Sep 07 '22 07:09 SpencerMiller23

Hey, @scopsy can you assign it to me, would love to work on it. 😊

Nabhag8848 avatar Sep 14 '22 16:09 Nabhag8848

Sure @Nabhag8848 thank you!

scopsy avatar Sep 14 '22 20:09 scopsy

Hi @Nabhag8848 , need any inputs from the team?

oba2311 avatar Oct 02 '22 10:10 oba2311

Any updates with regards to this feature?

SpencerMiller23 avatar Nov 07 '22 13:11 SpencerMiller23