From 1018196f4928932acbe061fc3370c7da1721481d Mon Sep 17 00:00:00 2001 From: CTLalit Date: Wed, 13 Nov 2024 19:36:21 +0530 Subject: [PATCH 1/4] feat(SDK-4133): dedupe check - change mentioned in the TAN --- .../main/java/com/clevertap/android/sdk/AnalyticsManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java index db44f04c4..8262071b8 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java @@ -1168,7 +1168,7 @@ private boolean checkDuplicateNotificationIds(Bundle extras, HashMap Date: Thu, 14 Nov 2024 16:00:41 +0530 Subject: [PATCH 2/4] feat(SDK-4133): changes map to contain long value - corrects object save and casting --- .../com/clevertap/android/sdk/AnalyticsManager.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java index 8262071b8..8dde6c70b 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java @@ -60,11 +60,11 @@ public class AnalyticsManager extends BaseAnalyticsManager { private final InAppResponse inAppResponse; - private final HashMap notificationIdTagMap = new HashMap<>(); + private final HashMap notificationIdTagMap = new HashMap<>(); private final Object notificationMapLock = new Object(); - private final HashMap notificationViewedIdTagMap = new HashMap<>(); + private final HashMap notificationViewedIdTagMap = new HashMap<>(); AnalyticsManager(Context context, CleverTapInstanceConfig config, @@ -1162,8 +1162,11 @@ private void _pushMultiValue(ArrayList originalValues, String key, Strin } } - private boolean checkDuplicateNotificationIds(Bundle extras, HashMap notificationTagMap, - int interval) { + private boolean checkDuplicateNotificationIds( + Bundle extras, + HashMap notificationTagMap, + int interval + ) { synchronized (notificationMapLock) { // default to false; only return true if we are sure we've seen this one before boolean isDupe = false; @@ -1173,7 +1176,7 @@ private boolean checkDuplicateNotificationIds(Bundle extras, HashMap Date: Thu, 21 Nov 2024 17:57:32 +0530 Subject: [PATCH 3/4] feat(SDK-4171): Adds check for dedupe behind feature flag - adds a wzrk_dd flag so that it can be used in client specific fashion until it is rolled out to general audience. --- .../com/clevertap/android/sdk/AnalyticsManager.java | 12 +++++++++++- .../java/com/clevertap/android/sdk/Constants.java | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java index 8dde6c70b..92d1c7a59 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java @@ -1171,7 +1171,17 @@ private boolean checkDuplicateNotificationIds( // default to false; only return true if we are sure we've seen this one before boolean isDupe = false; try { - String notificationIdTag = extras.getString(Constants.WZRK_PUSH_ID); + + // This flag is used so that we can release in phased manner, eventually the check has to go away. + boolean checkUsingPid = extras.getBoolean(Constants.WZRK_DEDUPE); + + String notificationIdTag; + if (checkUsingPid) { + notificationIdTag = extras.getString(Constants.WZRK_PUSH_ID); + } else { + notificationIdTag = extras.getString(Constants.NOTIFICATION_ID_TAG); + } + long now = System.currentTimeMillis(); if (notificationTagMap.containsKey(notificationIdTag)) { long timestamp; diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/Constants.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/Constants.java index 39478b9ce..5e5797e7c 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/Constants.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/Constants.java @@ -248,6 +248,7 @@ public interface Constants { String KEY_ENCRYPTION_LEVEL = "encryptionLevel"; String KEY_ENCRYPTION_FLAG_STATUS = "encryptionFlagStatus"; String WZRK_PUSH_ID = "wzrk_pid"; + String WZRK_DEDUPE = "wzrk_dd"; String WZRK_PUSH_SILENT = "wzrk_pn_s"; String EXTRAS_FROM = "extras_from"; String NOTIF_MSG = "nm"; From 1a0ebad09b20d365d287ab1929305edcc7995a77 Mon Sep 17 00:00:00 2001 From: CTLalit Date: Thu, 28 Nov 2024 15:17:11 +0530 Subject: [PATCH 4/4] feat(SDK-4133): parses string or boolean after check --- .../clevertap/android/sdk/AnalyticsManager.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java index 92d1c7a59..3c9d96a7b 100644 --- a/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java +++ b/clevertap-core/src/main/java/com/clevertap/android/sdk/AnalyticsManager.java @@ -1173,10 +1173,20 @@ private boolean checkDuplicateNotificationIds( try { // This flag is used so that we can release in phased manner, eventually the check has to go away. - boolean checkUsingPid = extras.getBoolean(Constants.WZRK_DEDUPE); + Object doDedupeCheck = extras.get(Constants.WZRK_DEDUPE); + + boolean check = false; + if (doDedupeCheck != null) { + if (doDedupeCheck instanceof String) { + check = "true".equalsIgnoreCase((String) doDedupeCheck); + } + if (doDedupeCheck instanceof Boolean) { + check = (Boolean) doDedupeCheck; + } + } String notificationIdTag; - if (checkUsingPid) { + if (check) { notificationIdTag = extras.getString(Constants.WZRK_PUSH_ID); } else { notificationIdTag = extras.getString(Constants.NOTIFICATION_ID_TAG);