StackDriver Error Reporting Email Notification - stackdriver

In our multitenant environment, I would like to setup an alert notification(e.g. email) when our user's code has an exception.
I was thinking of using the stackdriver error reporting api to send an error notification. Something like
from google.cloud import error_reporting
client = error_reporting.Client()
try:
raise NameError
except Exception:
client.report_exception()
How can I set this up (using a python api)
create an alert for a tenant id/service id to send notifications to. I could input user's contact email in this step.
Report an exception for a tenant id/service id using something like client.report_exception() and notify the alert mechanism
Other solutions:
This post suggests that I use logging and log errors, create a filter and create an alert policy. That would be an option but I feel it may be expensive as that would mean for each of the services of our users, it will be running the log search query every few seconds/minutes? I was wondering if there was a push approach (vs the logging pull approach) or have I misunderstood that the logging notification is actually a push approach?
If I'm on the wrong path, please feel free to suggest better ways.

Related

SignalR push notification when users are not online

I need to implement push notifications for my asp.net core project.For a news service
it needs to work in such a manner that if the user is not online while a message is being sent out, then the message will arrive at the client when they are online thenext time.
All the articles I can find about this, are all slightly vague about this case, and just emphasises the "real-time" communication.
So would it be possible to have push notifications that could that wiht signalr?
it needs to work in such a manner that if the user is not online while a message is being sent out, then the message will arrive at the client when they are online thenext time.
To achieve your above requirement, you can try:
mapping user to the connection id(s) and persist that mapping, which would help find/get new connection id(s) based on user name or email etc readable info after user connect/reconnect to hub, then you can send unread message/data to specific user by specifying connection id(s).
Note: you can also send a message to a specific user by passing the user identifier to the User function in a hub method, please refer to this doc: https://learn.microsoft.com/en-us/aspnet/core/signalr/groups?view=aspnetcore-5.0#users-in-signalr
for unread messages, as #SamiKuhmonen mentioned, you can store/persist those messages in somewhere, and if you want to persist information after restarts or you would host hub on multi-servers/instances, in-memory store is not a good approach. You can try to store messages in database etc permanent, external storage.
define and use a flag to indicates if the message has been seen by user. After client received a message, then invoke a hub method to update that flag or delete that message from the store.

Firebase notifications security / console activity log

i'm thinking about using Firebase for the notification service that my app needs. However, its important that the process of sending notifications is secure. I want to avoid a notification being sent from any member of the team without permission.
One way could be assigning restricted roles and permissions for the team members. However it also would be good to have any kind of activity log in the console, or have a log of all notifications sent including the name of the user. The console currently allows you to see all notifications sent, but i cannot see who sent it, and also the notification can be deleted from the log.
Any ideas on how to manage this? Which specific roles would you recommend me to use? Is it possible with Firebase?
You could write a function in Firebase which sends notifications, and you have logs on that function. Here is how to write a function which send notifications

Firebase Crash Reporting API/Notifications

I've been looking around for a while now, but haven't been able to find a way to send out notifications about Firebase crashes. I have found/enabled email notifications for these crashes, but I was hoping for an API that I could use to integrate them into Slack or something a bit more actionable than email. Is there any way to do this?
firebaser here
You will automatically get emails upon certain type of crash reports: new crash types and regressions. For example if a type of crash that you had fixed reoccurs, the system will send you an email to alert you to this regression.
But there is no API (yet) for getting called when a crash is registered on the server. It sounds like a good feature though, so I'd recommend that you file a feature request.
The best you can do right now is to trigger such an action from the client that reports the crash.

Firebase Cloud Messaging for Web - How to maintain the token list in the database and ensure they are valid or up-to-date

With Firebase Cloud Messaging for Web,
How do I maintain the list of valid tokens in my database? For example I've noticed when a user turns off notifications and revisits the site, a new token will be generated and the old token in my database is useless.
I've also tried using Firebase messaging.onTokenRefresh() callback, but it does not get called when I turned off notifications. Also in this case, even if it did get triggered, it returns a new token that was refreshed. How do I keep track of the old token that was refreshed?
Can someone please share with me their thoughts/ways to maintain and ensure the token list in the database are valid or up-to-date?
Any feedback is much appreciated.
Thank you,
Christina
messaging.onTokenRefresh() is probably a wrapper around the event onpushsubscriptionchange.
Indeed that event is currently only called when the subscription is enabled (or enabled again), but not when the permission for push notifications is revoked. So at the moment you can only know that an endpoint has expired when you try to send a notification to it.
More details:
http://blog.pushpad.xyz/2016/05/the-push-api-and-its-wild-unsubscription-mechanism/
In any case you can use the callback to send any new token to the server: at first you will have two tokens stored for the same browser, one expired and the other valid.
Some problems arise if you have data associated to the endpoint (e.g. tag) that you want to preserve during the endpoint change: see the blog post for some suggestions.

worklight send push notification for all subscribed users

I have to schedule a downtime in order to do some stuff on the production server. My customer wants me to send a push notification to all the subscribed users in order to notify them by the downtime.
Is that possible? If I want to do it even by code will it be possible?
I'm on worklight 6.0.0.0
Using the Worklight Console you can notify the users of your application taking advantage of the "Active, Notifying" setting. This will allow you to display a notification message on startup telling the customer of scheduled downtime. Even when the downtime occurs you can use the same mechanism and set the application to "disabled" with a notification message stating the application is currently down. Please look at the following documentation for more information:
Displaying a notification message on application startup:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.worklight.help.doc%2Fadmin%2Ft_displaying_a_notification_message_on_app_startup.html
Defining administrator messages from Worklight Console in multiple languages:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.worklight.help.doc%2Fadmin%2Ft_defining_multi-language_admin_notifications.html
Maybe you can use Wl.Server.sendMessage, you just need to send the applicationId and notificationOptions where you can pass only the message to send and this method will be send to all users, of if you want you can pass a kind of target for specify the users
I hope this help you
For more info check these links:
Tutorial: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/notifications/push-notifications-overview/push-notifications-in-hybrid-applications/tag-based-notifications-in-hybrid-applications/
Documentation: http://www-01.ibm.com/support/knowledgecenter/api/content/nl/es/SSZH4A_6.2.0/com.ibm.worklight.apiref.doc/html/refjavascript-server/html/WL.Server.html#sendMessage

Resources