Skip to content

Commit

Permalink
fix: added filter for rudderstack crashes (#325)
Browse files Browse the repository at this point in the history
* fix: added filter for rudderstack crashes
added a default value to build config
removed unnecessary exception reporting
 update rudderreporter version
  • Loading branch information
itsdebs authored Oct 3, 2023
1 parent 16e1817 commit b804a32
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
implementation 'androidx.annotation:annotation:1.6.0'


implementation ('com.rudderstack.android.sdk:rudderreporter:0.2.0')
implementation ('com.rudderstack.android.sdk:rudderreporter:0.3.0')
// implementation(project(path: ':rudderreporter'))
// implementation(project(path: ':gsonrudderadapter'))
implementation 'com.rudderstack.kotlin.sdk:gsonrudderadapter:0.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.rudderstack.android.ruddermetricsreporterandroid.Metrics;
import com.rudderstack.android.ruddermetricsreporterandroid.RudderReporter;
import com.rudderstack.android.ruddermetricsreporterandroid.error.BreadcrumbType;
import com.rudderstack.android.ruddermetricsreporterandroid.error.CrashFilter;
import com.rudderstack.android.ruddermetricsreporterandroid.error.ErrorClient;
import com.rudderstack.android.ruddermetricsreporterandroid.metrics.LongCounter;
import com.rudderstack.gsonrudderadapter.GsonAdapter;
Expand Down Expand Up @@ -209,12 +210,9 @@ private static void checkAndUpdateErrorsCollection(boolean isErrorsEnabled) {
private static void initiateRudderReporter(Context context, @Nullable String writeKey,
boolean isMetricsEnabled, boolean isErrorsEnabled) {
RudderLogger.logDebug("EventRepository: Creating RudderReporter isMetricsEnabled: " + isMetricsEnabled + " isErrorsEnabled: " + isErrorsEnabled);
String writeKeyOrBlank = writeKey == null ? "" : writeKey;
if (rudderReporter == null) {
rudderReporter = new DefaultRudderReporter(context, METRICS_URL_PROD,
new Configuration(new LibraryMetadata(
BuildConfig.LIBRARY_PACKAGE_NAME, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, writeKeyOrBlank
)), new GsonAdapter(), isMetricsEnabled, isErrorsEnabled);
getStatsConfig(writeKey), new GsonAdapter(), isMetricsEnabled, isErrorsEnabled);
rudderReporter.getSyncer().startScheduledSyncs(METRICS_UPLOAD_INTERVAL,
true, METRICS_FLUSH_COUNT);
//we default to null if metrics or errors are not enabled
Expand All @@ -223,6 +221,15 @@ private static void initiateRudderReporter(Context context, @Nullable String wri
}
}

private static Configuration getStatsConfig(@Nullable String writeKey) {
String writeKeyOrBlank = writeKey == null ? "" : writeKey;
Configuration config = new Configuration(new LibraryMetadata(
BuildConfig.LIBRARY_PACKAGE_NAME, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, writeKeyOrBlank
));
config.setCrashFilter(CrashFilter.generateWithKeyWords(Collections.singletonList("rudderstack")));
return config;
}

static void incrementMessageCounter(int value, Map<String, String> attributes) {
incrementCounter(messageCounter, value, attributes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private HttpURLConnection updateHttpConnection(String requestURL, RequestMethod
return updateHttpConnection(httpConnection, requestMethod, requestPayload, isDMTRequest,
null, null);
} catch (Exception ex) {
ReportManager.reportError(ex);
// ReportManager.reportError(ex);
RudderLogger.logError("RudderNetworkManager: sendNetworkRequest: Exception occurred while creating HttpURLConnection" + ex.getLocalizedMessage());
return null;
}
Expand Down Expand Up @@ -238,7 +238,7 @@ private HttpURLConnection updateHttpConnectionForPostRequest(HttpURLConnection h
osw.flush();
return httpConnection;
} catch (Exception ex) {
ReportManager.reportError(ex);
// ReportManager.reportError(ex);
RudderLogger.logError("RudderNetworkManager: updateHttpConnection: Error while updating the http connection" + ex.getLocalizedMessage());
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion sample-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "DATA_PLANE_URL", properties.getProperty('dataplaneUrl', 'https://api.rudderstack.com'))
buildConfigField("String", "CONTROL_PLANE_URL", properties.getProperty('controlplaneUrl', "\"https://api.rudderstack.com\""))
buildConfigField("String", "WRITE_KEY", properties.getProperty('writeKey', ''))
buildConfigField("String", "WRITE_KEY", properties.getProperty('writeKey', "\"\""))
}
buildTypes {
debug {
Expand Down Expand Up @@ -63,6 +63,7 @@ dependencies {

// Rudder Android Core SDK
implementation project(':core')
// implementation 'com.rudderstack.android.sdk:core:1.19.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation "androidx.work:work-runtime:2.7.1"

Expand Down

0 comments on commit b804a32

Please sign in to comment.