diff --git a/CHANGELOG.md b/CHANGELOG.md index 9146bef2..4050dbd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## XX.XX.XX +* Introduced new health checks to monitor how device ID changes are handled. * Added a config option to content (setZoneTimerInterval) to set content zone timer. (Experimental!) ## 24.7.7 @@ -7,7 +8,7 @@ ## 24.7.6 * Added support for localization of content blocks. - +* * Mitigated an issue where visibility could have been wrongly assigned if a view was closed while going to background. (Experimental!) * Fixed a bug where passing the global content callback was not possible. * Mitigated an issue related to content actions navigation. diff --git a/sdk/src/main/java/ly/count/android/sdk/HealthCheckCounter.java b/sdk/src/main/java/ly/count/android/sdk/HealthCheckCounter.java index ce4038f8..4dd9ee67 100644 --- a/sdk/src/main/java/ly/count/android/sdk/HealthCheckCounter.java +++ b/sdk/src/main/java/ly/count/android/sdk/HealthCheckCounter.java @@ -10,16 +10,22 @@ public class HealthCheckCounter implements HealthTracker { public long countLogError = 0; public int statusCode = -1; public String errorMessage = ""; - + public int mergeCount = 0; + public int withoutMergeCount = 0; + final String keyLogError = "LErr"; final String keyLogWarning = "LWar"; final String keyStatusCode = "RStatC"; final String keyErrorMessage = "REMsg"; + final String keyMergeCount = "MCount"; + final String keyWithoutMergeCount = "WMCount"; final String requestKeyErrorCount = "el"; final String requestKeyWarningCount = "wl"; final String requestKeyStatusCode = "sc"; final String requestKeyRequestError = "em"; + final String requestKeyChangeWithMerge = "mc"; + final String requestKeyChangeWithoutMerge = "wmc"; StorageProvider storageProvider; ModuleLog L; @@ -47,6 +53,8 @@ void setupInitialCounters(@NonNull String initialState) { countLogError = jsonObject.optLong(keyLogError, 0); statusCode = jsonObject.optInt(keyStatusCode, -1); errorMessage = jsonObject.optString(keyErrorMessage, ""); + mergeCount = jsonObject.optInt(keyMergeCount, 0); + withoutMergeCount = jsonObject.optInt(keyWithoutMergeCount, 0); L.d("[HealthCheckCounter] Loaded initial health check state: [" + jsonObject.toString() + "]"); } catch (Exception e) { @@ -67,7 +75,7 @@ void setupInitialCounters(@NonNull String initialState) { assert statusCode > 0; assert statusCode < 1000; assert errorResponse != null; - + this.statusCode = statusCode; if (errorResponse.length() > 1000) { @@ -102,6 +110,8 @@ void setupInitialCounters(@NonNull String initialState) { jsonObject.put(keyLogError, countLogError); jsonObject.put(keyStatusCode, statusCode); jsonObject.put(keyErrorMessage, errorMessage); + jsonObject.put(keyMergeCount, mergeCount); + jsonObject.put(keyWithoutMergeCount, withoutMergeCount); storageProvider.setHealthCheckCounterState(jsonObject.toString()); } catch (Exception e) { @@ -109,12 +119,22 @@ void setupInitialCounters(@NonNull String initialState) { } } + @Override public void logDeviceIdWithMergeChange() { + mergeCount++; + } + + @Override public void logDeviceIdWithoutMergeChange() { + withoutMergeCount++; + } + void clearValues() { L.v("[HealthCheckCounter] Clearing counters"); countLogWarning = 0; countLogError = 0; statusCode = -1; errorMessage = ""; + mergeCount = 0; + withoutMergeCount = 0; } @NonNull String createRequestParam() { @@ -128,6 +148,8 @@ void clearValues() { jsonObject.put(requestKeyWarningCount, countLogWarning); jsonObject.put(requestKeyStatusCode, statusCode); jsonObject.put(requestKeyRequestError, errorMessage); + jsonObject.put(requestKeyChangeWithMerge, mergeCount); + jsonObject.put(requestKeyChangeWithoutMerge, withoutMergeCount); } catch (JSONException e) { L.w("[HealthCheckCounter] Failed to create param for hc request, " + e); } diff --git a/sdk/src/main/java/ly/count/android/sdk/HealthTracker.java b/sdk/src/main/java/ly/count/android/sdk/HealthTracker.java index cde9da7b..78456b6d 100644 --- a/sdk/src/main/java/ly/count/android/sdk/HealthTracker.java +++ b/sdk/src/main/java/ly/count/android/sdk/HealthTracker.java @@ -16,4 +16,8 @@ interface HealthTracker { void clearAndSave(); void saveState(); + + void logDeviceIdWithMergeChange(); + + void logDeviceIdWithoutMergeChange(); } diff --git a/sdk/src/main/java/ly/count/android/sdk/ModuleDeviceId.java b/sdk/src/main/java/ly/count/android/sdk/ModuleDeviceId.java index d3b3e701..bad348a3 100644 --- a/sdk/src/main/java/ly/count/android/sdk/ModuleDeviceId.java +++ b/sdk/src/main/java/ly/count/android/sdk/ModuleDeviceId.java @@ -151,6 +151,7 @@ void changeDeviceIdWithoutMergeInternal(@NonNull String deviceId) { } else { // setting a custom device ID deviceIdInstance.changeToCustomId(deviceId); + healthTracker.logDeviceIdWithoutMergeChange(); } //clear automated star rating session values because now we have a new user @@ -201,6 +202,7 @@ void changeDeviceIdWithMergeInternal(@NonNull String deviceId) { _cly.moduleRemoteConfig.clearAndDownloadAfterIdChange(); requestQueueProvider.changeDeviceId(deviceId, deviceIdInstance.getCurrentId()); deviceIdInstance.changeToCustomId(deviceId); + healthTracker.logDeviceIdWithMergeChange(); _cly.notifyDeviceIdChange(false); } }