Skip to content

Commit 7652090

Browse files
authored
fix: Usage tracking is not handling exceptions for unauthenticated requests (#359)
1 parent 828b683 commit 7652090

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lang/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"invalidEvent": "Usage tracking event {{ eventName }} is not a valid event type.",
55
"sendingEventAuthenticated": "Sending usage event to authenticated endpoint",
66
"retryingEventUnauthenticated": "Failed to send the usage event as authenticated. Trying again as unauthenticated.",
7-
"sendingEventUnauthenticated": "Sending usage event to unauthenticated endpoint"
7+
"sendingEventUnauthenticated": "Sending usage event to unauthenticated endpoint",
8+
"unauthenticatedSendFailed": "Failed to send usage event to unauthenticated endpoint"
89
},
910
"archive": {
1011
"extractZip": {

lib/trackUsage.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,10 @@ export async function trackUsage(
6767
resolveWithFullResponse: true,
6868
});
6969
logger.debug(i18n(`${i18nKey}.sendingEventUnauthenticated`));
70-
return httpClient({ ...axiosConfig, method: 'post' });
70+
71+
try {
72+
await httpClient({ ...axiosConfig, method: 'post' });
73+
} catch (e) {
74+
logger.debug(i18n(`${i18nKey}.unauthenticatedSendFailed`));
75+
}
7176
}

0 commit comments

Comments
 (0)