Skip to content

Commit

Permalink
make data optional as it's already skipped in some events
Browse files Browse the repository at this point in the history
  • Loading branch information
jivey committed Oct 21, 2021
1 parent 0e13f6f commit 33463c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion tutor/specs/models/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('User Model', () => {
expect(User.metrics.course_subjects).toEqual('testing');
expect(User.metrics.course_types).toEqual('real');
})

it('calculates audience tags', () => {
bootstrapCoursesList();
expect(User.tourAudienceTags).toEqual(['teacher', 'teacher-not-previewed']);
Expand Down Expand Up @@ -105,6 +105,11 @@ describe('User Model', () => {
expect(JSON.parse(body)).toMatchObject({
some: 'data',
})

// Some events do not contain data
fetchMock.mockResponseOnce(JSON.stringify({ ok: true }))
User.logEvent({ category: 'nodata', code: 'nodata' })
expect(fetchMock.mock.calls[1][1]?.body).toBeUndefined()
}))

it('checks for names then splits', action(() => {
Expand Down
2 changes: 1 addition & 1 deletion tutor/src/components/my-courses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MyCourses extends React.Component<MyCoursesProps> {
if (history && history.action === 'POP') {
await currentCourses.fetch();
}
currentUser.logEvent({ category: 'onboarding', code: 'arrived_my_courses', data: '' });
currentUser.logEvent({ category: 'onboarding', code: 'arrived_my_courses' });
}

@computed get firstCourse() {
Expand Down
2 changes: 1 addition & 1 deletion tutor/src/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import urlFor from '../api'
export interface UserEventPayload {
category: string
code: string
data: any
data?: any
}


Expand Down

0 comments on commit 33463c0

Please sign in to comment.