IonicPro Monitoring not working


#1

I am trying to install monitoring with the following code

const IonicPro = Pro.init('ae6ba6b8', {
  appVersion: "1.5.5"
});

export class MyErrorHandler implements ErrorHandler {
  handleError(err: any): void {
    IonicPro.monitoring.handleNewError(err);
  }
}

But I get cannot read property handleNewError of undefined, someone knows something?


#2

Running into the same problem.


#3

Did you get this working? Did you follow the instructions in the docs?


#4

@richardshergold, Here’s a sample of working code for monitoring. I just added the <---'s as potential issues

in app.module.ts

import { ErrorHandler, NgModule, Injectable, Injector } from '@angular/core'; <---
import { IonicApp, IonicErrorHandler } from 'ionic-angular'; <---
import { Pro } from '@ionic/pro';

const IonicPro = Pro.init('0000000', {
  appVersion: "0.0.1"
});

@Injectable()
export class MyErrorHandler implements ErrorHandler {
  ionicErrorHandler: IonicErrorHandler;
   constructor(injector: Injector) {
     try {
       this.ionicErrorHandler = injector.get(IonicErrorHandler);
     }
     catch(e) {
      console.log(e);
     }
   }
   handleError(err:any): void {
     IonicPro.monitoring.handleNewError(err);
     this.ionicErrorHandler && this.ionicErrorHandler.handleError(err);
   }
}

@NgModule({

providers: [
    IonicErrorHandler,   <---
    {provide: ErrorHandler, useClass: MyErrorHandler }, <---
  ]
})