@umituz/react-native-exception 1.2.10 → 1.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-exception",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "Exception handling and error tracking for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@umituz/react-native-firebase": "latest",
|
|
29
29
|
"@umituz/react-native-firebase-auth": "latest",
|
|
30
|
+
"@umituz/react-native-uuid": "latest",
|
|
30
31
|
"react": ">=18.2.0",
|
|
31
32
|
"react-native": ">=0.74.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@umituz/react-native-firebase": "latest",
|
|
35
36
|
"@umituz/react-native-firebase-auth": "latest",
|
|
37
|
+
"@umituz/react-native-uuid": "latest",
|
|
36
38
|
"@types/react": "~19.1.10",
|
|
37
39
|
"react": "19.1.0",
|
|
38
40
|
"react-native": "0.81.5",
|
|
@@ -46,4 +48,4 @@
|
|
|
46
48
|
"README.md",
|
|
47
49
|
"LICENSE"
|
|
48
50
|
]
|
|
49
|
-
}
|
|
51
|
+
}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Pure business logic representation of errors and exceptions
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import 'react-native-
|
|
7
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import { generateUUID } from '@umituz/react-native-uuid';
|
|
8
7
|
|
|
9
8
|
export type ExceptionSeverity = 'fatal' | 'error' | 'warning' | 'info';
|
|
10
9
|
export type ExceptionCategory = 'network' | 'validation' | 'authentication' | 'authorization' | 'business-logic' | 'system' | 'storage' | 'unknown';
|
|
@@ -51,7 +50,7 @@ export function createException(
|
|
|
51
50
|
context: ExceptionContext = {}
|
|
52
51
|
): ExceptionEntity {
|
|
53
52
|
return {
|
|
54
|
-
id:
|
|
53
|
+
id: generateUUID(),
|
|
55
54
|
message: error.message,
|
|
56
55
|
stackTrace: error.stack,
|
|
57
56
|
severity,
|
|
@@ -70,7 +69,7 @@ export function createErrorLog(
|
|
|
70
69
|
exception: ExceptionEntity
|
|
71
70
|
): ErrorLog {
|
|
72
71
|
return {
|
|
73
|
-
id:
|
|
72
|
+
id: generateUUID(),
|
|
74
73
|
exceptionId: exception.id,
|
|
75
74
|
userId: exception.context.userId,
|
|
76
75
|
message: exception.message,
|
|
@@ -141,16 +141,18 @@ export class ExceptionLogger {
|
|
|
141
141
|
*/
|
|
142
142
|
protected async getStorageItem(key: string): Promise<string | null> {
|
|
143
143
|
// Default implementation using localStorage/globalThis for web, AsyncStorage for RN
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
const g = globalThis as any;
|
|
145
|
+
if (typeof g !== 'undefined' && g.localStorage) {
|
|
146
|
+
return g.localStorage.getItem(key);
|
|
146
147
|
}
|
|
147
148
|
// For React Native, this would be overridden
|
|
148
149
|
return null;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
protected async setStorageItem(key: string, value: string): Promise<void> {
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
const g = globalThis as any;
|
|
154
|
+
if (typeof g !== 'undefined' && g.localStorage) {
|
|
155
|
+
g.localStorage.setItem(key, value);
|
|
154
156
|
}
|
|
155
157
|
// For React Native, this would be overridden
|
|
156
158
|
}
|