Skip to content

Commit

Permalink
feat: add session attributes in _first_open event (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu-xiaowei authored Dec 7, 2023
1 parent f74a4c9 commit 7c7e3e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public SessionClient(@NonNull final ClickstreamContext clickstreamContext) {
throw new IllegalArgumentException("A valid AnalyticsClient must be provided!");
}
this.clickstreamContext = clickstreamContext;
session = Session.getInstance(clickstreamContext);
this.clickstreamContext.getAnalyticsClient().setSession(session);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,11 @@ public void testHandleFirstOpen() throws Exception {
JSONObject jsonObject = new JSONObject(eventString);
String eventType = jsonObject.getString("event_type");
assertEquals(Event.PresetEvent.FIRST_OPEN, eventType);
JSONObject attributes = jsonObject.getJSONObject("attributes");
assertNotNull(attributes.getString("_session_id"));
assertNotNull(attributes.getString("_session_start_timestamp"));
assertNotNull(attributes.getString("_session_duration"));
assertNotNull(attributes.getString("_session_number"));
cursor.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void testGetBatchOfEventsForOneEvent() throws Exception {
Cursor cursor = dbUtil.queryAllEvents();
String[] result = getBatchOfEvents(cursor);
assertEquals(result.length, 2);
assertEquals("[" + event.toJSONObject().toString() + "]", result[0]);
assertTrue(result[0].contains(event.getEventId()));
assertEquals("1", result[1]);
cursor.close();
}
Expand Down

0 comments on commit 7c7e3e6

Please sign in to comment.