Skip to content

Commit 08f9f5d

Browse files
fix: support segmentation
1 parent ba763f9 commit 08f9f5d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,17 @@ private void eventAction(Map<String, Object> query) {
287287
JSONObject eventJson = event.getJSONObject(i);
288288
Log.v(Countly.TAG, "[TransparentActivity] eventAction, event JSON: [" + eventJson.toString() + "]");
289289

290-
if (!eventJson.has("sg")) {
290+
Map<String, Object> segmentation = new ConcurrentHashMap<>();
291+
JSONObject sgJson = eventJson.optJSONObject("sg");
292+
JSONObject segmentationJson = eventJson.optJSONObject("segmentation");
293+
294+
if (sgJson != null) {
295+
segmentationJson = sgJson;
296+
} else if (segmentationJson == null) {
291297
Log.w(Countly.TAG, "[TransparentActivity] eventAction, event JSON is missing segmentation data event: [" + eventJson + "]");
292298
continue;
293299
}
294300

295-
Map<String, Object> segmentation = new ConcurrentHashMap<>();
296-
JSONObject segmentationJson = eventJson.getJSONObject("sg");
297-
assert segmentationJson != null; // this is already checked above
298-
299301
for (int j = 0; j < segmentationJson.names().length(); j++) {
300302
String key = segmentationJson.names().getString(j);
301303
Object value = segmentationJson.get(key);

0 commit comments

Comments
 (0)