notification feed more than 10
I want to get feed for a specific subscriberId with a filter where seen is false and page count is at least 100. I cant call api from front end because i am getting CORS error. can i do this with usenotification().
61 Replies
Hi @Ketul
You can use
useFetchNotifications
hook
useFetchNotifications ^Yes, but it gives only 10 items in a page, and i want only unseen messages. Other wise i will have to iterate all pages.
i cant even find documentation for this
Try this
I have raised a PR to add this
Alright thanks, so how long will it take for this to reflect?
day one or two
i am able to see the changes
@Ketul, you just advanced to level 1!
hey, If i trigger 5 messages concurrently will i get 5 notifications in useFetchNotifications().
Beaacuse i am seeing few messages getting dropped
Hey @Ketul you should, unless something filters this out, have you looked in the Activity Feed?
It shows up in the activity feed but on the frontend, all events are not visible
Hi If you are using useFetchNotifications hook and you want realtime in-app notification,
You will need to use useSocket hook as well
Checkout our docs
https://docs.novu.co/notification-center/client/react/get-started#realtime-sockets
You will need to call refetch() function in socket.on callback method
I cant find refetch() in doc, is there any documentation for refetch().
refetch() function is returned by useFetchNotifications() hook
Hey @Pawan Jain ,
I used real-time socket as you mentioned above in react code.
But sometimes I am not receiveing all notifications. some notifications are getting dropped.
We are getting all notifications in activity feed but not in socket event in frontend
Code snippet is given below for handling new notifications. Pls check
const { socket: novuSocket } = useSocket();
const { markNotificationAsSeen } = useNotifications();
const init = (notification) => {
// some logic
markNotificationAsSeen(notification?.id)
}
const handleNewNotification = async (notificationData) => {
await refetch();
console.log(notificationData,"notification-data");
init(notificationData?.message)
} useEffect(() => { if (novuSocket) { novuSocket.on("notification_received", (data) => { console.log(data,"socket-data"); handleNewNotification(data) }); } return () => { if (novuSocket) { novuSocket.off("notification_received"); } } }, [novuSocket])
} useEffect(() => { if (novuSocket) { novuSocket.on("notification_received", (data) => { console.log(data,"socket-data"); handleNewNotification(data) }); } return () => { if (novuSocket) { novuSocket.off("notification_received"); } } }, [novuSocket])
Hi @Dushyant
Thanks for sharing
It will be easier for me if you can share your code implementation in codesandbox,
I will debug quickly
Hi @Pawan Jain
Link for Sandbox : https://codesandbox.io/s/shy-fire-znsnzl
@Dushyant
Are you self hosting Novu?
What is your Novu version?
We are not self hosting, we are using the free version as of now.
Okay 👍
Would using a free version of novu cause performance / reliability issues which we are facing right now?
Hi @Ketul
Are you seeing unusual delivery time ?
Could you please share the exact performance or reliability issue?
Suppose i trigger 5 events from api, on the frontend (using above code), I am not able to see all 5 events 100% of times. Sometimes i see 3 or 4 events
@Ketul can we hop on a call quickly?
Can you show me exactly what's happening?
yea sure
@Ketul, you just advanced to level 2!
https://meet.google.com/jfz-pibh-gza
Please join
@Ketul
how are you triggering 5 notifications to same user at same time?
- a for loop?
- topic with same subscriberid 5 times?
- or same subscriberId 5 times in
to
fieldwe are using a tool called Jmeter which calls the novu trigger api for same subscriber id 5 times
hey @Pawan Jain any luck on this?
Hey @Pawan Jain We are blocked on this as we are facing issues in production. Could you please have a look.
@Pawan Jain , @Engineering can you help here?
Hi @Ketul, I have not see your workflow so I wonder if there is any digest or delay nodes in your workflow?
Currently, we are not using any digest or delay nodes. Should we try digest nodes for our concurrent events, would that help?
No I just try to eliminate what can cause the issue 🙂
We are simply using in-app notification.
@saket, you just advanced to level 1!
Is it only when you trigger the events for the same subscriber 5 times quickly? Can you try to wait a second or two between the triggers?
Yes, it's happening for the same subscriber id. At peak hours, we frequently get concurrent events
hm how do our response look when that happens do you get different transactionIds back?
we get different transactionids for different messages
below is sample event data we r getting from const { data } = useFetchNotifications({
query: { limit: 100 , seen : false},
});
And there is missing some messages in the response?
yes , sometimes we don't receive messages, but we can see them in activity feed , but we don't get all messages using hooks on frontend
generally we observe this happens if there are multiple notification in small time frame
if you reload they are shown in the notification center?
when we refresh the page then we get
@Dushyant, you just advanced to level 1!
and you are refetching on
notification_received
?yes
okay I wonder if samething happens with the react package we provide, could you try it and see if you get the same issue there?
which react package yoyu are talking about?
yes , same issue happens when we use react package also
okay, could you please create an issue for this because this seems to require some more investigation
!issue
Let's open an issue over GitHub! That's the link you should follow: https://github.com/novuhq/novu/issues/new/choose
ok
raised issue https://github.com/novuhq/novu/issues/4439
GitHub
🐛 Bug Report: Notification messages are getting missed during Concu...
📜 Description When we trigger multiple notifications at the same time or within few seconds, we do not get all the notification messages in events provided by novu hooks. When we reload the page or...
Thank you
hey @Dushyant 👋 when you use the
useNotifications
hook you don't need to use any other hooks like useFetchNotifications, useSocket
... if you want to fetch unseen
messages only do it like this:
I need markNotificationAsSeen() fn too, does useSocket provides this function as well then I can avoid using multiple hooks
markNotificationAsSeen
is provided only by the useNotifications
hook, that's why I'm saying it's the only hook you needwe are getting issues when we use only useNotifications too, that's why we tried using another hooks as well
@Dushyant, you just advanced to level 2!
what kind of issues?