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..28ac75ab8 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) => { @@ -195,6 +196,9 @@ class Account { this._setSubscriptionData(plusSubscription); } } + if (options && options.calledFrom === 'login') { + metrics.ping('sign_in_success'); + } return subscriptions; })