@fluwa-tool/sdk 1.0.28 → 1.0.29
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.
|
@@ -100,12 +100,33 @@ class XMLHttpRequestInterceptor {
|
|
|
100
100
|
requestMetadata.status = xhr.status;
|
|
101
101
|
// Tentar extrair response
|
|
102
102
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
// responseText só está disponível para responseType 'text' ou '' (padrão)
|
|
104
|
+
if (xhr.responseType === '' || xhr.responseType === 'text') {
|
|
105
|
+
if (xhr.responseText) {
|
|
106
|
+
requestMetadata.response = self.safeParseBody(xhr.responseText);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else if (xhr.response) {
|
|
110
|
+
// Para blob, arraybuffer, document, etc., usar xhr.response
|
|
111
|
+
if (typeof xhr.response === 'string') {
|
|
112
|
+
requestMetadata.response = self.safeParseBody(xhr.response);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Não consegue serializar blob/arraybuffer, apenas registra tipo
|
|
116
|
+
requestMetadata.response = `[${xhr.responseType}]`;
|
|
117
|
+
}
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
120
|
catch (e) {
|
|
108
|
-
|
|
121
|
+
// Em caso de erro, tenta responseText como fallback
|
|
122
|
+
try {
|
|
123
|
+
if (xhr.responseText) {
|
|
124
|
+
requestMetadata.response = xhr.responseText;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
requestMetadata.response = undefined;
|
|
129
|
+
}
|
|
109
130
|
}
|
|
110
131
|
const duration = Date.now() - (xhr._fluwaStartTime || 0);
|
|
111
132
|
requestMetadata.duration = duration;
|