Skip to content

Conversation

@e7mac
Copy link
Contributor

@e7mac e7mac commented Jun 29, 2018

The Android SDK needs to report crashes. We will add another repo which will provide different crash reporting services to the main repo. This commit adds the interface for a raygun provider

@@ -0,0 +1,5 @@
package com.leanplum.monitoring;

public interface LeanplumCrashReporting {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rename this to ExceptionReporter

import java.lang.reflect.Constructor;

public class LeanplumCrashHandler {
private static final String RAYGUN_CRASH_REPORTER_CLASS =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAYGUN_CRASH_REPORTER_CLASS_NAME

public class LeanplumCrashHandler {
private static final String RAYGUN_CRASH_REPORTER_CLASS =
"com.leanplum.monitoring.internal.RaygunCrashReporter";
private static final LeanplumCrashHandler ourInstance = new LeanplumCrashHandler();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just instance


import java.lang.reflect.Constructor;

public class LeanplumCrashHandler {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the class name can be just CrashHandler, it already lives in package com.leanplum.monitoring


public void setContext(Context context) {
try {
Class<?> clazz = Class.forName(RAYGUN_CRASH_REPORTER_CLASS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using reflection to try to instantiate the class, we can just let the crash reporter register a factory, if it's loaded by the jvm.

so this CrashHandler can just expose a register method:

static void registerCrashReporterFactory(CrashReporterFactory crashReportFactory) {
 reporterFactory = crashReporterFactory;
}

then in setContext()

public void setContext(Context context) {
  if (reporterFactory != null) {
    crashReporter = crashReporterFactory.create(context);
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who calls registerCrashReporterFactory ? In my design, the module can just be added and won't need any additional code, hence reflection

@e7mac
Copy link
Contributor Author

e7mac commented Jun 29, 2018

test this please

1 similar comment
@e7mac
Copy link
Contributor Author

e7mac commented Jun 29, 2018

test this please


JSONObject responseBody;
HttpURLConnection op = null;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert ?

@e7mac e7mac changed the title Add crash handler code E2-1372 : Add crash handler code Jul 3, 2018
@e7mac e7mac merged commit 109e071 into develop Jul 3, 2018
@e7mac e7mac deleted the raygun2 branch July 6, 2018 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants