Notification log hook in custom app

def notification_insert(doc, method):
prefs = get_user_notification_preferences(user_email=doc.for_user)
print(doc.name)
if doc.type == “Mention” and doc.for_user and prefs.get(“comments_overall”):
message_data = {
‘subject’: doc.subject,
‘from_user’: doc.email_content
}
frappe.publish_realtime(
event=‘mention_notification’,
message=message_data,
user=doc.for_user,
after_commit=True
)

doc_events = {
“Notification Log”: {
“on_update”: “virtual_munim.api.notification.notification_insert”
}
}

why this docevent not working

Could you please clarify what’s not working? Is the event not being triggered?

Also, would it be more appropriate to use the after_insert hook for this task?

Event not being triggered. Tested with after_insert too