chore: Handle non-error rejections in sentry (#27519)
This commit is contained in:
parent
6f7dd7254b
commit
3d851f214d
|
|
@ -21,21 +21,25 @@ export const initializeAnalyticsAndTrackers = () => {
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
...appsmithConfigs.sentry,
|
...appsmithConfigs.sentry,
|
||||||
beforeSend(event) {
|
beforeSend(event) {
|
||||||
if (
|
const exception = extractSentryException(event);
|
||||||
event.exception &&
|
if (exception?.type === "ChunkLoadError") {
|
||||||
Array.isArray(event.exception.values) &&
|
|
||||||
event.exception.values[0].value &&
|
|
||||||
event.exception.values[0].type === "ChunkLoadError"
|
|
||||||
) {
|
|
||||||
// Only log ChunkLoadErrors after the 2 retires
|
// Only log ChunkLoadErrors after the 2 retires
|
||||||
if (
|
if (!exception.value?.includes("failed after 2 retries")) {
|
||||||
!event.exception.values[0].value.includes(
|
|
||||||
"failed after 2 retries",
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Handle Non-Error rejections
|
||||||
|
if (exception?.value?.startsWith("Non-Error")) {
|
||||||
|
const serializedData: any = event.extra?.__serialized__;
|
||||||
|
if (!serializedData) return null; // if no data is attached, ignore error
|
||||||
|
const actualErrorMessage = serializedData.error
|
||||||
|
? serializedData.error.message
|
||||||
|
: serializedData.message;
|
||||||
|
if (!actualErrorMessage) return null; // If no message is attached, ignore error
|
||||||
|
// Now modify the original error
|
||||||
|
exception.value = actualErrorMessage;
|
||||||
|
event.message = actualErrorMessage;
|
||||||
|
}
|
||||||
return event;
|
return event;
|
||||||
},
|
},
|
||||||
beforeBreadcrumb(breadcrumb) {
|
beforeBreadcrumb(breadcrumb) {
|
||||||
|
|
@ -485,3 +489,9 @@ export function getDatatype(value: unknown) {
|
||||||
return DataType.UNDEFINED;
|
return DataType.UNDEFINED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractSentryException(event: Sentry.Event) {
|
||||||
|
if (!event.exception) return null;
|
||||||
|
const value = event.exception.values ? event.exception.values[0] : null;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user