N
Novu16mo 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 Jain16mo ago
Hi @Ketul You can use useFetchNotifications hook useFetchNotifications ^
Ketul
KetulOP16mo 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 Jain16mo 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
KetulOP16mo ago
Alright thanks, so how long will it take for this to reflect?
Pawan Jain
Pawan Jain16mo ago
day one or two
Ketul
KetulOP16mo ago
i am able to see the changes
Novu_Bot
Novu_Bot16mo ago
@Ketul, you just advanced to level 1!
Ketul
KetulOP16mo 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 Barnea16mo ago
Hey @Ketul you should, unless something filters this out, have you looked in the Activity Feed?
Ketul
KetulOP16mo ago
It shows up in the activity feed but on the frontend, all events are not visible
Pawan Jain
Pawan Jain15mo 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 Jain15mo 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
KetulOP15mo ago
I cant find refetch() in doc, is there any documentation for refetch().
Pawan Jain
Pawan Jain15mo ago
refetch() function is returned by useFetchNotifications() hook
Dushyant
Dushyant15mo 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 Jain15mo 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
Dushyant15mo ago
Hi @Pawan Jain Link for Sandbox : https://codesandbox.io/s/shy-fire-znsnzl
Pawan Jain
Pawan Jain15mo ago
@Dushyant Are you self hosting Novu? What is your Novu version?
Ketul
KetulOP15mo ago
We are not self hosting, we are using the free version as of now.
Pawan Jain
Pawan Jain15mo ago
Okay 👍
Ketul
KetulOP15mo ago
Would using a free version of novu cause performance / reliability issues which we are facing right now?
Pawan Jain
Pawan Jain15mo ago
Hi @Ketul Are you seeing unusual delivery time ? Could you please share the exact performance or reliability issue?
Ketul
KetulOP15mo 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 Jain15mo ago
@Ketul can we hop on a call quickly? Can you show me exactly what's happening?
Ketul
KetulOP15mo ago
yea sure
Novu_Bot
Novu_Bot15mo ago
@Ketul, you just advanced to level 2!
Pawan Jain
Pawan Jain15mo 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
KetulOP15mo 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 Barnea15mo 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
saket15mo 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
saket15mo ago
We are simply using in-app notification.
Novu_Bot
Novu_Bot15mo 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
saket15mo 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
Dushyant15mo 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
Dushyant15mo 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
Dushyant15mo ago
when we refresh the page then we get
Novu_Bot
Novu_Bot15mo ago
@Dushyant, you just advanced to level 1!
DavidSouthmountain
and you are refetching on notification_received?
Dushyant
Dushyant15mo 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
Dushyant15mo ago
which react package yoyu are talking about?
Dushyant
Dushyant15mo 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_Bot15mo ago
Let's open an issue over GitHub! That's the link you should follow: https://github.com/novuhq/novu/issues/new/choose
Dushyant
Dushyant15mo ago
ok
Dushyant
Dushyant15mo 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.15mo 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
Dushyant15mo ago
I need markNotificationAsSeen() fn too, does useSocket provides this function as well then I can avoid using multiple hooks
Paweł T.
Paweł T.15mo ago
markNotificationAsSeen is provided only by the useNotifications hook, that's why I'm saying it's the only hook you need
Dushyant
Dushyant15mo ago
we are getting issues when we use only useNotifications too, that's why we tried using another hooks as well
Novu_Bot
Novu_Bot15mo ago
@Dushyant, you just advanced to level 2!
Paweł T.
Paweł T.15mo ago
what kind of issues?
Want results from more Discord servers?
Add your server