Skip to content

Commit

Permalink
[Techdebt/] pdate match firebase events 33 (#48)
Browse files Browse the repository at this point in the history
* Added the equivalenmt events

- updated web link

* WIP : Should compile

* Fixed constants

* Udpaded all Analytics constants

* Added basic tests

- This is WIP
- Need to debug the Tests

* version bump

* fiexd compile bug
  • Loading branch information
kcw-grunt committed Jan 13, 2023
1 parent f7896e5 commit 08ac5bc
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 40 deletions.
23 changes: 23 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ android {
testInstrumentationRunner = 'androidx.test.runner.AndroidJUnitRunner'
applicationId = 'com.loafwallet'
minSdkVersion 27
targetSdkVersion 31
versionCode 684
targetSdkVersion 31
versionCode 690
versionName "v2.7.0"
multiDexEnabled true
archivesBaseName = "${versionName}(${versionCode})"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.breadwallet.analytics;
import androidx.test.rule.ActivityTestRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import android.util.Log;

import com.breadwallet.presenter.activities.intro.IntroActivity;
import com.breadwallet.tools.manager.AnalyticsManager;
import com.breadwallet.tools.util.BRConstants;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class AnalyticsTests {
public static final String TAG = AnalyticsTests.class.getName();
@Rule
public ActivityTestRule<IntroActivity> mActivityRule = new ActivityTestRule<>(IntroActivity.class);

@Before
public void setUp() {
Log.e(TAG, "setUp: ");
}

@After
public void tearDown() {
}

/// This needs to be debugged. Some logs:
/// Error: WARNING: The option setting is experimental and unsupported
/// Manifest merger failed with multiple errors, see logs
/// Execution failed for task ':app:processLoafDebugAndroidTestManifest'.

@Test
public void testFirebaseAnalyticsConstants() {
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20191105_AL));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20191105_VSC));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20202116_VRC));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20191105_DSL));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20191105_DTBT));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200111_RNI));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200111_FNI));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200111_TNI));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200111_WNI));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200111_PNI));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200111_UTST));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200112_ERR));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200112_DSR));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200125_DSRR));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20201118_DTGS));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200217_DUWP));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200217_DUWB));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200223_DD));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200225_DCD));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200301_DUDFPK));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20201121_SIL));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20201121_DRIA));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20201121_FRIA));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20200207_DTHB));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20210405_TAWDF));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20210804_TAA2FAC));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20210804_TAWDS));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20210804_TAULI));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20210804_TAULO));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20210427_HCIEEH));
Assert.assertNotNull(AnalyticsManager.logCustomEvent(BRConstants._20220822_UTOU));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onComplete() {
unlockWallet();
AnalyticsManager.logCustomEvent(BRConstants._20200217_DLWB);
AnalyticsManager.logCustomEvent(BRConstants._20200217_DUWB);
}

