Ionic Pro: Error Monitoring

A post was split to a new topic: Bad gateway when viewing app in ionic view

Hey @max is the new version of Monitoring coming this week?

Yep! Just as we speak, the docs went live: http://ionicframework.com/docs/pro/monitoring/

New manual capture/log API: http://ionicframework.com/docs/pro/monitoring/#manual-capture

Would love your feedback on the update.

1 Like

Thanks. Iā€™ll take a look.

@max checked out the docs and looks exactly what I was after so we will give it a try.

1 Like

Hi! How can you show the error like before but only in devel environment (and trigger the exception log when running in prod)? I mean, something like:

if (prod) {
    IonicPro.monitoring.handleNewError(err);
} else {
    throw new Error(err); 
}

Hmm not sure off hand, will think about this for the next sprintā€¦

Hey all, lots of updates and improvements yesterday and today. Source mapping should be more accurate now and update more readily. Itā€™s a Hard Problem to keep the two synced so a future update will automate source map generation to make it even easier.

One thing to make sure you do before continuing: update to @ionic/app-scripts 3.0.0 which fixed a production sourcemap bug we had (unrelated to Pro monitoring), and then follow the npm install steps in the docs to make sure youā€™re running at least @ionic/pro 1.0.9

1 Like

I did it like this:

export class MyErrorHandler implements ErrorHandler {

    protected _devMode: boolean = !window.hasOwnProperty('cordova');

    handleError(err: any): void {

        if (this._devMode) {
            throw new Error(err);
        } else {
            IonicPro.monitoring.handleNewError(err);
        }
    }
}

But I think monitoring should know itself whether to send exceptions or not (and display debug info in console).

1 Like

Great suggestion. Iā€™ll noodle on this and see if we can come up with something better. Weā€™re also working on environment variables in app-scripts in general so maybe we just always have a ENV setting for dev/prod.

1 Like

I used to have a src/config/config.ts.sample in my repo and in .gitignore a line with src/config/config.ts, so after cloning a project a developer just needed to copy config.ts.sample => config.ts and thatā€™s it, you could have env / prod vars depending on your needs (when building, we just replaced that file with prod values). In Pro (Iā€™ve signed for the paid plan this week), since you have a new repo tu push and it builds from there (unlike before, where ionic upload used to upload the entire builded env), I canā€™t use this approach anymore. This is because that runs in Ionic Pro and builds from new repo instead of uploading your project with all your files, and config.ts wonā€™t exist and fail.

Iā€™d like you to find a way to have different config files for different environments. Since you canā€™t do a ā€œfile existsā€ with javacsript, itā€™s also not possible/reliable to try to load a config file in not async mode (and itā€™s not the purpose either in new standards) and overwrite variables.

Iā€™d like to read suggestions on how to achieve this :slight_smile:

Thanks!

@max

Just started getting my feet wet with monitoring and love the potential. There are times when my error logs (via dashboard) toggle from source mapped: yes, to source mapped: no.

This could be inexperience on my part, or like you said, itā€™s a work in progress.

Iā€™ve logged errors from Ionic serve, Ionic View, and post phonegap build. Could the variation be the culprit?

Regardless, the documentation is starting to clarify and I like where itā€™s headed.

Thanks!