2017-12-17 13 views
0

私はプロのイオンに私のイオン2アプリを移行し、セットアップエラーの監視へのリンク以下の指示に従っ: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の監視ページには何も表示されません。ここで

は、エラー処理のためのapp.module.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 }] 
    ] 
}) 

はまた、私は手動で私のlogin.tsコード内のエラーを送信してみました:

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

それが表示されます問題のように、私はindex.htmlの私のContent-Security-Policyでconnect-srcにapi.ionicjs.comを追加するのを忘れていました。これを追加した後、私は監視ページでエラーを見ることができます。

+0

私は同じ問題を抱えています。あなたのコンテンツセキュリティポリシー –

関連する問題