@posiwise/common-services 0.2.11 → 0.2.13

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.
@@ -8,7 +8,7 @@ import { DOCUMENT, CommonModule } from '@angular/common';
8
8
  import * as i1$2 from '@angular/common/http';
9
9
  import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
10
10
  import { throwError, of, BehaviorSubject, tap, timer } from 'rxjs';
11
- import { catchError, take, switchMap, map, mergeMap, tap as tap$1, distinctUntilChanged } from 'rxjs/operators';
11
+ import { catchError, take, tap as tap$1, switchMap, map, mergeMap, distinctUntilChanged } from 'rxjs/operators';
12
12
  import { HelperService } from '@posiwise/helper-service';
13
13
  import * as i1$1 from 'ngx-toastr';
14
14
  import { getUser, SetUser, UserActionTypes, appReducers } from '@posiwise/app-store';
@@ -1108,9 +1108,12 @@ class AuthService {
1108
1108
  phonegap: true
1109
1109
  };
1110
1110
  }
1111
- // Clear all tokens securely
1112
- this.secureTokenStorage.clearTokens().subscribe();
1113
- return this.http.delete('session', options);
1111
+ // Send DELETE request with token intact, then clear tokens after response
1112
+ // Use tap to clear tokens without changing the response stream
1113
+ return this.http.delete('session', options).pipe(tap$1(() => {
1114
+ // Clear tokens AFTER logout succeeds
1115
+ this.secureTokenStorage.clearTokens().subscribe();
1116
+ }));
1114
1117
  }
1115
1118
  /**
1116
1119
  * Clear all authentication tokens
@@ -2986,6 +2989,18 @@ class SentryErrorHandler {
2986
2989
  // We want to ignore those kinds of errors
2987
2990
  return null;
2988
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
+ }
2989
3004
  // If we started with exception values but filtered them all out, drop the event.
2990
3005
  // Otherwise Sentry will group it as an "unlabeled event" and spam the issue stream.
2991
3006
  if (typeof initialExceptionValuesLength === 'number' &&
@@ -3143,6 +3158,13 @@ class SentryErrorHandler {
3143
3158
  scope.setUser({
3144
3159
  ...user
3145
3160
  });
3161
+ // Filter out Edge browser synthetic events before logging
3162
+ if (this.isEdgeSyntheticEvent(error)) {
3163
+ console.warn('Filtered Edge synthetic event:', error);
3164
+ return;
3165
+ }
3166
+ // Tag the event so it can be properly grouped in Sentry
3167
+ scope.setTag('error_type', this.classifyError(error));
3146
3168
  // Ensure error is properly formatted
3147
3169
  if (error instanceof Error && error.message) {
3148
3170
  captureException(error);
@@ -3155,6 +3177,48 @@ class SentryErrorHandler {
3155
3177
  }
3156
3178
  });
3157
3179
  }
3180
+ /**
3181
+ * Classifies the error type for proper Sentry tagging
3182
+ * This prevents "unlabeled events" by ensuring all events have a classification
3183
+ */
3184
+ classifyError(error) {
3185
+ if (error instanceof HttpErrorResponse) {
3186
+ return `http_${error.status}`;
3187
+ }
3188
+ if (error instanceof Error) {
3189
+ const name = error.name || 'Error';
3190
+ return name.toLowerCase().replace(/error$/, '') || 'unknown';
3191
+ }
3192
+ if (typeof error === 'string') {
3193
+ return 'string_error';
3194
+ }
3195
+ if (error && typeof error === 'object') {
3196
+ if ('isTrusted' in error) {
3197
+ return 'browser_event';
3198
+ }
3199
+ if ('type' in error) {
3200
+ return `event_${error.type}`.toLowerCase();
3201
+ }
3202
+ return 'object_error';
3203
+ }
3204
+ return 'unknown';
3205
+ }
3206
+ isEdgeSyntheticEvent(error) {
3207
+ // Check if running in Edge browser
3208
+ const isEdge = /Edg\//.test(navigator.userAgent);
3209
+ if (!isEdge) {
3210
+ return false;
3211
+ }
3212
+ // Filter out Edge synthetic DOM events
3213
+ if (error && typeof error === 'object') {
3214
+ const errorObj = error;
3215
+ if ('isTrusted' in errorObj && errorObj['isTrusted'] === true) {
3216
+ // isTrusted browser events in Edge should not be logged
3217
+ return true;
3218
+ }
3219
+ }
3220
+ return false;
3221
+ }
3158
3222
  handleNonStandardError(error) {
3159
3223
  if ('isTrusted' in error) {
3160
3224
  return;