From 59eb17719a4d5e9d01c4b10ff0188107d6780a69 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray <burakdemiray09@hotmail.com> Date: Mon, 11 Nov 2024 14:06:31 +0300 Subject: [PATCH 1/6] feat: remove visibility from the end view --- CHANGELOG.md | 3 +++ .../ly/count/android/sdk/ModuleEvents.java | 20 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 561960946..cff63f204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## XX.XX.XX +* Visibility tracking for end view requests has been removed to improve functionality. + ## 24.7.5 * ! Minor breaking change ! All active views will now automatically stop when consent for "views" is revoked. diff --git a/sdk/src/main/java/ly/count/android/sdk/ModuleEvents.java b/sdk/src/main/java/ly/count/android/sdk/ModuleEvents.java index 4e0857817..0261b1761 100644 --- a/sdk/src/main/java/ly/count/android/sdk/ModuleEvents.java +++ b/sdk/src/main/java/ly/count/android/sdk/ModuleEvents.java @@ -156,18 +156,22 @@ public void recordEventInternal(@Nullable final String key, @Nullable Map<String _cly.moduleUserProfile.saveInternal(); if (visibilityTracking) { - String appInBackground = deviceInfo.isInBackground(); - int state = 1; // in foreground - if ("true".equals(appInBackground)) { - state = 0; // in background - } - L.d("[ModuleEvents] recordEventInternal, Adding visibility tracking to segmentation app in background:[" + appInBackground + "] cly_v:[" + state + "]"); - if (segmentation == null) { segmentation = new HashMap<>(); } - segmentation.put(VISIBILITY_KEY, state); + if (ModuleViews.VIEW_EVENT_KEY.equals(key) && !segmentation.containsKey("visit")) { + L.d("[ModuleEvents] recordEventInternal, visibility key will not be added to the end view event"); + } else { + String appInBackground = deviceInfo.isInBackground(); + int state = 1; // in foreground + if ("true".equals(appInBackground)) { + state = 0; // in background + } + L.d("[ModuleEvents] recordEventInternal, Adding visibility tracking to segmentation app in background:[" + appInBackground + "] cly_v:[" + state + "]"); + + segmentation.put(VISIBILITY_KEY, state); + } } switch (key) { From fdcec88505ea30a7800a47e61c5273988464d009 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray <burakdemiray09@hotmail.com> Date: Mon, 11 Nov 2024 14:08:36 +0300 Subject: [PATCH 2/6] fix: tests --- .../java/ly/count/android/sdk/ModuleEventsTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java b/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java index e2ef6602a..5dc755d56 100644 --- a/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java +++ b/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java @@ -834,7 +834,7 @@ public void recordEvent_visibilityTracking_bgFgSwitch() throws JSONException { countly.onStart(Mockito.mock(Activity.class)); //foreground - countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map()); + countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 1), 1, 0.0d, 0.0d, 2); countly.events().recordEvent("fg", TestUtils.map()); @@ -842,7 +842,7 @@ public void recordEvent_visibilityTracking_bgFgSwitch() throws JSONException { countly.onStop(); //background - countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map()); + countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 0), 1, 0.0d, 0.0d, 5); countly.events().recordEvent("bg", TestUtils.map()); @@ -864,7 +864,7 @@ public void recordEvent_visibilityTracking_notEnabled() throws JSONException { countly.onStart(Mockito.mock(Activity.class)); //foreground - countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map()); + countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map(), 1, 0.0d, 0.0d, 2); countly.events().recordEvent("fg", TestUtils.map()); @@ -872,7 +872,7 @@ public void recordEvent_visibilityTracking_notEnabled() throws JSONException { countly.onStop(); //background - countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map()); + countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map(), 1, 0.0d, 0.0d, 5); countly.events().recordEvent("bg", TestUtils.map()); From f25c264e84ac913c1600ce8ce68e7e3c5fa3e615 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray <burakdemiray09@hotmail.com> Date: Mon, 11 Nov 2024 14:09:46 +0300 Subject: [PATCH 3/6] fix: tests --- .../java/ly/count/android/sdk/ModuleEventsTests.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java b/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java index 5dc755d56..0cd842301 100644 --- a/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java +++ b/sdk/src/androidTest/java/ly/count/android/sdk/ModuleEventsTests.java @@ -807,8 +807,8 @@ public void recordEvent_visibilityTracking_onlyAddingItToViewsAndEvents() throws countly.events().recordEvent(ModuleFeedback.RATING_EVENT_KEY, TestUtils.map()); validateEventInRQ(ModuleFeedback.RATING_EVENT_KEY, TestUtils.map(), 1, 0.0d, 0.0d, 4); - countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map()); - validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 0), 1, 0.0d, 0.0d, 5); + countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); + validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 0, "visit", 1), 1, 0.0d, 0.0d, 5); countly.events().recordEvent(ModuleViews.ORIENTATION_EVENT_KEY, TestUtils.map()); validateEventInRQ(ModuleViews.ORIENTATION_EVENT_KEY, TestUtils.map(), 1, 0.0d, 0.0d, 6); @@ -835,7 +835,7 @@ public void recordEvent_visibilityTracking_bgFgSwitch() throws JSONException { countly.onStart(Mockito.mock(Activity.class)); //foreground countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); - validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 1), 1, 0.0d, 0.0d, 2); + validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 1, "visit", 1), 1, 0.0d, 0.0d, 2); countly.events().recordEvent("fg", TestUtils.map()); validateEventInRQ("fg", TestUtils.map("cly_v", 1), 1, 0.0d, 0.0d, 3); @@ -843,7 +843,7 @@ public void recordEvent_visibilityTracking_bgFgSwitch() throws JSONException { countly.onStop(); //background countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); - validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 0), 1, 0.0d, 0.0d, 5); + validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("cly_v", 0, "visit", 1), 1, 0.0d, 0.0d, 5); countly.events().recordEvent("bg", TestUtils.map()); validateEventInRQ("bg", TestUtils.map("cly_v", 0), 1, 0.0d, 0.0d, 6); @@ -865,7 +865,7 @@ public void recordEvent_visibilityTracking_notEnabled() throws JSONException { countly.onStart(Mockito.mock(Activity.class)); //foreground countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); - validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map(), 1, 0.0d, 0.0d, 2); + validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1), 1, 0.0d, 0.0d, 2); countly.events().recordEvent("fg", TestUtils.map()); validateEventInRQ("fg", TestUtils.map(), 1, 0.0d, 0.0d, 3); @@ -873,7 +873,7 @@ public void recordEvent_visibilityTracking_notEnabled() throws JSONException { countly.onStop(); //background countly.events().recordEvent(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1)); - validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map(), 1, 0.0d, 0.0d, 5); + validateEventInRQ(ModuleViews.VIEW_EVENT_KEY, TestUtils.map("visit", 1), 1, 0.0d, 0.0d, 5); countly.events().recordEvent("bg", TestUtils.map()); validateEventInRQ("bg", TestUtils.map(), 1, 0.0d, 0.0d, 6); From b30f415a713620da1efc74e682e8f757a70da9c0 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray <burakdemiray09@hotmail.com> Date: Mon, 11 Nov 2024 14:12:25 +0300 Subject: [PATCH 4/6] fix: mitigate --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cff63f204..e667560e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## XX.XX.XX -* Visibility tracking for end view requests has been removed to improve functionality. +* Mitigated an issue where visibility tracking for end view requests has been removed to improve functionality. ## 24.7.5 * ! Minor breaking change ! All active views will now automatically stop when consent for "views" is revoked. From ff1c2fb3f0ad18afe2d4897c33e102809cf06918 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray <57103426+arifBurakDemiray@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:33:53 +0300 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e667560e7..15d3114cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## XX.XX.XX -* Mitigated an issue where visibility tracking for end view requests has been removed to improve functionality. +* Mitigated an issue where sending visibility information with the end views too were creating improper results. (Experimental!) ## 24.7.5 * ! Minor breaking change ! All active views will now automatically stop when consent for "views" is revoked. From 020ebaeee9b6fb6f2c65968c171095d53dec9b7a Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:13:43 +0900 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d3114cd..7eaa44fff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## XX.XX.XX -* Mitigated an issue where sending visibility information with the end views too were creating improper results. (Experimental!) +* Mitigated an issue where visibility could have been wrongly assigned if a view was closed while going to background. (Experimental!) ## 24.7.5 * ! Minor breaking change ! All active views will now automatically stop when consent for "views" is revoked.