Active
Project:
Drupal core
Version:
main
Component:
javascript
Priority:
Normal
Category:
Plan
Assigned:
Unassigned
Reporter:
Created:
28 Jan 2012 at 12:54 UTC
Updated:
7 Dec 2018 at 18:30 UTC
Jump to comment: Most recent
There are several aspects of this.
We need to decide:
Let's talk about this.
Comments
Comment #0.0
nod_reorder
Comment #0.1
nod_one issue per problem.
Comment #1
rfayJust want to say thank you for all your activism on this!
Comment #2
peterx commentedAdd an email interface so you can send messages.
Comment #3
nod_That's not a bad idea in itself, unfortunately it has nothing to do with javascript :)
Comment #4
peterx commentedWhen you are creating a Javascript based application, you sometimes need to send messages. Most of those messages are watchdog style logging of events. I wrote jDog to do that. Some of the critical errors need immediate attention and an email is better. I added email to jDog because one site needed immediate alerts for some problems occurring in jQuery code. Their use case is mixing several jQuery based functions on one page and reporting the occasional clash. If the second or third section of their jQuery cannot proceed, send email to the jQuery developer or the content administrator.
In the current jDog approach, you can add an email to a severity level. The test case sends email for errors, not warnings. There is also allowance for an email to anyone for any special cases.
The email is sent to the Web site using the same Ajax as the watchdog. The Ajax callback code sends the email from within Drupal. The email use case is similar to the watchdog use case and lets you send an immediate alert. The watchdog Javascript code requires only one extra parameter for email.
The same Javascript code could be extended to SMS, bleets, anything you need for message alerts, by extending the PHP code to decode the address for something other than email.
Other use cases suggested to me include alerts for problems with multipage forms and unusual choices in games. The developer can react immediately to unusual results in their Javascript. The only current alternative is to spend all day looking through the watchdog log.
Comment #5
nod_I think that'd be more of a watchdog extension, or even a Rules thing. I don't think it should be JS-specific, after all, you might want to have a mail if the watchdog logs hundreds of times a 404 on some image too.
It's a more global issue than just JS errors.
Comment #6
apotek commentedGeneral comment on JS error logging/mailing. Since a user can use any JS based logging facility, we are potentially opening up a security hole. I certainly don't want arbitrary JS errors postable (via a service) to watchdog or to sendmail.
Some errors can simply be ignored (autocomplete comes to mind). The main thing is to simply never expose any dangerous diagnostic information to the user in an ajax reply from the server, unless display errors is enabled.
Other, more serious errors, can be displayed to the user with a softer, more general (themable?) error message in an alert dialog or jquery-ui dialog, with diagnostic information sent to the console.log, IF the site has been configured to display errors. My $0.02.
Comment #7
peterx commentedRe security. The JS sends stuff to a URL. The URL starts PHP code and the PHP code passes stuff to watchdog and mail. The PHP code is responsible for cleaning stuff.
Watchdog cleans all variables prior to substitutions. That leaves only the message variable to be cleaned by the PHP code.
Mail does nothing to keep things clean. The PHP code has to clean everything for mail.
jDog is loaded at http://drupal.org/sandbox/peter/1414906 and is running on several sites where the content is cleaned before passing it to jDog. The cleaning of variables in PHP is not yet systematically tested. If someone wants to perform a security check, I can update the code.
I am happy to pass this module to someone who wants to be a Drupal contributor and needs a starting project, sort of like a Google Summer of Code project with all the glory but not the money. if the person is in Sydney, Australia, I can mentor them in real time.
Comment #7.0
peterx commentedclean up list
Comment #8
Bevan commentedJS Watchdog module may serve as a discussion point or prototype for this issue.
Comment #9
nod_#77245: Provide a common API for displaying JavaScript messages
Comment #9.0
nod_throw
Comment #10
corbacho commentedAdding blocking issue to the list #77245: Provide a common API for displaying JavaScript messages
Comment #11
mgiffordComment #12
mgiffordComment #13
mgiffordComment #14
geerlingguy commentedComment #15
droplet commentedMessage in Frontend for vistors VS Logging to backend for developers
It's 2 very different concepts.
A simple JS logging may not help for debugging. Some free / paid / open source tools/services with a powerful panel will do a better job ( for both debugging & logging performance ).
Comment #17
nod_Comment #18
hanoiiFor what it's worth, now that #2808789: Fix "An AJAX HTTP request terminated abnormally" alert after user has navigated away from the page is in, I submitted https://www.drupal.org/project/ajax_error_behavior which could serve as an alternative while a decision is made here.
Maybe useful to add it to the summary, although not sure if it belongs there.
Comment #23
mfbAlso for what it's worth, Raven module - https://www.drupal.org/project/raven - sends javascript exceptions to a Sentry server.