1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-27 19:20:12 +02:00

chore: event on limit exceed (#9069)

This commit is contained in:
Arik Chakma
2025-08-26 01:52:47 +06:00
committed by GitHub
parent 82edfba6e9
commit 3e21d05767
2 changed files with 16 additions and 0 deletions

View File

@@ -395,6 +395,14 @@ export async function fetchWithAuthHandling(
if (!response.ok) {
const data = await response.json();
if (data?.errors) {
if (data?.type && data?.type === 'ai_tutor_limit_exceeded') {
window?.fireEvent?.({
action: 'tutor_credit_limit',
category: 'ai_tutor',
label: 'Tutor Credit Limit Exceeded',
});
}
throw new FetchError(response.status, data.message);
} else {
throw new Error('An unexpected error occurred');

View File

@@ -86,6 +86,14 @@ export async function httpCall<ResponseType = AppResponse>(
if (!response.ok) {
if (data.errors) {
if (data?.type && data?.type === 'ai_tutor_limit_exceeded') {
window?.fireEvent?.({
action: 'tutor_credit_limit',
category: 'ai_tutor',
label: 'Tutor Credit Limit Exceeded',
});
}
throw new FetchError(response?.status, data.message);
} else if (data.message) {
throw new FetchError(response?.status, data.message);