Skip to content

Commit e627552

Browse files
feat: add detailed logs to unsupported data types
1 parent b956455 commit e627552

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

sdk/src/androidTest/java/ly/count/android/sdk/UtilsInternalLimitsTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public void removeReservedKeysFromSegmentation() {
244244

245245
@Test(expected = AssertionError.class)
246246
public void removeUnsupportedDataTypesNull() {
247-
Assert.assertFalse(UtilsInternalLimits.removeUnsupportedDataTypes(null));
247+
Assert.assertFalse(UtilsInternalLimits.removeUnsupportedDataTypes(null, Mockito.mock(ModuleLog.class)));
248248
}
249249

250250
@Test
@@ -261,7 +261,7 @@ public void removeUnsupportedDataTypes() {
261261
segm.put("41", new Object());
262262
segm.put("42", new int[] { 1, 2 });
263263

264-
Assert.assertTrue(UtilsInternalLimits.removeUnsupportedDataTypes(segm));
264+
Assert.assertTrue(UtilsInternalLimits.removeUnsupportedDataTypes(segm, Mockito.mock(ModuleLog.class)));
265265

266266
Assert.assertTrue(segm.containsKey("aa"));
267267
Assert.assertTrue(segm.containsKey("aa1"));
@@ -284,7 +284,7 @@ public void removeUnsupportedDataTypes2() {
284284

285285
Assert.assertEquals(3, segm.size());
286286

287-
Assert.assertTrue(UtilsInternalLimits.removeUnsupportedDataTypes(segm));
287+
Assert.assertTrue(UtilsInternalLimits.removeUnsupportedDataTypes(segm, Mockito.mock(ModuleLog.class)));
288288

289289
Assert.assertEquals(0, segm.size());
290290

@@ -298,7 +298,7 @@ public void removeUnsupportedDataTypes2() {
298298

299299
Assert.assertEquals(7, segm.size());
300300

301-
Assert.assertTrue(UtilsInternalLimits.removeUnsupportedDataTypes(segm));
301+
Assert.assertTrue(UtilsInternalLimits.removeUnsupportedDataTypes(segm, Mockito.mock(ModuleLog.class)));
302302

303303
Assert.assertEquals(4, segm.size());
304304
Assert.assertTrue(segm.containsKey("1"));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ boolean crashFilterCheck(@NonNull CrashData crashData) {
256256
UtilsInternalLimits.applySdkInternalLimitsToSegmentation(crashData.getCrashSegmentation(), _cly.config_.sdkInternalLimits, L, "[ModuleCrash] sendCrashReportToQueue");
257257
String truncatedStackTrace = UtilsInternalLimits.applyInternalLimitsToStackTraces(crashData.getStackTrace(), _cly.config_.sdkInternalLimits.maxStackTraceLineLength, "[ModuleCrash] sendCrashReportToQueue", L);
258258
crashData.setStackTrace(truncatedStackTrace);
259-
UtilsInternalLimits.removeUnsupportedDataTypes(crashData.getCrashSegmentation());
260-
UtilsInternalLimits.removeUnsupportedDataTypes(crashData.getCrashMetrics());
259+
UtilsInternalLimits.removeUnsupportedDataTypes(crashData.getCrashSegmentation(), L);
260+
UtilsInternalLimits.removeUnsupportedDataTypes(crashData.getCrashMetrics(), L);
261261

262262
return false;
263263
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void recordEventInternal(@Nullable final String key, @Nullable Map<String
8888
L.d("[ModuleEvents] recordEventInternal, key:[" + key + "] eventIdOverride:[" + eventIdOverride + "] segmentation:[" + segmentation + "] count:[" + count + "] sum:[" + sum + "] dur:[" + dur + "] instant:[" + instant + "]");
8989

9090
if (segmentation != null) {
91-
UtilsInternalLimits.removeUnsupportedDataTypes(segmentation);
91+
UtilsInternalLimits.removeUnsupportedDataTypes(segmentation, L);
9292
}
9393

9494
//record the current event timestamps
@@ -163,7 +163,7 @@ public void recordEventInternal(@Nullable final String key, @Nullable Map<String
163163
case ACTION_EVENT_KEY:
164164
if (consentProvider.getConsent(Countly.CountlyFeatureNames.clicks) || consentProvider.getConsent(Countly.CountlyFeatureNames.scrolls)) {
165165
if (segmentation != null) {
166-
UtilsInternalLimits.removeUnsupportedDataTypes(segmentation);
166+
UtilsInternalLimits.removeUnsupportedDataTypes(segmentation, L);
167167
}
168168
eventQueueProvider.recordEventToEventQueue(key, segmentation, count, sum, dur, timestamp, hour, dow, eventId, pvid, cvid, null);
169169
_cly.moduleRequestQueue.sendEventsIfNeeded(false);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ void reportFeedbackWidgetManuallyInternal(@Nullable CountlyFeedbackWidget widget
447447

448448
if (widgetResult != null) {
449449
//removing broken values first
450-
UtilsInternalLimits.removeUnsupportedDataTypes(widgetResult);
450+
UtilsInternalLimits.removeUnsupportedDataTypes(widgetResult, L);
451451

452452
Iterator<Map.Entry<String, Object>> iter = widgetResult.entrySet().iterator();
453453
while (iter.hasNext()) {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ static void removeReservedKeysFromSegmentation(@NonNull Map<String, Object> segm
292292
* @param data
293293
* @return returns true if any entry had been removed
294294
*/
295-
static boolean removeUnsupportedDataTypes(@NonNull Map<String, Object> data) {
295+
static boolean removeUnsupportedDataTypes(@NonNull Map<String, Object> data, @NonNull ModuleLog L) {
296296
assert data != null;
297297

298-
boolean removed = false;
298+
StringBuilder removedKeys = new StringBuilder();
299299

300300
for (Iterator<Map.Entry<String, Object>> it = data.entrySet().iterator(); it.hasNext(); ) {
301301
Map.Entry<String, Object> entry = it.next();
@@ -305,15 +305,16 @@ static boolean removeUnsupportedDataTypes(@NonNull Map<String, Object> data) {
305305
if (key == null || key.isEmpty() || !(isSupportedDataType(value))) {
306306
//found unsupported data type or null key or value, removing
307307
it.remove();
308-
removed = true;
308+
removedKeys.append("key:[").append(key).append("] value:[").append(value).append("] ").append("type: [").append(value == null ? "null" : value.getClass().getSimpleName()).append("] ,");
309309
}
310310
}
311+
String removedKeysStr = removedKeys.toString();
311312

312-
if (removed) {
313-
Countly.sharedInstance().L.w("[Utils] Unsupported data types were removed from provided segmentation");
313+
if (!removedKeysStr.isEmpty()) {
314+
L.w("[UtilsInternalLimits] removeUnsupportedDataTypes, removed " + removedKeysStr + " from the provided data map.");
314315
}
315316

316-
return removed;
317+
return !removedKeysStr.isEmpty();
317318
}
318319

319320
/**

0 commit comments

Comments
 (0)