N
Novu9mo ago
Ketul

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
Pawan Jain
Pawan Jain9mo ago
Hi @Ketul You can use useFetchNotifications hook useFetchNotifications ^
Ketul
Ketul9mo ago
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
Pawan Jain
Pawan Jain9mo ago
Try this
const { data } = useFetchNotifications({
query: {
limit: 100,
seen: false
}
})
const { data } = useFetchNotifications({
query: {
limit: 100,
seen: false
}
})
I have raised a PR to add this
Ketul
Ketul9mo ago
Alright thanks, so how long will it take for this to reflect?
Pawan Jain
Pawan Jain9mo ago
day one or two
Ketul
Ketul9mo ago
i am able to see the changes
Novu_Bot
Novu_Bot9mo ago
@Ketul, you just advanced to level 1!
Ketul
Ketul9mo ago
hey, If i trigger 5 messages concurrently will i get 5 notifications in useFetchNotifications(). Beaacuse i am seeing few messages getting dropped
Tomer Barnea
Tomer Barnea9mo ago
Hey @Ketul you should, unless something filters this out, have you looked in the Activity Feed?
Ketul
Ketul9mo ago
It shows up in the activity feed but on the frontend, all events are not visible
Pawan Jain
Pawan Jain9mo ago
Hi If you are using useFetchNotifications hook and you want realtime in-app notification, You will need to use useSocket hook as well
Pawan Jain
Pawan Jain9mo ago
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
Ketul
Ketul9mo ago
I cant find refetch() in doc, is there any documentation for refetch().
Pawan Jain
Pawan Jain9mo ago
refetch() function is returned by useFetchNotifications() hook
Dushyant
Dushyant9mo ago
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])
Pawan Jain
Pawan Jain9mo ago
Hi @Dushyant Thanks for sharing It will be easier for me if you can share your code implementation in codesandbox, I will debug quickly
Dushyant
Dushyant9mo ago
Hi @Pawan Jain Link for Sandbox : https://codesandbox.io/s/shy-fire-znsnzl
Pawan Jain
Pawan Jain9mo ago
@Dushyant Are you self hosting Novu? What is your Novu version?
Ketul
Ketul9mo ago
We are not self hosting, we are using the free version as of now.
Pawan Jain
Pawan Jain9mo ago
Okay 👍
Ketul
Ketul9mo ago
Would using a free version of novu cause performance / reliability issues which we are facing right now?
Pawan Jain
Pawan Jain9mo ago
Hi @Ketul Are you seeing unusual delivery time ? Could you please share the exact performance or reliability issue?
Ketul
Ketul9mo ago
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
Pawan Jain
Pawan Jain9mo ago
@Ketul can we hop on a call quickly? Can you show me exactly what's happening?
Ketul
Ketul9mo ago
yea sure
Novu_Bot
Novu_Bot9mo ago
@Ketul, you just advanced to level 2!
Pawan Jain
Pawan Jain9mo ago
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 field
Ketul
Ketul9mo ago
we 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.
Tomer Barnea
Tomer Barnea9mo ago
@Pawan Jain , @Engineering can you help here?
DavidSouthmountain
Hi @Ketul, I have not see your workflow so I wonder if there is any digest or delay nodes in your workflow?
saket
saket9mo ago
Currently, we are not using any digest or delay nodes. Should we try digest nodes for our concurrent events, would that help?
DavidSouthmountain
No I just try to eliminate what can cause the issue 🙂
saket
saket9mo ago
We are simply using in-app notification.
Novu_Bot
Novu_Bot9mo ago
@saket, you just advanced to level 1!
DavidSouthmountain
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?
saket
saket9mo ago
Yes, it's happening for the same subscriber id. At peak hours, we frequently get concurrent events
DavidSouthmountain
hm how do our response look when that happens do you get different transactionIds back?
Dushyant
Dushyant9mo ago
we get different transactionids for different messages below is sample event data we r getting from const { data } = useFetchNotifications({ query: { limit: 100 , seen : false}, });
DavidSouthmountain
And there is missing some messages in the response?
Dushyant
Dushyant9mo ago
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
DavidSouthmountain
if you reload they are shown in the notification center?
Dushyant
Dushyant9mo ago
when we refresh the page then we get
Novu_Bot
Novu_Bot9mo ago
@Dushyant, you just advanced to level 1!
DavidSouthmountain
and you are refetching on notification_received?
Dushyant
Dushyant9mo ago
yes
DavidSouthmountain
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?
Dushyant
Dushyant9mo ago
which react package yoyu are talking about?
Dushyant
Dushyant9mo ago
yes , same issue happens when we use react package also
DavidSouthmountain
okay, could you please create an issue for this because this seems to require some more investigation !issue
Novu_Bot
Novu_Bot9mo ago
Let's open an issue over GitHub! That's the link you should follow: https://github.com/novuhq/novu/issues/new/choose
Dushyant
Dushyant9mo ago
ok
Dushyant
Dushyant9mo ago
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...
DavidSouthmountain
Thank you
Paweł T.
Paweł T.9mo ago
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:
<NovuProvider
stores={[{ storeId: "default", query: { seen: false } }]}
initialFetchingStrategy={{
fetchNotifications: true,
fetchUserPreferences: true
}}
>
<App />
</NovuProvider>

// App code
const { notifications } = useNotifications();
<NovuProvider
stores={[{ storeId: "default", query: { seen: false } }]}
initialFetchingStrategy={{
fetchNotifications: true,
fetchUserPreferences: true
}}
>
<App />
</NovuProvider>

// App code
const { notifications } = useNotifications();
Dushyant
Dushyant9mo ago
I need markNotificationAsSeen() fn too, does useSocket provides this function as well then I can avoid using multiple hooks
Paweł T.
Paweł T.9mo ago
markNotificationAsSeen is provided only by the useNotifications hook, that's why I'm saying it's the only hook you need
Dushyant
Dushyant9mo ago
we are getting issues when we use only useNotifications too, that's why we tried using another hooks as well
Novu_Bot
Novu_Bot9mo ago
@Dushyant, you just advanced to level 2!
Paweł T.
Paweł T.9mo ago
what kind of issues?