Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging for user service #289

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ lerna-debug.log*
!.vscode/launch.json
!.vscode/extensions.json

.env
.env*
!.env.example

*.dump
7 changes: 7 additions & 0 deletions src/api/crisp/crisp-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AxiosResponse } from 'axios';
import { ICoursesWithSessions } from 'src/course/course.interface';
import { IPartnerAccessWithPartner } from 'src/partner-access/partner-access.interface';
import { Logger } from '../../logger/logger';
import { IUser } from '../../user/user.interface';
import { crispToken, crispWebsiteId, PROGRESS_STATUS } from '../../utils/constants';
import apiCall from '../apiCalls';
Expand All @@ -26,6 +27,8 @@ const headers = {
'-ContentType': 'application/json',
};

const logger = new Logger('UserService');

export const updateCrispProfileAccesses = async (
user: IUser,
partnerAccesses: IPartnerAccessWithPartner[],
Expand Down Expand Up @@ -142,6 +145,8 @@ export const addCrispProfile = async (
headers,
});
} catch (error) {
logger.error(`Could not add crisp profile for user: ${newPeopleProfile.email}`);

throw error;
}
};
Expand All @@ -158,6 +163,8 @@ export const updateCrispProfileData = async (
headers,
});
} catch (error) {
logger.error(`Could not update crisp profile for user: ${email}`);

throw error;
}
};
Expand Down
7 changes: 7 additions & 0 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,15 @@ export class UserService {
createUserDto,
firebaseUser.uid,
);
this.logger.log(`Create user: (no access code) created partner user in db. User: ${email}`);
} else if (signUpType === SIGNUP_TYPE.PARTNER_USER_WITH_CODE) {
formattedUserObject = await this.createPartnerUserWithCode(createUserDto, firebaseUser.uid);
this.logger.log(
`Create user: (with access code) created partner user in db. User: ${email}`,
);
} else {
formattedUserObject = await this.createPublicUser(createUserDto, firebaseUser.uid);
this.logger.log(`Create user: created public user in db. User: ${email}`);
}

const partnerSegment =
Expand All @@ -122,6 +127,7 @@ export class UserService {
person: { nickname: formattedUserObject.user.name },
segments: [partnerSegment],
});
this.logger.log(`Create user: added crisp profile: ${email}`);

await updateCrispProfileData(
createCrispProfileData(
Expand All @@ -130,6 +136,7 @@ export class UserService {
),
formattedUserObject.user.email,
);
this.logger.log(`Create user: updated crisp profile ${email}`);

return formattedUserObject;
} catch (error) {
Expand Down
Loading