Skip to content

More functional code snippets #4

@tjvantoll

Description

@tjvantoll

The AppBuilder documentation includes the following code block:

function onDeviceReady() {
     window.analytics.Start();
     // existing code goes here
}

function onPause() {
     window.analytics.Stop();
     // existing code goes here
}
function onResume() {
     window.analytics.Start();
     // existing code goes here
}

// todo: handle global exceptions. See eg:
// http://stackoverflow.com/questions/951791/javascript-global-error-handling

I would suggest replacing this with code with:

document.addEventListener( "deviceready", function() {
    window.analytics.Start();
});
document.addEventListener( "pause", function() {
    window.analytics.Stop();
});
document.addEventListener( "resume", function() {
    window.analytics.Start();
});
window.onerror = function( message, url, lineNumber, columnNumber, error ) {
    var monitor = window.plugins.EqatecAnalytics.Monitor;
    monitor.TrackExceptionMessage( error );
};

Developers are lazy and this is a copy-and-paste friendly way of adding analytics functionality—i.e. you can paste it in and it works without any extra work.

The “todo” the currently provided code has for error functionality sends people on a wild goose chase. I'm still not even sure if the way I'm telling the plugin to track errors is even correct because I can't seem to get messages to appear in the backend.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions