added crash, anr, background screens. added anr watchdog
This commit is contained in:
@@ -264,6 +264,8 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
|
||||
implementation "com.github.anrwatchdog:anrwatchdog:1.4.0"
|
||||
|
||||
implementation 'com.navi.medici:alfred:navi_v1.0.0-20230911.101354-15'
|
||||
|
||||
//noinspection GradleDynamicVersion
|
||||
|
||||
@@ -85,4 +85,9 @@ public class DeviceUtilsModule extends ReactContextBaseJavaModule implements Act
|
||||
public void startRecording() {
|
||||
// AlfredManager.INSTANCE.startRecording(RNContext, rootView, "", "", null);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setUserId(String userId) {
|
||||
AlfredManager.config.setUserId(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,14 @@ import com.facebook.react.ReactRootView;
|
||||
import com.navi.alfred.AlfredManager;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import kotlinx.coroutines.AwaitKt;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class MainActivity extends ReactActivity {
|
||||
|
||||
@@ -28,15 +36,15 @@ public class MainActivity extends ReactActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
AlfredManager.config.setEnableRecordingStatus(true);
|
||||
AlfredManager.config.setAlfredStatus(true);
|
||||
AlfredManager.INSTANCE.startRecording(this, getWindow().getDecorView().getRootView(), "cosmos", "cosmos", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
AlfredManager.INSTANCE.stopRecording(this.getWindow().getDecorView().getRootView());
|
||||
View appBackgroundView = LayoutInflater.from(this).inflate(R.layout.app_background_screen, null);
|
||||
AlfredManager.INSTANCE.measureInflatedView(appBackgroundView);
|
||||
AlfredManager.INSTANCE.stopRecording(appBackgroundView);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.avapp;
|
||||
|
||||
|
||||
import static com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_NAME;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
@@ -13,15 +13,22 @@ import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import com.avapp.newarchitecture.MainApplicationReactNativeHost;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.anrwatchdog.ANRError;
|
||||
import com.github.anrwatchdog.ANRWatchDog;
|
||||
import com.microsoft.codepush.react.CodePush;
|
||||
import com.navi.alfred.AlfredConfig;
|
||||
import com.navi.alfred.AlfredManager;
|
||||
|
||||
import android.database.CursorWindow;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class MainApplication extends Application implements ReactApplication {
|
||||
@@ -75,6 +82,33 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
|
||||
AlfredConfig alfredConfig = new AlfredConfig("Cosmos", "336", "4.0.0","qa");
|
||||
AlfredManager.INSTANCE.init(alfredConfig, getApplicationContext());
|
||||
alfredConfig.setEnableRecordingStatus(true);
|
||||
alfredConfig.setAlfredStatus(true);
|
||||
|
||||
new ANRWatchDog()
|
||||
.setIgnoreDebugger(true)
|
||||
.setReportMainThreadOnly()
|
||||
.setANRListener(new ANRWatchDog.ANRListener() {
|
||||
public void onAppNotResponding(ANRError error) {
|
||||
if (error.getCause().getStackTrace().length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String className = error.getCause().getStackTrace()[0].getClassName();
|
||||
Map<String, String> anrEventProperties = new HashMap<>();
|
||||
//anrEventProperties.put(SCREEN_NAME, NaviTrackEvent.getCurrentScreenName() != null ? NaviTrackEvent.getCurrentScreenName() : className);
|
||||
//anrEventProperties.put(METHOD_NAME, error.getCause().getStackTrace()[0].getMethodName());
|
||||
//anrEventProperties.put(LINE_NUMBER, String.valueOf(error.getCause().getStackTrace()[0].getLineNumber()));
|
||||
//anrEventProperties.put(APP_IN_FOREGROUND, String.valueOf(isAppInForeground(MainApplication.this)));
|
||||
|
||||
if (AlfredManager.config.getAlfredStatus() && AlfredManager.config.getAnrEnableStatus()) {
|
||||
//anrEventProperties.put(STACK_TRACE, error.getCause().getStackTrace()[0].toString());
|
||||
View anrView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.anr_screen, null);
|
||||
AlfredManager.INSTANCE.measureInflatedView(anrView);
|
||||
AlfredManager.INSTANCE.handleAnrEvent(anrEventProperties, anrView, SCREEN_NAME);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
// https://github.com/rt2zz/redux-persist/issues/284#issuecomment-1011214066
|
||||
try {
|
||||
|
||||
27
android/app/src/main/res/layout/anr_screen.xml
Normal file
27
android/app/src/main/res/layout/anr_screen.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_anr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Anr Occured"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
28
android/app/src/main/res/layout/app_background_screen.xml
Normal file
28
android/app/src/main/res/layout/app_background_screen.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/root_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_app_background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="App In Background"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
27
android/app/src/main/res/layout/crash_screen.xml
Normal file
27
android/app/src/main/res/layout/crash_screen.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_crash"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Crash Occured"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Reference in New Issue
Block a user