From f366dbae86e7c6a705e4db1cd5b46106b7d5168c Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 30 Sep 2020 01:14:26 -0400 Subject: [PATCH 1/2] Ensure sign_in_success ping fires for free accounts as well as plus and premium --- src/background.js | 3 --- src/classes/Account.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/background.js b/src/background.js index 80e3e63a3..88a71298e 100644 --- a/src/background.js +++ b/src/background.js @@ -836,9 +836,6 @@ function onMessageHandler(request, sender, callback) { const { email, password } = message; account.login(email, password) .then((response) => { - if (!response.hasOwnProperty('errors')) { - metrics.ping('sign_in_success'); - } callback(response); }) .catch((err) => { diff --git a/src/classes/Account.js b/src/classes/Account.js index e7b58afad..4df5c95e2 100644 --- a/src/classes/Account.js +++ b/src/classes/Account.js @@ -22,6 +22,7 @@ import conf from './Conf'; import dispatcher from './Dispatcher'; import { log } from '../utils/common'; import Api from '../utils/api'; +import metrics from './Metrics'; import ghosteryDebugger from './Debugger'; const api = new Api(); @@ -87,7 +88,7 @@ class Account { ghosteryDebugger.addAccountEvent('login', 'cookie set by fetch POST'); this._getUserIDFromCookie().then((userID) => { this._setAccountInfo(userID); - this.getUserSubscriptionData(); + this.getUserSubscriptionData({ calledFrom: 'login'}); }); return {}; }); @@ -168,7 +169,7 @@ class Account { /** * @return {array} All subscriptions the user has, empty if none */ - getUserSubscriptionData = () => ( + getUserSubscriptionData = (options) => ( this._getUserID() .then(userID => api.get('stripe/customers', userID, 'cards,subscriptions')) .then((res) => { @@ -197,6 +198,12 @@ class Account { } return subscriptions; + + }) + .finally(() => { + if (options && options.calledFrom === 'login') { + metrics.ping('sign_in_success'); + } }) ) From 3858f8719c305d1d58e6565b9cde4973a862b805 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 30 Sep 2020 01:25:36 -0400 Subject: [PATCH 2/2] Pacify linter --- src/classes/Account.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/classes/Account.js b/src/classes/Account.js index 2e0b4d645..d30c6d32d 100644 --- a/src/classes/Account.js +++ b/src/classes/Account.js @@ -198,7 +198,6 @@ class Account { } return subscriptions; - }) .finally(() => { if (options && options.calledFrom === 'login') {