From 1e19afd92ef19000e3e834ff846d5c5b09b3ff5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com> Date: Tue, 1 Nov 2022 11:32:00 +0300 Subject: [PATCH] 472: set up sample app to showcase sentry integration --- android-json-form-wizard/build.gradle | 2 +- .../activities/JsonFormBaseActivity.java | 5 ----- sample/build.gradle | 13 +++++++++++ sample/src/main/AndroidManifest.xml | 1 + .../nativeform/MainActivity.java | 7 +++++- .../nativeform/MainApplication.java | 22 +++++++++++++++++++ 6 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 sample/src/main/java/org/smartregister/nativeform/MainApplication.java diff --git a/android-json-form-wizard/build.gradle b/android-json-form-wizard/build.gradle index 709beae15..eac01747b 100644 --- a/android-json-form-wizard/build.gradle +++ b/android-json-form-wizard/build.gradle @@ -151,7 +151,7 @@ dependencies { implementation "org.greenrobot:eventbus:3.2.0" implementation 'androidx.multidex:multidex:2.0.1' - implementation 'io.sentry:sentry-android:5.0.1' + api 'io.sentry:sentry-android:5.0.1' // PowerMock def powerMockVersion = '2.0.9' diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java index 48c79d7ae..c1f9aaa5f 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java @@ -43,8 +43,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import io.sentry.ITransaction; -import io.sentry.Sentry; import timber.log.Timber; import static com.vijay.jsonwizard.utils.NativeFormLangUtils.getTranslatedString; @@ -84,7 +82,6 @@ public abstract class JsonFormBaseActivity extends MultiLanguageActivity impleme protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.native_form_activity_json_form); - ITransaction transaction = Sentry.startTransaction("revealFormOpening", "insideJsonFormBase oncreate"); findViewById(R.id.native_form_activity).setFilterTouchesWhenObscured(true); mToolbar = findViewById(R.id.tb_top); setSupportActionBar(mToolbar); @@ -112,8 +109,6 @@ protected void onCreate(Bundle savedInstanceState) { for (LifeCycleListener lifeCycleListener : lifeCycleListeners) { lifeCycleListener.onCreate(savedInstanceState); } - - transaction.finish(); } private String readDataSource() { diff --git a/sample/build.gradle b/sample/build.gradle index 81bfb98d6..5f5e2113b 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -29,6 +29,8 @@ android { versionCode 1 versionName "1.0" multiDexEnabled true + + buildConfigField("String", "SENTRY_DSN", "\"" + getProps("sentry.dsn") + "\"") } buildTypes { @@ -60,3 +62,14 @@ dependencies { implementation 'org.smartregister:opensrp-client-utils:0.0.6-SNAPSHOT' } + +// get property from local.properties +def getProps(String propName) { + def propsFile = rootProject.file('local.properties') + if (propsFile.exists()) { + def props = new Properties() + props.load(new FileInputStream(propsFile)) + return props[propName] + } + return ""; +} diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 75c11a6ab..1eae6330d 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" + android:name=".MainApplication" android:theme="@style/NativeFormsAppTheme"> { + options.setEnvironment("opensrp-native-form-sample"); + options.setDsn(BuildConfig.SENTRY_DSN.trim()); + }); + } + + } +}