@posiwise/common-services 0.2.13 → 0.2.14
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.
|
@@ -1195,7 +1195,13 @@ class AuthService {
|
|
|
1195
1195
|
return this.userService.getUserInfo();
|
|
1196
1196
|
}));
|
|
1197
1197
|
sequence$.subscribe(resp => {
|
|
1198
|
-
localStorage
|
|
1198
|
+
// Store user information in localStorage for chat widgets and other services
|
|
1199
|
+
const firstName = resp.first_name || '';
|
|
1200
|
+
const email = resp.email || '';
|
|
1201
|
+
const userId = resp.id?.toString() || '';
|
|
1202
|
+
localStorage.setItem('name', firstName);
|
|
1203
|
+
localStorage.setItem('userEmail', email);
|
|
1204
|
+
localStorage.setItem('userId', userId);
|
|
1199
1205
|
this.router.navigate(['home']);
|
|
1200
1206
|
if ($('.cc-dismiss').length > 0) {
|
|
1201
1207
|
$('.cc-dismiss')[0].click();
|
|
@@ -2920,97 +2926,7 @@ class SentryErrorHandler {
|
|
|
2920
2926
|
// NOTE: We intentionally do not enable Performance Tracing here.
|
|
2921
2927
|
// The previous integration (`BrowserTracing` + `routingInstrumentation`) was part of
|
|
2922
2928
|
// the legacy `@sentry/angular-ivy` API and isn't available in `@sentry/angular` v10.
|
|
2923
|
-
beforeSend(event, hint)
|
|
2924
|
-
const initialExceptionValuesLength = Array.isArray(event?.exception?.values)
|
|
2925
|
-
? event.exception.values.length
|
|
2926
|
-
: undefined;
|
|
2927
|
-
const safeIncludes = (val, needle) => typeof val === 'string' && val.includes(needle);
|
|
2928
|
-
// Check if the event is of type CloseEvent and ignore it
|
|
2929
|
-
if (event?.exception?.values) {
|
|
2930
|
-
event.exception.values = event.exception.values.filter(value => {
|
|
2931
|
-
// Update the condition based on the actual structure of the event
|
|
2932
|
-
return !(value.type === 'CloseEvent' ||
|
|
2933
|
-
safeIncludes(value.value, 'CloseEvent'));
|
|
2934
|
-
});
|
|
2935
|
-
}
|
|
2936
|
-
if (event?.exception?.values) {
|
|
2937
|
-
event.exception.values = event.exception.values.filter(value => {
|
|
2938
|
-
// Check for the specific error message and ignore it
|
|
2939
|
-
return !(value.type === 'Error' &&
|
|
2940
|
-
safeIncludes(value.value, 'ResizeObserver loop completed'));
|
|
2941
|
-
});
|
|
2942
|
-
}
|
|
2943
|
-
// originates from vendor.js file
|
|
2944
|
-
if (event?.exception?.values) {
|
|
2945
|
-
const isJsonParsingError = event.exception.values.some(value => {
|
|
2946
|
-
return (value.type === 'SyntaxError' &&
|
|
2947
|
-
value?.value?.includes("expected ':' after property name in"));
|
|
2948
|
-
});
|
|
2949
|
-
if (isJsonParsingError) {
|
|
2950
|
-
return null;
|
|
2951
|
-
}
|
|
2952
|
-
}
|
|
2953
|
-
// Check if the event is a ChunkLoadError and ignore it (it could be because of poor network)
|
|
2954
|
-
if (event?.exception?.values) {
|
|
2955
|
-
event.exception.values = event.exception.values.filter(value => {
|
|
2956
|
-
return !(value.type === 'ChunkLoadError' ||
|
|
2957
|
-
safeIncludes(value.value, 'ChunkLoadError: Loading chunk'));
|
|
2958
|
-
});
|
|
2959
|
-
}
|
|
2960
|
-
// Check if the event is a script loading error and ignore it
|
|
2961
|
-
if (event?.exception?.values) {
|
|
2962
|
-
event.exception.values = event.exception.values.filter(value => {
|
|
2963
|
-
return !(value.type === 'Error' &&
|
|
2964
|
-
safeIncludes(value.value, 'Could not load "util"'));
|
|
2965
|
-
});
|
|
2966
|
-
}
|
|
2967
|
-
// Check if the event is a timeout error and ignore it
|
|
2968
|
-
if (event?.exception?.values) {
|
|
2969
|
-
event.exception.values = event.exception.values.filter(value => {
|
|
2970
|
-
return !(value.type === 'Error' &&
|
|
2971
|
-
safeIncludes(value.value, 'Error loading plotly.js library from'));
|
|
2972
|
-
});
|
|
2973
|
-
}
|
|
2974
|
-
// Check if the event is related to cross-origin frame access
|
|
2975
|
-
if (event?.exception?.values) {
|
|
2976
|
-
const isCrossOriginFrameError = event.exception.values.some(value => {
|
|
2977
|
-
return (value.type === 'SecurityError' &&
|
|
2978
|
-
value?.value?.includes("Failed to read a named property 'navigator' from 'Window': Blocked a frame with origin"));
|
|
2979
|
-
});
|
|
2980
|
-
if (isCrossOriginFrameError) {
|
|
2981
|
-
// Exclude cross-origin frame errors from being reported to Sentry
|
|
2982
|
-
return null;
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
// Check if it's a non-error exception
|
|
2986
|
-
const isNonErrorException = event?.exception?.values?.[0]?.value?.startsWith('Non-Error exception captured') ??
|
|
2987
|
-
hint?.originalException?.message?.startsWith('Non-Error exception captured');
|
|
2988
|
-
if (isNonErrorException) {
|
|
2989
|
-
// We want to ignore those kinds of errors
|
|
2990
|
-
return null;
|
|
2991
|
-
}
|
|
2992
|
-
// Filter out Edge browser (145.0.0+) synthetic isTrusted events
|
|
2993
|
-
// These events spam Sentry as "unlabeled events"
|
|
2994
|
-
const isEdge = /Edg\//.test(navigator.userAgent);
|
|
2995
|
-
if (isEdge && hint?.originalException) {
|
|
2996
|
-
const originalException = hint.originalException;
|
|
2997
|
-
if (originalException &&
|
|
2998
|
-
typeof originalException === 'object' &&
|
|
2999
|
-
originalException['isTrusted'] === true) {
|
|
3000
|
-
// Block Edge synthetic browser events from being sent to Sentry
|
|
3001
|
-
return null;
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
// If we started with exception values but filtered them all out, drop the event.
|
|
3005
|
-
// Otherwise Sentry will group it as an "unlabeled event" and spam the issue stream.
|
|
3006
|
-
if (typeof initialExceptionValuesLength === 'number' &&
|
|
3007
|
-
initialExceptionValuesLength > 0 &&
|
|
3008
|
-
Array.isArray(event?.exception?.values) &&
|
|
3009
|
-
event.exception.values.length === 0) {
|
|
3010
|
-
return null;
|
|
3011
|
-
}
|
|
3012
|
-
return event;
|
|
3013
|
-
},
|
|
2929
|
+
beforeSend: (event, hint) => SentryErrorHandler.beforeSendFilter(event, hint),
|
|
3014
2930
|
denyUrls: [/drift.*\.js/i, /analytics.*\.js/i, /polyfills.*\.js/i, /vendor.*\.js/i],
|
|
3015
2931
|
environment,
|
|
3016
2932
|
// We ignore Server Errors. We have to define here since Angular
|
|
@@ -3193,15 +3109,41 @@ class SentryErrorHandler {
|
|
|
3193
3109
|
return 'string_error';
|
|
3194
3110
|
}
|
|
3195
3111
|
if (error && typeof error === 'object') {
|
|
3112
|
+
return this.classifyObjectError(error);
|
|
3113
|
+
}
|
|
3114
|
+
return 'unknown';
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Classifies object-type errors
|
|
3118
|
+
*/
|
|
3119
|
+
classifyObjectError(error) {
|
|
3120
|
+
if (typeof error === 'object' && error !== null) {
|
|
3196
3121
|
if ('isTrusted' in error) {
|
|
3197
3122
|
return 'browser_event';
|
|
3198
3123
|
}
|
|
3199
3124
|
if ('type' in error) {
|
|
3200
|
-
return
|
|
3125
|
+
return this.classifyErrorByType(error);
|
|
3201
3126
|
}
|
|
3202
|
-
return 'object_error';
|
|
3203
3127
|
}
|
|
3204
|
-
return '
|
|
3128
|
+
return 'object_error';
|
|
3129
|
+
}
|
|
3130
|
+
/**
|
|
3131
|
+
* Determines error type classification based on the 'type' property
|
|
3132
|
+
*/
|
|
3133
|
+
classifyErrorByType(error) {
|
|
3134
|
+
const typedError = error;
|
|
3135
|
+
const rawType = typedError['type'];
|
|
3136
|
+
let errorType;
|
|
3137
|
+
if (typeof rawType === 'string') {
|
|
3138
|
+
errorType = rawType;
|
|
3139
|
+
}
|
|
3140
|
+
else if (rawType != null) {
|
|
3141
|
+
errorType = JSON.stringify(rawType);
|
|
3142
|
+
}
|
|
3143
|
+
else {
|
|
3144
|
+
errorType = 'unknown';
|
|
3145
|
+
}
|
|
3146
|
+
return `event_${errorType}`.toLowerCase();
|
|
3205
3147
|
}
|
|
3206
3148
|
isEdgeSyntheticEvent(error) {
|
|
3207
3149
|
// Check if running in Edge browser
|
|
@@ -3261,6 +3203,102 @@ class SentryErrorHandler {
|
|
|
3261
3203
|
const enhancedError = new Error(enhancedErrorMessage);
|
|
3262
3204
|
captureException(enhancedError);
|
|
3263
3205
|
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Filters Sentry events before sending — extracted from beforeSend config
|
|
3208
|
+
* to reduce cognitive complexity (S3776).
|
|
3209
|
+
*
|
|
3210
|
+
* Drops or filters exception values for known noisy/irrelevant error types:
|
|
3211
|
+
* CloseEvent, ResizeObserver, JSON parsing, ChunkLoadError, script loading,
|
|
3212
|
+
* plotly timeout, cross-origin frame, non-error exceptions, and Edge synthetic events.
|
|
3213
|
+
*/
|
|
3214
|
+
static beforeSendFilter(event, hint) {
|
|
3215
|
+
const initialExceptionValuesLength = Array.isArray(event?.exception?.values)
|
|
3216
|
+
? event.exception.values.length
|
|
3217
|
+
: undefined;
|
|
3218
|
+
// Apply all exception-value filters in a single pass
|
|
3219
|
+
if (event?.exception?.values) {
|
|
3220
|
+
event.exception.values = SentryErrorHandler.filterExceptionValues(event.exception.values);
|
|
3221
|
+
}
|
|
3222
|
+
// Check for early-return (drop) conditions
|
|
3223
|
+
const dropReason = SentryErrorHandler.shouldDropEvent(event, hint);
|
|
3224
|
+
if (dropReason) {
|
|
3225
|
+
return null;
|
|
3226
|
+
}
|
|
3227
|
+
// If we started with exception values but filtered them all out, drop the event.
|
|
3228
|
+
if (typeof initialExceptionValuesLength === 'number' &&
|
|
3229
|
+
initialExceptionValuesLength > 0 &&
|
|
3230
|
+
Array.isArray(event?.exception?.values) &&
|
|
3231
|
+
event.exception.values.length === 0) {
|
|
3232
|
+
return null;
|
|
3233
|
+
}
|
|
3234
|
+
return event;
|
|
3235
|
+
}
|
|
3236
|
+
/**
|
|
3237
|
+
* Filters out known noisy exception values in a single pass.
|
|
3238
|
+
*/
|
|
3239
|
+
static filterExceptionValues(values) {
|
|
3240
|
+
const safeIncludes = (val, needle) => typeof val === 'string' && val.includes(needle);
|
|
3241
|
+
return values.filter(value => {
|
|
3242
|
+
// CloseEvent
|
|
3243
|
+
if (value.type === 'CloseEvent' || safeIncludes(value.value, 'CloseEvent')) {
|
|
3244
|
+
return false;
|
|
3245
|
+
}
|
|
3246
|
+
// ResizeObserver loop completed
|
|
3247
|
+
if (value.type === 'Error' &&
|
|
3248
|
+
safeIncludes(value.value, 'ResizeObserver loop completed')) {
|
|
3249
|
+
return false;
|
|
3250
|
+
}
|
|
3251
|
+
// ChunkLoadError
|
|
3252
|
+
if (value.type === 'ChunkLoadError' ||
|
|
3253
|
+
safeIncludes(value.value, 'ChunkLoadError: Loading chunk')) {
|
|
3254
|
+
return false;
|
|
3255
|
+
}
|
|
3256
|
+
// Script loading error
|
|
3257
|
+
if (value.type === 'Error' && safeIncludes(value.value, 'Could not load "util"')) {
|
|
3258
|
+
return false;
|
|
3259
|
+
}
|
|
3260
|
+
// Plotly timeout error
|
|
3261
|
+
if (value.type === 'Error' &&
|
|
3262
|
+
safeIncludes(value.value, 'Error loading plotly.js library from')) {
|
|
3263
|
+
return false;
|
|
3264
|
+
}
|
|
3265
|
+
return true;
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
/**
|
|
3269
|
+
* Determines whether the entire event should be dropped (return truthy to drop).
|
|
3270
|
+
*/
|
|
3271
|
+
static shouldDropEvent(event, hint) {
|
|
3272
|
+
// JSON parsing error from vendor.js
|
|
3273
|
+
const hasJsonParsingError = event?.exception?.values?.some(value => value.type === 'SyntaxError' &&
|
|
3274
|
+
value?.value?.includes("expected ':' after property name in"));
|
|
3275
|
+
if (hasJsonParsingError) {
|
|
3276
|
+
return true;
|
|
3277
|
+
}
|
|
3278
|
+
// Cross-origin frame access error
|
|
3279
|
+
const hasCrossOriginError = event?.exception?.values?.some(value => value.type === 'SecurityError' &&
|
|
3280
|
+
value?.value?.includes("Failed to read a named property 'navigator' from 'Window': Blocked a frame with origin"));
|
|
3281
|
+
if (hasCrossOriginError) {
|
|
3282
|
+
return true;
|
|
3283
|
+
}
|
|
3284
|
+
// Non-error exception
|
|
3285
|
+
const isNonErrorException = event?.exception?.values?.[0]?.value?.startsWith('Non-Error exception captured') ??
|
|
3286
|
+
hint?.originalException?.message?.startsWith('Non-Error exception captured');
|
|
3287
|
+
if (isNonErrorException) {
|
|
3288
|
+
return true;
|
|
3289
|
+
}
|
|
3290
|
+
// Edge browser synthetic isTrusted events
|
|
3291
|
+
const isEdge = /Edg\//.test(navigator.userAgent);
|
|
3292
|
+
if (isEdge && hint?.originalException) {
|
|
3293
|
+
const originalException = hint.originalException;
|
|
3294
|
+
if (originalException &&
|
|
3295
|
+
typeof originalException === 'object' &&
|
|
3296
|
+
originalException['isTrusted'] === true) {
|
|
3297
|
+
return true;
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
return false;
|
|
3301
|
+
}
|
|
3264
3302
|
logToConsole(error) {
|
|
3265
3303
|
// Attempt to print in the console
|
|
3266
3304
|
try {
|