2017-12-17 11 views
0

난 그냥 프로 이온에 내 이온이 응용 프로그램을 마이그레이션 및 설정 오류 모니터링 아래 링크의 지침에 따라 :Ionic Pro 오류 모니터링은 Ionic View에서 작동합니까?

https://ionicframework.com/docs/pro/monitoring/

을하지만, 그래서 여기까지 작동 제를 어떻게 알아낼 수 없었다 문제 :

내 API와 통신하기 위해 내 응용 프로그램에서 @ angular/http의 HTTP 모듈을 사용하고 있으며 Chrome --disable-web-security 기능으로 테스트 한 이후 지금까지 레거시 버전에서는 프록시를 필요로하지 않았습니다. 기존의 Ionic View에 배치했을 때 작동합니다. 그러나 Ionic Pro에 배포 한 후에 Ionic DevApp를 사용하려면 프록시를 추가해야했으며 Ionic View에 배포 할 때는 프록시와 전혀 작동하지 않습니다.

따라서 Ionic View에서 테스트 할 때 오류 및 로그가 표시되지만 Ionic의 모니터링 페이지에는 아무 것도 표시되지 않습니다.

import { Pro } from '@ionic/pro'; 

    err => { 

      loader.dismissAll(); 
      var errorTitle = this.authService.connectionService.GetNoInternetConnectionErrorTitle(); 
      var errorMessage = this.authService.connectionService.GetNoInternetConnectionErrorMessage(); 
      if (err.status != 0) { 
       console.log(JSON.parse(err._body)); 
       var errMessageJson = JSON.parse(JSON.parse(err._body)); 
       console.log("Error Code is " + errMessageJson.ErrorCode); 
       errorTitle = errMessageJson.ErrorTitle; 
       errorMessage = errMessageJson.ErrorMessage; 
      } 

      let alert = this.alertCtrl.create({ 
       title: errorTitle, 
       subTitle: errorMessage, 
       buttons: ['OK'] 
      }); 

      // add error monitoring here 
      Pro.getApp().monitoring.exception(new Error('Could not connect to API. Error Message is ' + errorMessage)); 
      Pro.getApp().monitoring.log('This happens sometimes Could not connect to API. The whole message object is ' + err, { level: 'error' }); 

      alert.present(); 

     }, 

답변

1

그것은 나타납니다 또한 내가 수동으로 login.ts 코드 내 오류를 보내는 시도

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

@Injectable() 
export class MyErrorHandler implements ErrorHandler { 
    ionicErrorHandler: IonicErrorHandler; 

    constructor(injector: Injector) { 
     try { 
      this.ionicErrorHandler = injector.get(IonicErrorHandler); 
     } catch (e) { 
      // Unable to get the IonicErrorHandler provider, ensure 
      // IonicErrorHandler has been added to the providers list below 
     } 
    } 

    handleError(err: any): void { 
     IonicPro.monitoring.handleNewError(err); 
     // Remove this if you want to disable Ionic's auto exception handling 
     // in development mode. 
     this.ionicErrorHandler && this.ionicErrorHandler.handleError(err); 
    } 
} 

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

: 여기

오류 처리에 대한 app.module.ts의 코드의 일부이다 문제는 index.html의 Content-Security-Policy에서 connect-src에 api.ionicjs.com을 추가하는 것을 잊었습니다. 추가 한 후 모니터링 페이지에서 오류를 볼 수 있습니다.

+0

동일한 문제가 있습니다. 콘텐츠 보안 정책을 게시 할 수 있습니까? –