Skip to content

Commit

Permalink
fix: change user attribute to JSONObject (#50)
Browse files Browse the repository at this point in the history
Co-authored-by: xiaoweii <xiaoweii@amazom.com>
  • Loading branch information
zhu-xiaowei and xiaoweii authored Dec 13, 2023
1 parent b903816 commit d4c1890
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ private JSONObject getSimpleUserAttribute() {
JSONObject userAttribute = new JSONObject();
try {
userAttribute.put(Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP,
allUserAttributes.getString(Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP));
allUserAttributes.getJSONObject(Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP));
if (allUserAttributes.has(Event.ReservedAttribute.USER_ID)) {
userAttribute.put(Event.ReservedAttribute.USER_ID,
allUserAttributes.getString(Event.ReservedAttribute.USER_ID));
allUserAttributes.getJSONObject(Event.ReservedAttribute.USER_ID));
}
} catch (final JSONException jsonException) {
LOG.error("Could not create Json object of simpleUserAttribute. error: " + jsonException.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ public void testCreateEventWithoutCustomUserAttributes() throws JSONException {
Assert.assertTrue(user.has(Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP));
Assert.assertFalse(user.has("userName"));
Assert.assertFalse(user.has("userAge"));
JSONObject userIdObject = user.getJSONObject(Event.ReservedAttribute.USER_ID);
Assert.assertEquals("123", userIdObject.getString("value"));
}

/**
Expand Down

0 comments on commit d4c1890

Please sign in to comment.