Hi,
I would like to track my errors with Bugsnag.
It’s work fine with ionic serve
and with run android
.
But when i build and install apk or with play store, it’s not working anymore.
My app.module.ts
// Bugsnag, before any other imports
import BugsnagErrorHandler from 'bugsnag-angular';
import bugsnag from 'bugsnag-js';
import { bugsnagConfig } from '../environments/bugsnag';
const bugsnagClient = new BugsnagService().getBugsnagClient();
// create a factory which will return the bugsnag error handler
export function errorHandlerFactory() {
return new BugsnagErrorHandler(bugsnagClient);
}
...
providers: [
...
{ provide: ErrorHandler, useFactory: errorHandlerFactory }
]
My bugsnag.service.ts
import { Injectable } from "@angular/core";
import { bugsnagConfig } from '../environments/bugsnag';
import bugsnag, { Bugsnag } from 'bugsnag-js';
import { INotifyOpts } from "bugsnag-js/types/client";
@Injectable()
export class BugsnagService {
private bugsnagClient: Bugsnag.Client;
private user: {
uid?: string,
email?: string,
displayName?: string,
provider?: string
};
constructor() {
this.bugsnagClient = bugsnag(bugsnagConfig);
this.user = {
uid: "none",
email: "none",
displayName: "none",
provider: "none"
};
}
/**
* @param message
* @param options
*/
public notify(message?: string, options?: INotifyOpts): void {
let lib = message ? message : 'Une erreur a eu lieu';
if (options) {
if (!options.user) {
options.user = this.user;
}
}
else {
options = { user: this.user };
}
this.bugsnagClient.notify(new Error(lib), options);
}
/**
* Get bugsnagClient
*/
public getBugsnagClient(): Bugsnag.Client {
return this.bugsnagClient;
}
/**
* @param userInitialized
*/
public initUser(userInitialized): void {
this.user = {
uid: userInitialized.uid,
email: userInitialized.email,
displayName: userInitialized.displayName,
provider: userInitialized.provider
}
}
}
Ionic info
cli packages: (C:\Users\me\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.5
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
System:
Node : v7.2.1
npm : 5.6.0
OS : Windows 10
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
Any idea of what’s wrong ?
Thank you.