From 44f21222988d233ecef540a3f0777c987d6cd9c1 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 22 Aug 2019 11:35:17 +0200 Subject: [PATCH] MOBILE-3068 analytics: Don't call logEvent if user disabled --- .../providers/pushnotifications.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/pushnotifications/providers/pushnotifications.ts b/src/core/pushnotifications/providers/pushnotifications.ts index 17fe16bb5..0985c6b18 100644 --- a/src/core/pushnotifications/providers/pushnotifications.ts +++ b/src/core/pushnotifications/providers/pushnotifications.ts @@ -342,11 +342,17 @@ export class CorePushNotificationsProvider { const win = window; // This feature is only present in our fork of the plugin. if (CoreConfigConstants.enableanalytics && win.PushNotification && win.PushNotification.logEvent) { - return new Promise((resolve, reject): void => { - win.PushNotification.logEvent(resolve, (error) => { - this.logger.error('Error logging firebase event', name, error); - resolve(); - }, name, data, !!filter); + + // Check if the analytics is enabled by the user. + return this.configProvider.get(CoreConstants.SETTINGS_ANALYTICS_ENABLED, true).then((enabled) => { + if (enabled) { + return new Promise((resolve, reject): void => { + win.PushNotification.logEvent(resolve, (error) => { + this.logger.error('Error logging firebase event', name, error); + resolve(); + }, name, data, !!filter); + }); + } }); }