@Override
Expand Down Expand Up @@ -298,7 +298,9 @@ private void updateDots() {
if (AuthManager.getInstance().checkAuth(pin.toString(), LoginActivity.this)) {
AuthManager.getInstance().authSuccess(LoginActivity.this);
unlockWallet();
AnalyticsManager.logCustomEvent(BRConstants._20200217_DLWP);
AnalyticsManager.logCustomEvent(BRConstants._20200217_DUWB);
AnalyticsManager.logCustomEvent(BRConstants._20200217_DUWB);

} else {
AuthManager.getInstance().authFail(LoginActivity.this);
showFailedToUnlock();
Expand Down Expand Up @@ -333,5 +335,6 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.breadwallet.presenter.customviews.BRDialogView;
import com.breadwallet.tools.animation.BRAnimator;
import com.breadwallet.tools.animation.BRDialog;
import com.breadwallet.tools.manager.AnalyticsManager;
import com.breadwallet.tools.manager.BRSharedPrefs;
import com.breadwallet.tools.threads.BRExecutor;
import com.breadwallet.tools.util.BRConstants;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void run() {
BRSharedPrefs.putAllowSpend(SyncBlockchainActivity.this, false);
BRPeerManager.getInstance().rescan();
BRAnimator.startBreadActivity(SyncBlockchainActivity.this, false);

AnalyticsManager.logCustomEvent(BRConstants._20200112_DSR);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import com.breadwallet.R;
import com.breadwallet.presenter.entities.Partner;
import com.breadwallet.tools.manager.AnalyticsManager;
import com.breadwallet.tools.util.BRConstants;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -47,6 +49,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
mRecyclerView.addItemDecoration(itemDecor);

mRecyclerView.setAdapter(new BuyPartnersAdapter(getContext(), getPartners()));
AnalyticsManager.logCustomEvent(BRConstants._20191105_DTBT);
}

private List<Partner> getPartners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.breadwallet.presenter.entities.BRMenuItem;
import com.breadwallet.tools.animation.BRAnimator;
import com.breadwallet.tools.animation.SlideDetector;
import com.breadwallet.tools.manager.AnalyticsManager;
import com.breadwallet.tools.util.BRConstants;
import com.platform.APIClient;

Expand Down Expand Up @@ -67,6 +68,7 @@ public View onCreateView(LayoutInflater inflater,
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getContext(), Uri.parse(BRConstants.CUSTOMER_SUPPORT_LINK));
AnalyticsManager.logCustomEvent(BRConstants._20201118_DTGS);
}));

/* Settings */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class FragmentSend : Fragment() {
comment
)
)
//AnalyticsManager.logCustomEvent(BRConstants._20191105_DSL)
AnalyticsManager.logCustomEvent(BRConstants._20191105_DSL);
BRSharedPrefs.incrementSendTransactionCount(context)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public static void init(Context context) {
instance = FirebaseAnalytics.getInstance(context);
}

