Skip to content

Commit

Permalink
fix: catch failed origin analytics call (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes authored Oct 29, 2024
1 parent c0e3d00 commit cde6bbc
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/crisp/crisp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,28 @@ export class CrispService {
let totalChatOrigin = 0;

for (const userEmail of userEmails) {
const conversations = await CrispClient.website.listPeopleConversations(
crispWebsiteId,
userEmail,
);

for (const conversation of conversations) {
const messages = await CrispClient.website.getMessagesInConversation(
try {
const conversations = await CrispClient.website.listPeopleConversations(
crispWebsiteId,
conversation,
userEmail,
);

for (const message of messages) {
if (message.from === 'user') {
if (message.origin === 'chat') totalChatOrigin++;
if (message.origin === 'email') totalEmailOrigin++;
for (const conversation of conversations) {
const messages = await CrispClient.website.getMessagesInConversation(
crispWebsiteId,
conversation,
);

for (const message of messages) {
if (message.from === 'user') {
if (message.origin === 'chat') totalChatOrigin++;
if (message.origin === 'email') totalEmailOrigin++;
}
}
}
} catch (error) {
// skip
console.log(error);
}
}
const totalMessages = totalEmailOrigin + totalChatOrigin;
Expand Down

0 comments on commit cde6bbc

Please sign in to comment.