From deea3a087a98dcd6e1450b028f3bcf8649332a8e Mon Sep 17 00:00:00 2001 From: Overtorment Date: Thu, 28 Nov 2019 23:16:04 +0000 Subject: [PATCH] OPS: analytics fix --- App.js | 2 ++ BlueComponents.js | 1 - analytics.js | 6 ++++++ class/app-storage.js | 2 +- index.js | 1 - package-lock.json | 6 +++--- package.json | 2 +- screen/wallets/list.js | 2 ++ 8 files changed, 15 insertions(+), 7 deletions(-) diff --git a/App.js b/App.js index ad778bd2..444ab0aa 100644 --- a/App.js +++ b/App.js @@ -13,6 +13,7 @@ import { Chain } from './models/bitcoinUnits'; import QuickActions from 'react-native-quick-actions'; import * as Sentry from '@sentry/react-native'; import OnAppLaunch from './class/onAppLaunch'; +const A = require('./analytics'); if (process.env.NODE_ENV !== 'development') { Sentry.init({ @@ -110,6 +111,7 @@ export default class App extends React.Component { _handleAppStateChange = async nextAppState => { if (BlueApp.getWallets().length > 0) { if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') { + A(A.ENUM.APP_UNSUSPENDED); const clipboard = await Clipboard.getString(); const isAddressFromStoredWallet = BlueApp.getWallets().some(wallet => wallet.chain === Chain.ONCHAIN ? wallet.weOwnAddress(clipboard) : wallet.isInvoiceGeneratedByWallet(clipboard), diff --git a/BlueComponents.js b/BlueComponents.js index a0772ceb..4412caf8 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -1,5 +1,4 @@ /* eslint react/prop-types: 0 */ -/** @type {AppStorage} */ import React, { Component, useEffect, useState } from 'react'; import Ionicons from 'react-native-vector-icons/Ionicons'; import PropTypes from 'prop-types'; diff --git a/analytics.js b/analytics.js index 7ce36fff..792d7014 100644 --- a/analytics.js +++ b/analytics.js @@ -1,9 +1,13 @@ import amplitude from 'amplitude-js'; import Analytics from 'appcenter-analytics'; +import { getVersion } from 'react-native-device-info'; +import { Platform } from 'react-native'; amplitude.getInstance().init('8b7cf19e8eea3cdcf16340f5fbf16330', null, { useNativeDeviceInfo: true, + platform: Platform.OS, }); +amplitude.getInstance().setVersionName(getVersion()); let A = async event => { amplitude.getInstance().logEvent(event, {}); @@ -17,8 +21,10 @@ let A = async event => { A.ENUM = { INIT: 'INIT', GOT_NONZERO_BALANCE: 'GOT_NONZERO_BALANCE', + GOT_ZERO_BALANCE: 'GOT_ZERO_BALANCE', CREATED_WALLET: 'CREATED_WALLET', CREATED_LIGHTNING_WALLET: 'CREATED_LIGHTNING_WALLET', + APP_UNSUSPENDED: 'APP_UNSUSPENDED', }; module.exports = A; diff --git a/class/app-storage.js b/class/app-storage.js index 41a6121a..5b449ca9 100644 --- a/class/app-storage.js +++ b/class/app-storage.js @@ -455,7 +455,7 @@ export class AppStorage { getBalance() { let finalBalance = 0; for (let wal of this.wallets) { - finalBalance += wal.balance; + finalBalance += wal.getBalance(); } return finalBalance; } diff --git a/index.js b/index.js index 763c49b7..77b860ae 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,6 @@ import App from './App'; import LottieView from 'lottie-react-native'; import UnlockWith from './UnlockWith.js'; -/** @type {AppStorage} */ const A = require('./analytics'); if (!Error.captureStackTrace) { diff --git a/package-lock.json b/package-lock.json index 1dd36509..9845c501 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1923,9 +1923,9 @@ } }, "amplitude-js": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/amplitude-js/-/amplitude-js-5.6.0.tgz", - "integrity": "sha512-XGaM0sTvMOrVYqfHhkKEikjQ/SzhEGbupxYopcrzEpEuNLenSOIBMyB0JycBcFI1hTWR4rGJ2TDRqIeRMmUZvg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/amplitude-js/-/amplitude-js-5.7.0.tgz", + "integrity": "sha512-nKE5oJhfuGTxUlJje4XJ7hpRmCTkM1G4sKRvk9vFxo/SsgHZ2qofd9a5Bvk/OKO2N4P9RMyLRa0byJ9j6NIAeg==", "requires": { "@amplitude/ua-parser-js": "0.7.20", "blueimp-md5": "^2.10.0", diff --git a/package.json b/package.json index 516ba6b9..27743b30 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@react-native-community/slider": "2.0.0-rc.1", "@remobile/react-native-qrcode-local-image": "git+https://github.com/BlueWallet/react-native-qrcode-local-image.git", "@sentry/react-native": "1.0.9", - "amplitude-js": "5.6.0", + "amplitude-js": "5.7.0", "appcenter": "2.6.0", "appcenter-analytics": "2.6.0", "appcenter-crashes": "2.6.0", diff --git a/screen/wallets/list.js b/screen/wallets/list.js index e3a6f1ab..5b61a538 100644 --- a/screen/wallets/list.js +++ b/screen/wallets/list.js @@ -111,6 +111,8 @@ export default class WalletsList extends Component { console.log('wallets/list redrawScreen()'); if (BlueApp.getBalance() !== 0) { A(A.ENUM.GOT_NONZERO_BALANCE); + } else { + A(A.ENUM.GOT_ZERO_BALANCE); } this.setState({