(fix) point to androidacy sentry instance

sentry saas is becoming too expensive to use, so switch back to androidacy hosted

same or stronger privacy protection, server side data scrubbing enabled, and for EU users data stays in EU

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/300/head
androidacy-user 1 year ago
parent 7effbaac2f
commit 36b583932f

@ -196,7 +196,7 @@
android:value="false" /> android:value="false" />
<meta-data <meta-data
android:name="io.sentry.dsn" android:name="io.sentry.dsn"
android:value="https://198c68516cb0412b9832204631a3fac8@o993586.ingest.sentry.io/4504069942804480" /> android:value="https://f35f7f369a254b2ca854cf9593c99da2@sentry.androidacy.com/7" />
<!-- Sane value, but feel free to lower it --> <!-- Sane value, but feel free to lower it -->
<meta-data <meta-data
android:name="io.sentry.traces.sample-rate" android:name="io.sentry.traces.sample-rate"

@ -15,6 +15,7 @@ import com.fox2code.foxcompat.app.FoxApplication;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textview.MaterialTextView; import com.google.android.material.textview.MaterialTextView;
import org.chromium.net.CronetEngine;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -99,17 +100,20 @@ public class CrashHandler extends FoxActivity {
final String[] emailString = {email.getText().toString().equals("") ? "Anonymous" : email.getText().toString()}; final String[] emailString = {email.getText().toString().equals("") ? "Anonymous" : email.getText().toString()};
// Prevent strict mode violation // Prevent strict mode violation
// create sentry userFeedback request // create sentry userFeedback request
try {
URL.setURLStreamHandlerFactory(new CronetEngine.Builder(this).build().createURLStreamHandlerFactory());
} catch (Error ignored) {
// Ignore
}
new Thread(() -> { new Thread(() -> {
try { try {
HttpURLConnection connection = (HttpURLConnection) new URL("https" + "://sentry.io/api/0/projects/androidacy-i6/foxmmm/user-feedback/").openConnection(); HttpURLConnection connection = (HttpURLConnection) new URL("https" + "://sentry.androidacy.com/api/0/projects/sentry/foxmmm/user-feedback/").openConnection();
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Bearer " + BuildConfig.SENTRY_TOKEN); connection.setRequestProperty("Authorization", "Bearer " + BuildConfig.SENTRY_TOKEN);
// Setups the JSON body // Setups the JSON body
if (nameString[0].equals("")) if (nameString[0].equals("")) nameString[0] = "Anonymous";
nameString[0] = "Anonymous"; if (emailString[0].equals("")) emailString[0] = "Anonymous";
if (emailString[0].equals(""))
emailString[0] = "Anonymous";
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
body.put("event_id", lastEventId); body.put("event_id", lastEventId);
body.put("name", nameString[0]); body.put("name", nameString[0]);
@ -121,22 +125,27 @@ public class CrashHandler extends FoxActivity {
outputStream.write(body.toString().getBytes()); outputStream.write(body.toString().getBytes());
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
// get response body
byte[] response;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
response = connection.getInputStream().readAllBytes();
// convert response to string
String responseBody = new String(response);
// log the response body
Timber.d("Response Body: %s", responseBody);
}
// close and disconnect the connection // close and disconnect the connection
connection.getInputStream().close(); connection.getInputStream().close();
connection.disconnect(); connection.disconnect();
// For debug builds, log the response code and response body // For debug builds, log the response code and response body
if (BuildConfig.DEBUG) { Timber.d("Response Code: %s", connection.getResponseCode());
Timber.d("Response Code: %s", connection.getResponseCode());
}
// Check if the request was successful // Check if the request was successful
if (connection.getResponseCode() == 200) { if (connection.getResponseCode() == 200) {
runOnUiThread(() -> Toast.makeText(this, R.string.sentry_dialogue_success, Toast.LENGTH_LONG).show()); runOnUiThread(() -> Toast.makeText(this, R.string.sentry_dialogue_success, Toast.LENGTH_LONG).show());
} else { } else {
runOnUiThread(() -> Toast.makeText(this, R.string.sentry_dialogue_failed_toast, Toast.LENGTH_LONG).show()); runOnUiThread(() -> Toast.makeText(this, R.string.sentry_dialogue_failed_toast, Toast.LENGTH_LONG).show());
} }
} catch ( } catch (JSONException | IOException ignored) {
JSONException |
IOException ignored) {
// Show a toast if the user feedback could not be submitted // Show a toast if the user feedback could not be submitted
runOnUiThread(() -> Toast.makeText(this, R.string.sentry_dialogue_failed_toast, Toast.LENGTH_LONG).show()); runOnUiThread(() -> Toast.makeText(this, R.string.sentry_dialogue_failed_toast, Toast.LENGTH_LONG).show());
} }
@ -185,7 +194,7 @@ public class CrashHandler extends FoxActivity {
builder.setMessage(R.string.reset_app_confirmation); builder.setMessage(R.string.reset_app_confirmation);
builder.setPositiveButton(R.string.reset, (dialog, which) -> { builder.setPositiveButton(R.string.reset, (dialog, which) -> {
// reset the app // reset the app
MainApplication.getINSTANCE().resetApp(); MainApplication.getINSTANCE().resetApp();
}); });
builder.setNegativeButton(R.string.cancel, (dialog, which) -> { builder.setNegativeButton(R.string.cancel, (dialog, which) -> {
// do nothing // do nothing
@ -207,8 +216,7 @@ public class CrashHandler extends FoxActivity {
new Thread(() -> { new Thread(() -> {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch ( } catch (InterruptedException e) {
InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
runOnUiThread(() -> view.setBackgroundResource(R.drawable.baseline_copy_all_24)); runOnUiThread(() -> view.setBackgroundResource(R.drawable.baseline_copy_all_24));

@ -32,8 +32,10 @@ public class SentryMain {
SharedPreferences.Editor editor = MainApplication.getINSTANCE().getSharedPreferences("sentry", Context.MODE_PRIVATE).edit(); SharedPreferences.Editor editor = MainApplication.getINSTANCE().getSharedPreferences("sentry", Context.MODE_PRIVATE).edit();
editor.putString("lastExitReason", "crash"); editor.putString("lastExitReason", "crash");
editor.putLong("lastExitTime", System.currentTimeMillis()); editor.putLong("lastExitTime", System.currentTimeMillis());
editor.putString("lastExitReason", "crash");
editor.putString("lastExitId", String.valueOf(Sentry.getLastEventId()));
editor.apply(); editor.apply();
Timber.e(throwable, "Uncaught exception"); Timber.e("Uncaught exception with sentry ID %s and stacktrace %s", Sentry.getLastEventId(), throwable.getStackTrace());
// open crash handler and exit // open crash handler and exit
Intent intent = new Intent(mainApplication, CrashHandler.class); Intent intent = new Intent(mainApplication, CrashHandler.class);
// pass the entire exception to the crash handler // pass the entire exception to the crash handler

Loading…
Cancel
Save