Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More functional code snippets #4

Open
tjvantoll opened this issue Jan 30, 2015 · 0 comments
Open

More functional code snippets #4

tjvantoll opened this issue Jan 30, 2015 · 0 comments

Comments

@tjvantoll
Copy link

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.

@tjvantoll tjvantoll reopened this Jan 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant