Skip to content

Commit

Permalink
feat: add session attributes in _first_open event (#37)
Browse files Browse the repository at this point in the history
Co-authored-by: xiaoweii <[email protected]>
  • Loading branch information
zhu-xiaowei and xiaoweii authored Dec 7, 2023
1 parent ac1b268 commit 3ec2af3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tracker/SessionTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class SessionTracker extends BaseTracker {
}

handleInit() {
this.session = Session.getCurrentSession(this.context);
if (StorageUtil.getIsFirstOpen()) {
this.provider.record({
name: Event.PresetEvent.FIRST_OPEN,
Expand Down
4 changes: 4 additions & 0 deletions test/ClickstreamAnalytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ describe('ClickstreamAnalytics test', () => {
expect(firstEvent.user[Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP]).not.toBeUndefined()
expect(firstEvent.attributes.brand).toBe('Samsung');
expect(firstEvent.attributes.level).toBe(10);
expect(firstEvent.attributes[Event.ReservedAttribute.SESSION_ID]).not.toBeUndefined();
expect(firstEvent.attributes[Event.ReservedAttribute.SESSION_NUMBER]).not.toBeUndefined();
expect(firstEvent.attributes[Event.ReservedAttribute.SESSION_START_TIMESTAMP]).not.toBeUndefined();
expect(firstEvent.attributes[Event.ReservedAttribute.SESSION_DURATION]).not.toBeUndefined();
const testEvent = eventList[eventList.length - 1];
expect(testEvent.attributes.brand).toBeUndefined();
});
Expand Down

0 comments on commit 3ec2af3

Please sign in to comment.