public static void logCustomEvent(@BRConstants.Event String customEvent) {
public static Object logCustomEvent(@BRConstants.Event String customEvent) {
instance.logEvent(customEvent, null);
return null;
}

public static void logCustomEventWithParams(@BRConstants.Event String customEvent, Bundle params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.breadwallet.tools.util.BRExchange;
import com.breadwallet.tools.util.Utils;
import com.breadwallet.wallet.BRWalletManager;
import com.breadwallet.tools.manager.AnalyticsManager;

import java.math.BigDecimal;
import java.util.Locale;
Expand Down Expand Up @@ -73,6 +74,9 @@ public void run() {
long time = BRSharedPrefs.getFeeTime(app);
if (time <= 0 || now - time >= FEE_EXPIRATION_MILLIS) {
Timber.d("sendTransaction: fee out of date even after fetching...");

AnalyticsManager.logCustomEvent(BRConstants._20200111_FNI);

throw new FeeOutOfDate(time, now);
}
}
Expand Down Expand Up @@ -142,6 +146,7 @@ private void tryPay(final Context app, final PaymentItem paymentRequest) throws
Timber.d("handlePay: WRONG PARAMS");
String message = paymentRequest == null ? "paymentRequest is null" : "addresses is null";
RuntimeException ex = new RuntimeException("paymentRequest is malformed: " + message);

Timber.e(ex);
throw ex;
}
Expand Down
102 changes: 69 additions & 33 deletions app/src/main/java/com/breadwallet/tools/util/BRConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public class BRConstants {

public static final String TWITTER_LINK = "https://twitter.com/Litewallet_App";
public static final String REDDIT_LINK = "https://www.reddit.com/r/Litewallet";
public static final String WEB_LINK = "https://lite-wallet.org";
public static final String TOS_LINK = "https://lite-wallet.org/policy";
public static final String WEB_LINK = "https://litewalle.io";
public static final String TOS_LINK = "https://litewallet.io/privacy/policy.html";
public static String CUSTOMER_SUPPORT_LINK = "https://litecoinfoundation.zendesk.com";
public static String BITREFILL_AFFILIATE_LINK = "https://www.bitrefill.com/";

Expand All @@ -108,39 +108,75 @@ public class BRConstants {
private BRConstants() {
}


public static final String _20191105_AL = "APP_LAUNCHED";
public static final String _20191105_VSC = "VISIT_SEND_CONTROLLER";
public static final String _20202116_VRC = "VISIT_RECEIVE_CONTROLLER";
public static final String _20191105_DSL = "DID_SEND_LTC";
public static final String _20191105_DULP = "DID_UPDATE_LTC_PRICE";
public static final String _20191105_DTBT = "DID_TAP_BUY_TAB";
public static final String _20200111_DEDG = "DID_ENTER_DISPATCH_GROUP";
public static final String _20200111_DLDG = "DID_LEAVE_DISPATCH_GROUP";
public static final String _20200111_RNI = "RATE_NOT_INITIALIZED";
public static final String _20200111_FNI = "FEEPERKB_NOT_INITIALIZED";
public static final String _20200111_TNI = "TRANSACTION_NOT_INITIALIZED";
public static final String _20200111_WNI = "WALLET_NOT_INITIALIZED";
public static final String _20200111_PNI = "PHRASE_NOT_INITIALIZED";
public static final String _20200111_UTST = "UNABLE_TO_SIGN_TRANSACTION";
public static final String _20200112_ERR = "ERROR";
public static final String _20200112_DSR = "DID_START_RESYNC";
public static final String _20200125_DSRR = "DID_SHOW_REVIEW_REQUEST";
public static final String _20200217_DLWP = "DID_LOGIN_WITH_PIN";
public static final String _20200217_DLWB = "DID_LOGIN_WITH_BIOMETRICS";
public static final String _20200223_DD = "DID_DONATE";
public static final String _20200225_DCD = "DID_CANCEL_DONATE";
public static final String _20200301_DUDFPK = "DID_USE_DEFAULT_FEE_PER_KB";
public static final String _20201121_SIL = "STARTED_IFPS_LOOKUP";
public static final String _20201121_DRIA = "DID_RESOLVE_IPFS_ADDRESS";
public static final String _20201121_FRIA = "FAILED_RESOLVE_IPFS_ADDRESS";
public static final String _20191105_AL = "app_launched";
public static final String _20191105_VSC = "visit_send_controller";
public static final String _20202116_VRC = "visit_receive_controller";
public static final String _20191105_DSL = "did_send_ltc";
public static final String _20191105_DTBT = "did_tap_buy_tab";
public static final String _20200111_RNI = "rate_not_initialized";
public static final String _20200111_FNI = "feeperkb_not_initialized";
public static final String _20200111_TNI = "transaction_not_initialized";
public static final String _20200111_WNI = "wallet_not_initialized";
public static final String _20200111_PNI = "phrase_not_initialized";
public static final String _20200111_UTST = "unable_to_sign_transaction";
public static final String _20200112_ERR = "error";
public static final String _20200112_DSR = "did_start_resync";
public static final String _20200125_DSRR = "did_show_review_request";
public static final String _20201118_DTGS = "did_tap_get_support";
public static final String _20200217_DUWP = "did_unlock_with_pin";
public static final String _20200217_DUWB = "did_unlock_with_biometrics";
public static final String _20200223_DD = "did_donate";
public static final String _20200225_DCD = "did_cancel_donate";
public static final String _20200301_DUDFPK = "did_use_default_fee_per_kb";
public static final String _20201121_SIL = "started_IFPS_lookup";
public static final String _20201121_DRIA = "did_resolve_IPFS_address";
public static final String _20201121_FRIA = "failed_resolve_IPFS_address";

///Dev: These events not yet used
public static final String _20200207_DTHB = "did_tap_header_balance";
public static final String _20210405_TAWDF = "ternio_api_wallet_details_failure";
public static final String _20210804_TAA2FAC = "ternio_API_auth_2FA_change";
public static final String _20210804_TAWDS = "ternio_API_wallet_details_success";
public static final String _20210804_TAULI = "ternio_API_user_log_in";
public static final String _20210804_TAULO = "ternio_API_user_log_out";
public static final String _20210427_HCIEEH = "heartbeat_check_if_event_even_happens";
public static final String _20220822_UTOU = "user_tapped_on_ud";
///Dev: These events not yet used

@Retention(RetentionPolicy.SOURCE)
@StringDef({_20191105_AL, _20191105_VSC, _20202116_VRC, _20191105_DSL, _20191105_DULP,
_20191105_DTBT, _20200111_DEDG, _20200111_DLDG, _20200111_RNI, _20200111_FNI,
_20200111_TNI, _20200111_WNI, _20200111_PNI, _20200111_UTST, _20200112_ERR, _20200112_DSR,
_20200125_DSRR, _20200217_DLWP, _20200217_DLWB, _20200223_DD, _20200225_DCD, _20200301_DUDFPK,
_20201121_SIL, _20201121_DRIA, _20201121_FRIA})
@StringDef({
_20191105_AL,
_20191105_VSC,
_20202116_VRC,
_20191105_DSL,
_20191105_DTBT,
_20200111_RNI,
_20200111_FNI,
_20200111_TNI,
_20200111_WNI,
_20200111_PNI,
_20200111_UTST,
_20200112_ERR,
_20200112_DSR,
_20200125_DSRR,
_20201118_DTGS,
_20200217_DUWP,
_20200217_DUWB,
_20200223_DD,
_20200225_DCD,
_20200301_DUDFPK,
_20201121_SIL,
_20201121_DRIA,
_20201121_FRIA,
_20200207_DTHB,
_20210405_TAWDF,
_20210804_TAA2FAC,
_20210804_TAWDS,
_20210804_TAULI,
_20210804_TAULO,
_20210427_HCIEEH,
_20220822_UTOU
})
public @interface Event {
}

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/platform/APIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.breadwallet.BreadApp;
import com.breadwallet.BuildConfig;
import com.breadwallet.presenter.activities.util.ActivityUTILS;
import com.breadwallet.tools.util.BRConstants;
import com.breadwallet.tools.util.Utils;

import org.json.JSONException;
Expand All @@ -28,6 +29,8 @@
import okhttp3.Response;
import okhttp3.ResponseBody;
import timber.log.Timber;
import com.breadwallet.tools.manager.AnalyticsManager;
import com.breadwallet.tools.util.BRConstants;

import static com.breadwallet.tools.util.BRCompressor.gZipExtract;

Expand Down Expand Up @@ -82,6 +85,7 @@ public long feePerKb() {
body = response.body().string();
} catch (IOException e) {
Timber.e(e);
AnalyticsManager.logCustomEvent(BRConstants._20200111_RNI);
}
JSONObject object = null;
object = new JSONObject(body);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/platform/tools/KVStoreManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import android.content.Context;

import com.breadwallet.tools.crypto.CryptoHelper;
import com.breadwallet.tools.manager.AnalyticsManager;
import com.breadwallet.tools.util.BRCompressor;
import com.breadwallet.tools.util.BRConstants;
import com.breadwallet.tools.util.Utils;
import com.platform.APIClient;
import com.platform.entities.TxMetaData;
Expand Down Expand Up @@ -74,6 +76,7 @@ public TxMetaData valueToMetaData(byte[] value) {
JSONObject json;
if (value == null) {
Timber.d("valueToMetaData: value is null!");
AnalyticsManager.logCustomEvent(BRConstants._20200111_TNI);
return null;
}
try {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ org.gradle.jvmargs=-Xmx1536M
org.gradle.daemon=true
android.useAndroidX=true
android.enableJetifier=true
android.useNewApkCreator=true

# Build release info
RELEASE_STORE_FILE=/Users/grunt/crypto_projects/lf-projects/loafwallet-signing-binaries/new-upload/keystore.jks
Expand Down

0 comments on commit 08ac5bc

Please sign in to comment.