Skip to content

Commit f351e45

Browse files
feat: add back old metric function
1 parent 9af05cb commit f351e45

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

sdk/src/main/java/ly/count/android/sdk/DeviceInfo.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,32 @@ String getMetrics(@NonNull final Context context, @Nullable final Map<String, St
675675
return result;
676676
}
677677

678+
@NonNull
679+
String getMetricsHealthCheck(@NonNull final Context context, @Nullable final Map<String, String> metricOverride) {
680+
Map<String, Object> metrics = new ConcurrentHashMap<>();
681+
682+
String appVersion = mp.getAppVersion(context);
683+
684+
if (metricOverride != null) {
685+
if (metricOverride.containsKey("_app_version")) {
686+
appVersion = metricOverride.get("_app_version");
687+
}
688+
}
689+
690+
metrics.put("_app_version", appVersion);
691+
692+
String result = new JSONObject(metrics).toString();
693+
694+
try {
695+
result = java.net.URLEncoder.encode(result, "UTF-8");
696+
} catch (UnsupportedEncodingException ex) {
697+
// should never happen because Android guarantees UTF-8 support
698+
Countly.sharedInstance().L.e("[getMetrics] encode failed, [" + ex + "]");
699+
}
700+
701+
return result;
702+
}
703+
678704
/**
679705
* Returns a JSON object containing the device crash report
680706
*/

0 commit comments

Comments
 (0)