Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #310 from bitstadium/fix/eliminate-potential-crash…
Browse files Browse the repository at this point in the history
…-cause

Check if MetricsManager instance is actually initialized in sessionTr…
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Sep 26, 2017
2 parents fc2e313 + ef8afef commit 90b6752
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import net.hockeyapp.android.Constants;
import net.hockeyapp.android.PrivateEventManager;
Expand Down Expand Up @@ -283,7 +282,13 @@ private static void setUserMetricsEnabled(boolean enabled) {
* @return YES if session tracking is enabled
*/
public static boolean sessionTrackingEnabled() {
return isUserMetricsEnabled() && !instance.mSessionTrackingDisabled;
if (instance == null) {
HockeyLog.error(TAG, "MetricsManager hasn't been registered or User Metrics has been disabled. No User Metrics will be collected!");
return false;
}
else {
return isUserMetricsEnabled() && !instance.mSessionTrackingDisabled;
}
}

/**
Expand Down Expand Up @@ -468,7 +473,7 @@ public static void trackEvent(final String eventName, final Map<String, String>
return;
}
if (instance == null) {
Log.w(TAG, "MetricsManager hasn't been registered or User Metrics has been disabled. No User Metrics will be collected!");
HockeyLog.error(TAG, "MetricsManager hasn't been registered or User Metrics has been disabled. No User Metrics will be collected!");
return;
}
if (!isUserMetricsEnabled()) {
Expand Down

0 comments on commit 90b6752

Please sign in to comment.