@capillarytech/cap-ui-dev-tools 1.7.0 → 1.9.0
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
|
@@ -64,11 +64,6 @@ class WebdriverIOCapVisionRecorder {
|
|
|
64
64
|
/** @type {boolean} */
|
|
65
65
|
this.cdpNetworkLoggingSetup = false;
|
|
66
66
|
|
|
67
|
-
/** @type {Object<string, string>} */
|
|
68
|
-
this.requestMap = {};
|
|
69
|
-
|
|
70
|
-
/** @type {Object<string, {headers: Object, status: number}>} */
|
|
71
|
-
this.responseInfo = {};
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
/**
|
|
@@ -166,60 +161,32 @@ class WebdriverIOCapVisionRecorder {
|
|
|
166
161
|
this.browser.removeAllListeners('Network.requestWillBeSent');
|
|
167
162
|
this.browser.removeAllListeners('Network.responseReceived');
|
|
168
163
|
this.browser.removeAllListeners('Network.loadingFailed');
|
|
169
|
-
this.requestMap = {};
|
|
170
|
-
this.responseInfo = {};
|
|
171
164
|
} catch (e) {
|
|
172
165
|
// Ignore errors when removing listeners
|
|
173
166
|
}
|
|
174
167
|
}
|
|
175
168
|
|
|
176
|
-
// Track requests to map requestId to URL
|
|
177
|
-
this.browser.on('Network.requestWillBeSent', (params) => {
|
|
178
|
-
const { requestId, request } = params;
|
|
179
|
-
this.requestMap[requestId] = request.url;
|
|
180
|
-
});
|
|
181
|
-
|
|
182
169
|
this.browser.on('Network.responseReceived', async (params) => {
|
|
183
|
-
const {
|
|
170
|
+
const { response } = params;
|
|
184
171
|
const url = response.url;
|
|
172
|
+
const statusCode = response.status;
|
|
185
173
|
const cap_requestId = response.headers['x-cap-request-id'] || 'N/A';
|
|
186
174
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// Log to browser console so it gets captured by CapVision recorder
|
|
192
|
-
if (url && url.includes('capillarytech')) {
|
|
193
|
-
await this.browser.execute((url, cap_requestId) => {
|
|
194
|
-
console.log(
|
|
195
|
-
'%c🌐 Network Request',
|
|
175
|
+
if (statusCode >= 400) {
|
|
176
|
+
await this.browser.execute((url, cap_requestId, statusCode) => {
|
|
177
|
+
console.error(
|
|
178
|
+
'%c🔴 Network Request',
|
|
196
179
|
'color: #4CAF50; font-weight: bold; font-size: 12px;',
|
|
197
180
|
'\n 📍 URL:',
|
|
198
181
|
url,
|
|
199
182
|
'\n 🆔 Request ID:',
|
|
200
183
|
cap_requestId,
|
|
184
|
+
'\n 🔴 Status Code:',
|
|
185
|
+
statusCode,
|
|
201
186
|
'\n'
|
|
202
187
|
);
|
|
203
|
-
}, url, cap_requestId);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
// Log failed requests
|
|
208
|
-
this.browser.on('Network.loadingFailed', async (params) => {
|
|
209
|
-
const { requestId } = params;
|
|
210
|
-
const url = this.requestMap[requestId] || 'unknown';
|
|
211
|
-
|
|
212
|
-
const info = this.responseInfo[requestId] || {};
|
|
213
|
-
const headers = info.headers || {};
|
|
214
|
-
const cap_requestId = headers['x-cap-request-id'] || 'N/A';
|
|
215
|
-
const statusCode = info.status || 'status N/A';
|
|
216
|
-
|
|
217
|
-
if (url && url.includes('capillarytech')) {
|
|
218
|
-
await this.browser.execute((url, statusCode, cap_requestId) => {
|
|
219
|
-
console.log(`❌ Request failed (ID: ${cap_requestId}) URL: ${url} Status Code: ${statusCode}`);
|
|
220
188
|
}, url, cap_requestId, statusCode);
|
|
221
189
|
}
|
|
222
|
-
|
|
223
190
|
});
|
|
224
191
|
|
|
225
192
|
this.cdpNetworkLoggingSetup = true;
|