@posiwise/common-services 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2986,6 +2986,16 @@ class SentryErrorHandler {
|
|
|
2986
2986
|
// We want to ignore those kinds of errors
|
|
2987
2987
|
return null;
|
|
2988
2988
|
}
|
|
2989
|
+
// Filter out Edge browser (145.0.0+) synthetic isTrusted events
|
|
2990
|
+
// These events spam Sentry as "unlabeled events"
|
|
2991
|
+
const isEdge = /Edg\//.test(navigator.userAgent);
|
|
2992
|
+
if (isEdge && hint?.originalException) {
|
|
2993
|
+
const originalException = hint.originalException;
|
|
2994
|
+
if (originalException && typeof originalException === 'object' && originalException['isTrusted'] === true) {
|
|
2995
|
+
// Block Edge synthetic browser events from being sent to Sentry
|
|
2996
|
+
return null;
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2989
2999
|
// If we started with exception values but filtered them all out, drop the event.
|
|
2990
3000
|
// Otherwise Sentry will group it as an "unlabeled event" and spam the issue stream.
|
|
2991
3001
|
if (typeof initialExceptionValuesLength === 'number' &&
|
|
@@ -3143,6 +3153,13 @@ class SentryErrorHandler {
|
|
|
3143
3153
|
scope.setUser({
|
|
3144
3154
|
...user
|
|
3145
3155
|
});
|
|
3156
|
+
// Filter out Edge browser synthetic events before logging
|
|
3157
|
+
if (this.isEdgeSyntheticEvent(error)) {
|
|
3158
|
+
console.warn('Filtered Edge synthetic event:', error);
|
|
3159
|
+
return;
|
|
3160
|
+
}
|
|
3161
|
+
// Tag the event so it can be properly grouped in Sentry
|
|
3162
|
+
scope.setTag('error_type', this.classifyError(error));
|
|
3146
3163
|
// Ensure error is properly formatted
|
|
3147
3164
|
if (error instanceof Error && error.message) {
|
|
3148
3165
|
captureException(error);
|
|
@@ -3155,6 +3172,48 @@ class SentryErrorHandler {
|
|
|
3155
3172
|
}
|
|
3156
3173
|
});
|
|
3157
3174
|
}
|
|
3175
|
+
/**
|
|
3176
|
+
* Classifies the error type for proper Sentry tagging
|
|
3177
|
+
* This prevents "unlabeled events" by ensuring all events have a classification
|
|
3178
|
+
*/
|
|
3179
|
+
classifyError(error) {
|
|
3180
|
+
if (error instanceof HttpErrorResponse) {
|
|
3181
|
+
return `http_${error.status}`;
|
|
3182
|
+
}
|
|
3183
|
+
if (error instanceof Error) {
|
|
3184
|
+
const name = error.name || 'Error';
|
|
3185
|
+
return name.toLowerCase().replace(/error$/, '') || 'unknown';
|
|
3186
|
+
}
|
|
3187
|
+
if (typeof error === 'string') {
|
|
3188
|
+
return 'string_error';
|
|
3189
|
+
}
|
|
3190
|
+
if (error && typeof error === 'object') {
|
|
3191
|
+
if ('isTrusted' in error) {
|
|
3192
|
+
return 'browser_event';
|
|
3193
|
+
}
|
|
3194
|
+
if ('type' in error) {
|
|
3195
|
+
return `event_${error.type}`.toLowerCase();
|
|
3196
|
+
}
|
|
3197
|
+
return 'object_error';
|
|
3198
|
+
}
|
|
3199
|
+
return 'unknown';
|
|
3200
|
+
}
|
|
3201
|
+
isEdgeSyntheticEvent(error) {
|
|
3202
|
+
// Check if running in Edge browser
|
|
3203
|
+
const isEdge = /Edg\//.test(navigator.userAgent);
|
|
3204
|
+
if (!isEdge) {
|
|
3205
|
+
return false;
|
|
3206
|
+
}
|
|
3207
|
+
// Filter out Edge synthetic DOM events
|
|
3208
|
+
if (error && typeof error === 'object') {
|
|
3209
|
+
const errorObj = error;
|
|
3210
|
+
if ('isTrusted' in errorObj && errorObj['isTrusted'] === true) {
|
|
3211
|
+
// isTrusted browser events in Edge should not be logged
|
|
3212
|
+
return true;
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
return false;
|
|
3216
|
+
}
|
|
3158
3217
|
handleNonStandardError(error) {
|
|
3159
3218
|
if ('isTrusted' in error) {
|
|
3160
3219
|
return;
|