Skip to content

Commit e6e4b44

Browse files
committed
integrate sentry
1 parent dedec0f commit e6e4b44

11 files changed

Lines changed: 339 additions & 213 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:7.3.1'
10+
classpath 'com.android.tools.build:gradle:8.13.0'
1111
classpath 'com.apollographql.apollo:apollo-gradle-plugin:2.5.14'
1212

1313
// NOTE: Do not place your application dependencies here; they belong

claimManagement/build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ repositories {
1919
}
2020

2121
android {
22-
compileSdkVersion 32
22+
compileSdk = 34
2323
buildToolsVersion '33.0.0'
2424

2525
defaultConfig {
2626
applicationId "org.openimis.imisclaims"
2727
minSdkVersion 26
28-
targetSdkVersion 32
28+
targetSdkVersion 33
2929
versionCode 4
30-
versionName "2.3.6"
30+
versionName "2.3.7"
3131
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
3232
}
3333
buildTypes {
@@ -111,6 +111,7 @@ android {
111111
buildConfigField "String", "API_BASE_URL", '"https://csuapps.minsante.cm/"'
112112
buildConfigField "String", "RAR_PASSWORD", '"xc3-ed@/dfr;nJ3R"'
113113
dimension 'std'
114+
resValue "string", "sentry_dsn", '"https://54612a80b36c47e78722b9779410e3d1@glitchtip-csuapps.minsante.cm/9"'
114115
}
115116
niger {
116117
applicationIdSuffix ".niger"
@@ -190,6 +191,7 @@ android {
190191
packagingOptions {
191192
exclude 'META-INF/DEPENDENCIES'
192193
}
194+
namespace 'org.openimis.imisclaims'
193195
}
194196

195197
apollo {
@@ -231,5 +233,6 @@ dependencies {
231233
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
232234
implementation group: 'com.squareup.picasso', name: 'picasso', version: '2.71828'
233235
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '1.2.7'
236+
implementation 'io.sentry:sentry-android:8.25.0'
234237

235238
}

claimManagement/src/main/AndroidManifest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="org.openimis.imisclaims">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<uses-permission android:name="android.permission.INTERNET" />
76
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -57,10 +56,13 @@
5756
android:resource="@xml/paths" />
5857
</provider>
5958

59+
<meta-data
60+
android:name="io.sentry.dsn"
61+
android:value="@string/sentry_dsn" />
62+
6063
<activity
6164
android:name=".MainActivity"
6265
android:exported="true"
63-
android:label="@string/app_name_claims"
6466
android:theme="@style/AppTheme.NoActionBar">
6567
<intent-filter>
6668
<action android:name="android.intent.action.MAIN" />

claimManagement/src/main/java/org/openimis/imisclaims/MainActivity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
import java.util.List;
7171
import java.util.Objects;
7272

73+
import io.sentry.Sentry;
74+
7375
public class MainActivity extends ImisActivity {
7476
private static final int REQUEST_PERMISSIONS_CODE = 1;
7577
private static final int REQUEST_ALL_FILES_ACCESS_CODE = 2;
@@ -295,6 +297,7 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten
295297
}
296298
} catch (Exception e) {
297299
Log.e(LOG_TAG, "Error while copying master data.", e);
300+
Sentry.captureException(e);
298301
}
299302
}
300303
}
@@ -314,6 +317,7 @@ public void PickMasterDataFileDialog() {
314317
try {
315318
startActivityForResult(intent, REQUEST_PICK_MD_FILE);
316319
} catch (ActivityNotFoundException e) {
320+
Sentry.captureException(e);
317321
Toast.makeText(getApplicationContext(), getResources().getString(R.string.NoFileExporerInstalled), Toast.LENGTH_SHORT).show();
318322
}
319323
}).setNegativeButton(getResources().getString(R.string.No),
@@ -331,6 +335,7 @@ public AlertDialog confirmRefreshMap() {
331335
doLoggedIn(() -> DownLoadDiagnosesServicesItems(global.getOfficerCode()));
332336
} catch (Exception e) {
333337
e.printStackTrace();
338+
Sentry.captureException(e);
334339
}
335340
},
336341
(dialog, i) -> dialog.cancel());
@@ -420,6 +425,7 @@ public AlertDialog DownloadMasterDialog() {
420425
}
421426
} catch (Exception e) {
422427
e.printStackTrace();
428+
Sentry.captureException(e);
423429
DownloadMasterDialog();
424430
}
425431
} else {
@@ -454,6 +460,7 @@ private void checkForUpdates() {
454460
mNotificationManager.notify(SIMPLE_NOTIFICATION_ID, builder.build());
455461
} catch (Exception e) {
456462
e.printStackTrace();
463+
Sentry.captureException(e);
457464
}
458465

459466
vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
@@ -490,6 +497,7 @@ public void run() {
490497
});
491498
} catch (Exception e) {
492499
e.printStackTrace();
500+
Sentry.captureException(e);
493501
runOnUiThread(() -> {
494502
progressDialog.dismiss();
495503
if(!global.isNetworkAvailable()){
@@ -539,6 +547,7 @@ public void getClaimAdmins() {
539547

540548
} catch (Exception e) {
541549
e.printStackTrace();
550+
Sentry.captureException(e);
542551
runOnUiThread(() -> {
543552
progressDialog.dismiss();
544553
if(!global.isNetworkAvailable()){
@@ -628,6 +637,7 @@ public void downloadServices(@NonNull final String claimAdminCode) {
628637
}
629638
} catch ( Exception e) {
630639
e.printStackTrace();
640+
Sentry.captureException(e);
631641
if(!global.isNetworkAvailable()){
632642
Toast.makeText(MainActivity.this, getResources().getString(R.string.CheckConnection), Toast.LENGTH_LONG).show();
633643
} else {
@@ -675,6 +685,7 @@ public void downloadItems(@NonNull final String claimAdminCode) {
675685
}
676686
} catch (Exception e) {
677687
e.printStackTrace();
688+
Sentry.captureException(e);
678689
if(!global.isNetworkAvailable()){
679690
Toast.makeText(MainActivity.this, getResources().getString(R.string.CheckConnection), Toast.LENGTH_LONG).show();
680691
} else {
@@ -716,6 +727,7 @@ public void validateClaimAdminCode(final String claimAdminCode) {
716727
doLoggedIn(() -> DownLoadDiagnosesServicesItems(claimAdminCode));
717728
} catch (Exception e) {
718729
e.printStackTrace();
730+
Sentry.captureException(e);
719731
}
720732
}
721733
c.close();
@@ -778,6 +790,7 @@ public void run() {
778790
});
779791
} catch (Exception e) {
780792
e.printStackTrace();
793+
Sentry.captureException(e);
781794
runOnUiThread(() -> {
782795
progressDialog.dismiss();
783796
if(!global.isNetworkAvailable()){
@@ -837,6 +850,7 @@ public void run() {
837850
});
838851
} catch (Exception e) {
839852
e.printStackTrace();
853+
Sentry.captureException(e);
840854
runOnUiThread(() -> {
841855
progressDialog.dismiss();
842856
if(!global.isNetworkAvailable()){

claimManagement/src/main/java/org/openimis/imisclaims/SynchronizeActivity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
import java.util.Locale;
7272
import java.util.Objects;
7373

74+
import io.sentry.Sentry;
75+
7476
public class SynchronizeActivity extends ImisActivity {
7577
private static final String LOG_TAG = "SYNCACTIVITY";
7678
private static final int PICK_FILE_REQUEST_CODE = 1;
@@ -165,6 +167,7 @@ protected void onBroadcastReceived(Context context, Intent intent) {
165167
}
166168
} catch (JSONException e) {
167169
Log.e(LOG_TAG, "Error while processing claim response", e);
170+
Sentry.captureException(e);
168171
}
169172
break;
170173
case SynchronizeService.ACTION_EXPORT_ERROR:
@@ -358,6 +361,7 @@ public void downloadServices() {
358361
}
359362
} catch ( Exception e) {
360363
e.printStackTrace();
364+
Sentry.captureException(e);
361365
}
362366
});
363367
thread.start();
@@ -447,6 +451,7 @@ public void downloadItems() {
447451
}
448452
} catch (Exception e) {
449453
e.printStackTrace();
454+
Sentry.captureException(e);
450455
runOnUiThread(() -> pd.dismiss());
451456
}
452457
});
@@ -510,6 +515,7 @@ public void run() {
510515
});
511516
} catch (Exception e) {
512517
e.printStackTrace();
518+
Sentry.captureException(e);
513519
runOnUiThread(() -> {
514520
pd.dismiss();
515521
Toast.makeText(SynchronizeActivity.this, e.getMessage() + "-" + getResources().getString(R.string.SomethingWentWrongServer), Toast.LENGTH_LONG).show();
@@ -542,6 +548,7 @@ public void run() {
542548
});
543549
} catch (Exception e) {
544550
e.printStackTrace();
551+
Sentry.captureException(e);
545552
runOnUiThread(() -> {
546553
pd.dismiss();
547554
ErrorDialogBox(e.getMessage());
@@ -584,6 +591,7 @@ public void downloadAdmins(){
584591

585592
} catch (Exception e) {
586593
e.printStackTrace();
594+
Sentry.captureException(e);
587595
runOnUiThread(() -> pd.dismiss());
588596
}
589597
});
@@ -668,6 +676,7 @@ public void CheckUpdate(){
668676
Toast.LENGTH_SHORT).show();
669677
});
670678
} catch (Exception e) {
679+
Sentry.captureException(e);
671680
runOnUiThread(() -> {
672681
pd.dismiss();
673682
if(!global.isNetworkAvailable()){
@@ -706,6 +715,7 @@ public void downloadUpdate(String lastVersion, String tagName) {
706715
} catch (Exception e) {
707716
Toast.makeText(this, getResources().getString(R.string.downloadUpdateFail), Toast.LENGTH_SHORT).show();
708717
Log.e("DownloadUpdate", "Erreur: ", e);
718+
Sentry.captureException(e);
709719
}
710720
}
711721
}

claimManagement/src/main/java/org/openimis/imisclaims/SynchronizeService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import java.util.Locale;
4242
import java.util.Objects;
4343

44+
import io.sentry.Sentry;
45+
4446
public class SynchronizeService extends JobIntentService {
4547
private static final int JOB_ID = 6541259; //Random unique Job id
4648
private static final String LOG_TAG = "SYNCSERVICE";
@@ -142,15 +144,15 @@ private void handleUploadClaims() {
142144

143145
if(isValidClaimCode){
144146
// Search insuree
145-
try{
147+
try {
146148
String insuree = new FetchInsuree().execute(claim.getInsuranceNumber());
147149
if(!insuree.isEmpty()){
148150
insureeId = Integer.parseInt(insuree);
149151
if(claim.getClaimProgram().equals("Cheque Santé") || claim.getClaimProgram().equals("Chèque Santé")){
150152
if(claim.getClaimPrefix() != null){
151153
List<ChequeImport> cheques = new ArrayList<>();
152154
// search cheque number in server
153-
try{
155+
try {
154156
cheques = new FetchChequeNumber().execute(claim.getClaimPrefix());
155157
if(cheques.isEmpty()){
156158
//invalid cheque
@@ -215,13 +217,15 @@ private void handleUploadClaims() {
215217
} else {
216218
result = new PostNewClaims.Result(claim.getClaimNumber(), PostNewClaims.Result.Status.ERROR,getResources().getString(R.string.SomethingWentWrongServer));
217219
}
220+
Sentry.captureException(e);
218221
results.add(result);
219222
}
220223
}
221224
JSONArray claimStatus = processClaimResponse(results);
222225
broadcastSyncSuccess(claimStatus);
223226
} catch (Exception e) {
224227
e.printStackTrace();
228+
Sentry.captureException(e);
225229
broadcastError(getResources().getString(R.string.ErrorOccurred) + ": " + e.getMessage(), ACTION_UPLOAD_CLAIMS);
226230
}
227231
}
@@ -429,6 +433,7 @@ private void handleExportClaims() {
429433
SQLHandler.CLAIM_UPLOAD_STATUS_EXPORTED, null);
430434
} catch (JSONException e) {
431435
Log.e(LOG_TAG, "Exception while exporting claims", e);
436+
Sentry.captureException(e);
432437
}
433438
}
434439

@@ -453,6 +458,7 @@ private File createClaimFile(JSONObject details) {
453458
return storageManager.createTempFile("exports/claim/" + filename);
454459
} catch (JSONException e) {
455460
Log.e(LOG_TAG, "Parsing claim JSON failed", e);
461+
Sentry.captureException(e);
456462
}
457463
return null;
458464
}
@@ -467,6 +473,7 @@ private void writeClaimToXmlFile(File claimFile, JSONObject claim) {
467473
serializer.endDocument();
468474
} catch (IOException e) {
469475
Log.e(LOG_TAG, "Writing XML file failed", e);
476+
Sentry.captureException(e);
470477
}
471478
}
472479

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
android.defaults.buildfeatures.buildconfig=true
12
android.enableJetifier=true
3+
android.nonFinalResIds=false
4+
android.nonTransitiveRClass=false
25
android.useAndroidX=true

gradle/wrapper/gradle-wrapper.jar

-6.28 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Fri Sep 09 17:28:52 WAT 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)