One of the problems with complex client-side programs is troubleshooting issues when there's a problem. You can show the error messages to the user, but that is usually frustrating for them and not typically helpful in locating the problem.
Based on a great suggestion from one of our clients, we have modified the IMOs to provide log messages to the javascript status function defined at runtime (statusfcn parameter). Implementations can then modify the status function however they choose to capture messages and, potentially, send them back to the server.
When set up for messages, the status function receives an object that has several fields:
status=msg (always set to 'msg' for messages)
eventid - the eventid provided at runtime for this imo.
level - 0=error, 1=warning, 2=info
text - the actual message.
You can capture these and then send the log messages back to a server URL using XMLHttpRequest. That way, when a user complains about a problem in the future, you'll have more information available for troubleshooting.
Here's a simple example of a status function you could include on your page:
function imoStatusFcn( o ) {
var status=o.status;
if( status==='msg' )
{
var msg = o.text;
var level = o.level;
var eid= o.eventid;
if( (msg) && (eid) )
sendLogMessage( msg, level, eid);
}
}
No comments:
Post a Comment