Skip to content

Commit

Permalink
switch to rollbar on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz committed Nov 24, 2024
1 parent 84f9842 commit 8387a8e
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 98 deletions.
7 changes: 0 additions & 7 deletions app/api/report-error/route.ts

This file was deleted.

14 changes: 2 additions & 12 deletions framer/Donation_Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,18 +496,8 @@ export const withFundraiser = (Component: any): ComponentType => {
});
};

request().catch(async (err: Error) => {
console.error(err?.toString());

try {
await notifyAboutClientSideError(
store.env,
"donation withFundraiser",
err?.toString(),
);
} catch (e) {
console.error(e);
}
request().catch((err: Error) => {
notifyAboutClientSideError("donation withFundraiser", err?.toString());
});
}, []);

Expand Down
14 changes: 2 additions & 12 deletions framer/Fundraiser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,9 @@ export const loadData = (Component: any): ComponentType => {
});
};

request().catch(async (err: Error) => {
console.error(err?.toString());
request().catch((err: Error) => {
setStore({ data: null, hasError: true, isLoading: false });

try {
await notifyAboutClientSideError(
"prod",
"fundraiser loadData",
err?.toString(),
);
} catch (e) {
console.error(e);
}
notifyAboutClientSideError("fundraiser loadData", err?.toString());
});
}, []);

Expand Down
17 changes: 5 additions & 12 deletions framer/Fundraiser_Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,12 @@ export const loadData = (Component: any): ComponentType => {
});
};

request().catch(async (err: Error) => {
console.error(err?.toString());
request().catch((err: Error) => {
setStore({ data: null, hasError: true, isLoading: false });

try {
await notifyAboutClientSideError(
"prod",
"fundraiser-admin loadData",
err?.toString(),
);
} catch (e) {
console.error(e);
}
notifyAboutClientSideError(
"fundraiser-admin loadData",
err?.toString(),
);
});
}, []);

Expand Down
14 changes: 2 additions & 12 deletions framer/Renew_Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,9 @@ export const loadUrl = (Component: any): ComponentType => {
setStore({ url: body.url, hasError: false });
};

request().catch(async (err: Error) => {
console.error(err?.toString());
request().catch((err: Error) => {
setStore({ url: null, hasError: true });

try {
await notifyAboutClientSideError(
"prod",
"renew-payment loadUrl",
err?.toString(),
);
} catch (e) {
console.error(e);
}
notifyAboutClientSideError("renew-payment loadUrl", err?.toString());
});
}, []);

Expand Down
10 changes: 2 additions & 8 deletions framer/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ export const loadKpi = (Component: any): ComponentType => {
});
};

request().catch(async (err: Error) => {
console.error(err?.toString());

try {
await notifyAboutClientSideError("prod", "loadKpi", err?.toString());
} catch (e) {
console.error(e);
}
request().catch((err: Error) => {
notifyAboutClientSideError("loadKpi", err?.toString());
});
}, []);

Expand Down
12 changes: 1 addition & 11 deletions framer/helpers-donation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,7 @@ const submitDonation = async (store: any, setStore: any) => {
}
} catch (err) {
alert(errorMessage);
console.error(err?.toString());

try {
await notifyAboutClientSideError(
store.env,
"submitDonation",
err?.toString(),
);
} catch (e) {
console.error(e);
}
notifyAboutClientSideError("submitDonation", err?.toString());
}

setStore({ isLoading: false });
Expand Down
12 changes: 1 addition & 11 deletions framer/helpers-membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,7 @@ const submitMembership = async (store: any, setStore: any) => {
}
} catch (err) {
alert(errorMessage);
console.error(err?.toString());

try {
await notifyAboutClientSideError(
store.env,
"submitMembership",
err?.toString(),
);
} catch (e) {
console.error(e);
}
notifyAboutClientSideError("submitMembership", err?.toString());
}

setStore({ isLoading: false });
Expand Down
19 changes: 6 additions & 13 deletions framer/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,16 @@ const submitForm = async (
return await response.json();
};

const notifyAboutClientSideError = async (
env: string,
action: string,
error?: string,
) => {
const notifyAboutClientSideError = (action: string, error?: string) => {
console.error(`Client-side error in ${action}: ${error}`);
if (error?.includes("NetworkError")) {
return;
}

const response = await fetch(apiUrl(env, "report-error"), {
method: "POST",
headers: { "Content-type": "application/json;charset=UTF-8" },
body: JSON.stringify({ action, error }),
});

if (!response.ok) {
throw new Error("Unable to submit report about the critical error");
// @ts-ignore
if (typeof Rollbar !== "undefined") {
// @ts-ignore
Rollbar.error(`Client-side error in ${action}: ${error}`);
}
};

Expand Down

0 comments on commit 8387a8e

Please sign in to comment.