Skip to content

Commit

Permalink
Merge pull request #428 from Countly/fix_contetns
Browse files Browse the repository at this point in the history
fix: support segmentation
  • Loading branch information
turtledreams authored Nov 28, 2024
2 parents 80cc4f1 + 930063d commit 72ac899
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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.

* Mitigated an issue that parsing internal content event segmentation.
## 24.7.5
* ! Minor breaking change ! All active views will now automatically stop when consent for "views" is revoked.

Expand Down
12 changes: 7 additions & 5 deletions sdk/src/main/java/ly/count/android/sdk/TransparentActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,17 @@ private void eventAction(Map<String, Object> query) {
JSONObject eventJson = event.getJSONObject(i);
Log.v(Countly.TAG, "[TransparentActivity] eventAction, event JSON: [" + eventJson.toString() + "]");

if (!eventJson.has("sg")) {
Map<String, Object> segmentation = new ConcurrentHashMap<>();
JSONObject sgJson = eventJson.optJSONObject("sg");
JSONObject segmentationJson = eventJson.optJSONObject("segmentation");

if (sgJson != null) {
segmentationJson = sgJson;
} else if (segmentationJson == null) {
Log.w(Countly.TAG, "[TransparentActivity] eventAction, event JSON is missing segmentation data event: [" + eventJson + "]");
continue;
}

Map<String, Object> segmentation = new ConcurrentHashMap<>();
JSONObject segmentationJson = eventJson.getJSONObject("sg");
assert segmentationJson != null; // this is already checked above

for (int j = 0; j < segmentationJson.names().length(); j++) {
String key = segmentationJson.names().getString(j);
Object value = segmentationJson.get(key);
Expand Down

0 comments on commit 72ac899

Please sign in to comment.