@zohodesk/i18n 1.0.0-beta.39-murphy → 1.0.0-beta.40-murphy
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/es/utils/errorReporter.js +33 -18
- package/lib/utils/errorReporter.js +33 -18
- package/package.json +1 -1
- package/src/utils/errorReporter.js +35 -19
|
@@ -8,24 +8,39 @@ const pendingErrors = new Map();
|
|
|
8
8
|
const MAX_PENDING_ERRORS = 100;
|
|
9
9
|
let hasLoggedQueueUse = false;
|
|
10
10
|
let hasLoggedFlushUse = false;
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function getDeskCustomError() {
|
|
12
|
+
if (typeof window === 'undefined') {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return typeof window._windowDeskCustomError === 'function' ? window._windowDeskCustomError : null;
|
|
16
|
+
}
|
|
17
|
+
function isReporterAvailable() {
|
|
18
|
+
return Boolean(getDeskCustomError());
|
|
13
19
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
function sendToDesk(type, key) {
|
|
21
|
+
const deskCustomError = getDeskCustomError();
|
|
22
|
+
if (!deskCustomError) {
|
|
23
|
+
console.log('[i18n] Murphy not available, skipping error report:', {
|
|
24
|
+
type,
|
|
25
|
+
key
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const errorMessage = `i18n ${type}: ${key}`;
|
|
30
|
+
const errorDetails = {
|
|
31
|
+
type,
|
|
32
|
+
key,
|
|
33
|
+
category: 'i18n'
|
|
34
|
+
};
|
|
35
|
+
const envData = {
|
|
36
|
+
errorType: type,
|
|
37
|
+
i18nKey: key,
|
|
38
|
+
category: 'i18n'
|
|
24
39
|
};
|
|
25
40
|
try {
|
|
26
|
-
|
|
41
|
+
deskCustomError(errorDetails, errorMessage, envData);
|
|
27
42
|
} catch (err) {
|
|
28
|
-
|
|
43
|
+
console.log('[i18n] Error reporting to Murphy failed:', err);
|
|
29
44
|
}
|
|
30
45
|
}
|
|
31
46
|
function queuePendingError(dedupeKey, type, key) {
|
|
@@ -46,7 +61,7 @@ function queuePendingError(dedupeKey, type, key) {
|
|
|
46
61
|
});
|
|
47
62
|
}
|
|
48
63
|
export function flushI18NErrors() {
|
|
49
|
-
if (!
|
|
64
|
+
if (!isReporterAvailable()) {
|
|
50
65
|
return;
|
|
51
66
|
}
|
|
52
67
|
if (pendingErrors.size === 0) {
|
|
@@ -63,7 +78,7 @@ export function flushI18NErrors() {
|
|
|
63
78
|
pendingErrors.delete(dedupeKey);
|
|
64
79
|
continue;
|
|
65
80
|
}
|
|
66
|
-
|
|
81
|
+
sendToDesk(data.type, data.key);
|
|
67
82
|
reportedKeys.add(dedupeKey);
|
|
68
83
|
pendingErrors.delete(dedupeKey);
|
|
69
84
|
}
|
|
@@ -73,7 +88,7 @@ export function reportI18NError(type, key) {
|
|
|
73
88
|
if (reportedKeys.has(dedupeKey)) {
|
|
74
89
|
return;
|
|
75
90
|
}
|
|
76
|
-
if (!
|
|
91
|
+
if (!isReporterAvailable()) {
|
|
77
92
|
queuePendingError(dedupeKey, type, key);
|
|
78
93
|
return;
|
|
79
94
|
}
|
|
@@ -81,7 +96,7 @@ export function reportI18NError(type, key) {
|
|
|
81
96
|
if (reportedKeys.has(dedupeKey)) {
|
|
82
97
|
return;
|
|
83
98
|
}
|
|
84
|
-
|
|
99
|
+
sendToDesk(type, key);
|
|
85
100
|
reportedKeys.add(dedupeKey);
|
|
86
101
|
}
|
|
87
102
|
export function clearReportedKeys() {
|
|
@@ -25,24 +25,39 @@ var pendingErrors = new Map();
|
|
|
25
25
|
var MAX_PENDING_ERRORS = 100;
|
|
26
26
|
var hasLoggedQueueUse = false;
|
|
27
27
|
var hasLoggedFlushUse = false;
|
|
28
|
-
function
|
|
29
|
-
|
|
28
|
+
function getDeskCustomError() {
|
|
29
|
+
if (typeof window === 'undefined') {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return typeof window._windowDeskCustomError === 'function' ? window._windowDeskCustomError : null;
|
|
33
|
+
}
|
|
34
|
+
function isReporterAvailable() {
|
|
35
|
+
return Boolean(getDeskCustomError());
|
|
30
36
|
}
|
|
31
|
-
function
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
function sendToDesk(type, key) {
|
|
38
|
+
var deskCustomError = getDeskCustomError();
|
|
39
|
+
if (!deskCustomError) {
|
|
40
|
+
console.log('[i18n] Murphy not available, skipping error report:', {
|
|
41
|
+
type: type,
|
|
42
|
+
key: key
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var errorMessage = "i18n ".concat(type, ": ").concat(key);
|
|
47
|
+
var errorDetails = {
|
|
48
|
+
type: type,
|
|
49
|
+
key: key,
|
|
50
|
+
category: 'i18n'
|
|
51
|
+
};
|
|
52
|
+
var envData = {
|
|
53
|
+
errorType: type,
|
|
54
|
+
i18nKey: key,
|
|
55
|
+
category: 'i18n'
|
|
41
56
|
};
|
|
42
57
|
try {
|
|
43
|
-
|
|
58
|
+
deskCustomError(errorDetails, errorMessage, envData);
|
|
44
59
|
} catch (err) {
|
|
45
|
-
|
|
60
|
+
console.log('[i18n] Error reporting to Murphy failed:', err);
|
|
46
61
|
}
|
|
47
62
|
}
|
|
48
63
|
function queuePendingError(dedupeKey, type, key) {
|
|
@@ -63,7 +78,7 @@ function queuePendingError(dedupeKey, type, key) {
|
|
|
63
78
|
});
|
|
64
79
|
}
|
|
65
80
|
function flushI18NErrors() {
|
|
66
|
-
if (!
|
|
81
|
+
if (!isReporterAvailable()) {
|
|
67
82
|
return;
|
|
68
83
|
}
|
|
69
84
|
if (pendingErrors.size === 0) {
|
|
@@ -86,7 +101,7 @@ function flushI18NErrors() {
|
|
|
86
101
|
pendingErrors["delete"](dedupeKey);
|
|
87
102
|
continue;
|
|
88
103
|
}
|
|
89
|
-
|
|
104
|
+
sendToDesk(data.type, data.key);
|
|
90
105
|
reportedKeys.add(dedupeKey);
|
|
91
106
|
pendingErrors["delete"](dedupeKey);
|
|
92
107
|
}
|
|
@@ -101,7 +116,7 @@ function reportI18NError(type, key) {
|
|
|
101
116
|
if (reportedKeys.has(dedupeKey)) {
|
|
102
117
|
return;
|
|
103
118
|
}
|
|
104
|
-
if (!
|
|
119
|
+
if (!isReporterAvailable()) {
|
|
105
120
|
queuePendingError(dedupeKey, type, key);
|
|
106
121
|
return;
|
|
107
122
|
}
|
|
@@ -109,7 +124,7 @@ function reportI18NError(type, key) {
|
|
|
109
124
|
if (reportedKeys.has(dedupeKey)) {
|
|
110
125
|
return;
|
|
111
126
|
}
|
|
112
|
-
|
|
127
|
+
sendToDesk(type, key);
|
|
113
128
|
reportedKeys.add(dedupeKey);
|
|
114
129
|
}
|
|
115
130
|
function clearReportedKeys() {
|
package/package.json
CHANGED
|
@@ -10,27 +10,43 @@ const MAX_PENDING_ERRORS = 100;
|
|
|
10
10
|
let hasLoggedQueueUse = false;
|
|
11
11
|
let hasLoggedFlushUse = false;
|
|
12
12
|
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
function getDeskCustomError() {
|
|
14
|
+
if (typeof window === 'undefined') {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return typeof window._windowDeskCustomError === 'function'
|
|
19
|
+
? window._windowDeskCustomError
|
|
20
|
+
: null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isReporterAvailable() {
|
|
24
|
+
return Boolean(getDeskCustomError());
|
|
15
25
|
}
|
|
16
26
|
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
function sendToDesk(type, key) {
|
|
28
|
+
const deskCustomError = getDeskCustomError();
|
|
29
|
+
if (!deskCustomError) {
|
|
30
|
+
console.log('[i18n] Murphy not available, skipping error report:', { type, key });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const errorMessage = `i18n ${type}: ${key}`;
|
|
35
|
+
const errorDetails = {
|
|
36
|
+
type,
|
|
37
|
+
key,
|
|
38
|
+
category: 'i18n'
|
|
39
|
+
};
|
|
40
|
+
const envData = {
|
|
41
|
+
errorType: type,
|
|
42
|
+
i18nKey: key,
|
|
43
|
+
category: 'i18n'
|
|
28
44
|
};
|
|
29
45
|
|
|
30
46
|
try {
|
|
31
|
-
|
|
47
|
+
deskCustomError(errorDetails, errorMessage, envData);
|
|
32
48
|
} catch (err) {
|
|
33
|
-
|
|
49
|
+
console.log('[i18n] Error reporting to Murphy failed:', err);
|
|
34
50
|
}
|
|
35
51
|
}
|
|
36
52
|
|
|
@@ -53,7 +69,7 @@ function queuePendingError(dedupeKey, type, key) {
|
|
|
53
69
|
}
|
|
54
70
|
|
|
55
71
|
export function flushI18NErrors() {
|
|
56
|
-
if (!
|
|
72
|
+
if (!isReporterAvailable()) {
|
|
57
73
|
return;
|
|
58
74
|
}
|
|
59
75
|
|
|
@@ -74,7 +90,7 @@ export function flushI18NErrors() {
|
|
|
74
90
|
continue;
|
|
75
91
|
}
|
|
76
92
|
|
|
77
|
-
|
|
93
|
+
sendToDesk(data.type, data.key);
|
|
78
94
|
reportedKeys.add(dedupeKey);
|
|
79
95
|
pendingErrors.delete(dedupeKey);
|
|
80
96
|
}
|
|
@@ -87,7 +103,7 @@ export function reportI18NError(type, key) {
|
|
|
87
103
|
return;
|
|
88
104
|
}
|
|
89
105
|
|
|
90
|
-
if (!
|
|
106
|
+
if (!isReporterAvailable()) {
|
|
91
107
|
queuePendingError(dedupeKey, type, key);
|
|
92
108
|
return;
|
|
93
109
|
}
|
|
@@ -98,7 +114,7 @@ export function reportI18NError(type, key) {
|
|
|
98
114
|
return;
|
|
99
115
|
}
|
|
100
116
|
|
|
101
|
-
|
|
117
|
+
sendToDesk(type, key);
|
|
102
118
|
reportedKeys.add(dedupeKey);
|
|
103
119
|
}
|
|
104
120
|
|