@capillarytech/cap-ui-dev-tools 1.6.0 → 1.7.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capillarytech/cap-ui-dev-tools",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Development tools for Capillary UI projects including webpack hot-reload plugin and CapVision session recording",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -66,6 +66,9 @@ class WebdriverIOCapVisionRecorder {
66
66
 
67
67
  /** @type {Object<string, string>} */
68
68
  this.requestMap = {};
69
+
70
+ /** @type {Object<string, {headers: Object, status: number}>} */
71
+ this.responseInfo = {};
69
72
  }
70
73
 
71
74
  /**
@@ -164,6 +167,7 @@ class WebdriverIOCapVisionRecorder {
164
167
  this.browser.removeAllListeners('Network.responseReceived');
165
168
  this.browser.removeAllListeners('Network.loadingFailed');
166
169
  this.requestMap = {};
170
+ this.responseInfo = {};
167
171
  } catch (e) {
168
172
  // Ignore errors when removing listeners
169
173
  }
@@ -176,33 +180,45 @@ class WebdriverIOCapVisionRecorder {
176
180
  });
177
181
 
178
182
  this.browser.on('Network.responseReceived', async (params) => {
179
- const { response } = params;
183
+ const { requestId, response } = params;
180
184
  const url = response.url;
181
- const requestId = response.headers['x-cap-request-id'] || 'N/A';
185
+ const cap_requestId = response.headers['x-cap-request-id'] || 'N/A';
182
186
 
187
+ this.responseInfo[requestId] = {
188
+ headers: response.headers,
189
+ status: response.status,
190
+ };
183
191
  // Log to browser console so it gets captured by CapVision recorder
184
- await this.browser.execute((url, requestId) => {
185
- console.log(
186
- '%c🌐 Network Request',
187
- 'color: #4CAF50; font-weight: bold; font-size: 12px;',
188
- '\n 📍 URL:',
189
- url,
190
- '\n 🆔 Request ID:',
191
- requestId,
192
- '\n'
193
- );
194
- }, url, requestId);
192
+ if (url && url.includes('capillarytech')) {
193
+ await this.browser.execute((url, cap_requestId) => {
194
+ console.log(
195
+ '%c🌐 Network Request',
196
+ 'color: #4CAF50; font-weight: bold; font-size: 12px;',
197
+ '\n 📍 URL:',
198
+ url,
199
+ '\n 🆔 Request ID:',
200
+ cap_requestId,
201
+ '\n'
202
+ );
203
+ }, url, cap_requestId);
204
+ }
195
205
  });
196
206
 
197
207
  // Log failed requests
198
208
  this.browser.on('Network.loadingFailed', async (params) => {
199
209
  const { requestId } = params;
200
210
  const url = this.requestMap[requestId] || 'unknown';
201
- const cap_requestId = params?.response?.headers['x-cap-request-id'] || 'N/A';
202
211
 
203
- await this.browser.execute((url, cap_requestId) => {
204
- console.log(`❌ Request failed (ID: ${cap_requestId})`, url);
205
- }, url, cap_requestId);
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
+ }, url, cap_requestId, statusCode);
221
+ }
206
222
 
207
223
  });
208
224
 
Binary file