MOBILE-3068 analytics: Don't call logEvent if user disabled

main
Dani Palou 2019-08-22 11:35:17 +02:00
parent 587a8e4114
commit 44f2122298
1 changed files with 11 additions and 5 deletions

View File

@ -342,11 +342,17 @@ export class CorePushNotificationsProvider {
const win = <any> window; // This feature is only present in our fork of the plugin. const win = <any> window; // This feature is only present in our fork of the plugin.
if (CoreConfigConstants.enableanalytics && win.PushNotification && win.PushNotification.logEvent) { if (CoreConfigConstants.enableanalytics && win.PushNotification && win.PushNotification.logEvent) {
return new Promise((resolve, reject): void => {
win.PushNotification.logEvent(resolve, (error) => { // Check if the analytics is enabled by the user.
this.logger.error('Error logging firebase event', name, error); return this.configProvider.get(CoreConstants.SETTINGS_ANALYTICS_ENABLED, true).then((enabled) => {
resolve(); if (enabled) {
}, name, data, !!filter); return new Promise((resolve, reject): void => {
win.PushNotification.logEvent(resolve, (error) => {
this.logger.error('Error logging firebase event', name, error);
resolve();
}, name, data, !!filter);
});
}
}); });
} }