Skip to content

Commit cde6bbc

Browse files
authored
fix: catch failed origin analytics call (#693)
1 parent c0e3d00 commit cde6bbc

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/crisp/crisp.service.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,28 @@ export class CrispService {
148148
let totalChatOrigin = 0;
149149

150150
for (const userEmail of userEmails) {
151-
const conversations = await CrispClient.website.listPeopleConversations(
152-
crispWebsiteId,
153-
userEmail,
154-
);
155-
156-
for (const conversation of conversations) {
157-
const messages = await CrispClient.website.getMessagesInConversation(
151+
try {
152+
const conversations = await CrispClient.website.listPeopleConversations(
158153
crispWebsiteId,
159-
conversation,
154+
userEmail,
160155
);
161156

162-
for (const message of messages) {
163-
if (message.from === 'user') {
164-
if (message.origin === 'chat') totalChatOrigin++;
165-
if (message.origin === 'email') totalEmailOrigin++;
157+
for (const conversation of conversations) {
158+
const messages = await CrispClient.website.getMessagesInConversation(
159+
crispWebsiteId,
160+
conversation,
161+
);
162+
163+
for (const message of messages) {
164+
if (message.from === 'user') {
165+
if (message.origin === 'chat') totalChatOrigin++;
166+
if (message.origin === 'email') totalEmailOrigin++;
167+
}
166168
}
167169
}
170+
} catch (error) {
171+
// skip
172+
console.log(error);
168173
}
169174
}
170175
const totalMessages = totalEmailOrigin + totalChatOrigin;

0 commit comments

Comments
 (0)