Skip to content

Commit a2c87e6

Browse files
committed
updated code
1 parent 280cf04 commit a2c87e6

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

bin/testObservability/cypress/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ Cypress.on('command:end', (command) => {
201201
});
202202
});
203203

204-
Cypress.on('command:enqueued', (attrs) => {
205-
if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) return;
206-
if (!attrs || attrs.name !== 'log') return;
207-
const args = attrs.args || [];
204+
Cypress.Commands.overwrite('log', (originalFn, ...args) => {
208205
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
209206
const message = args.reduce((result, logItem) => {
210207
if (typeof logItem === 'object') {
@@ -216,16 +213,13 @@ Cypress.on('command:enqueued', (attrs) => {
216213
eventsQueue.push({
217214
task: 'test_observability_log',
218215
data: {
219-
level: 'info',
216+
'level': 'info',
220217
message,
221218
timestamp: new Date().toISOString()
222219
},
223220
options: { log: false }
224221
});
225-
});
226222

227-
Cypress.Commands.overwrite('log', (originalFn, ...args) => {
228-
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
229223
originalFn(...args);
230224
});
231225

bin/testObservability/reporter/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,9 @@ class MyReporter {
631631
if(this.current_hook && ( this.current_hook.hookAnalyticsId && !this.runStatusMarkedHash[this.current_hook.hookAnalyticsId] )) {
632632
log.hook_run_uuid = this.current_hook.hookAnalyticsId;
633633
}
634-
if(!log.hook_run_uuid && this.current_test && ( this.current_test.testAnalyticsId && !this.runStatusMarkedHash[this.current_test.testAnalyticsId] )) log.test_run_uuid = this.current_test.testAnalyticsId;
634+
if(!log.hook_run_uuid && this.current_test && this.current_test.testAnalyticsId) {
635+
log.test_run_uuid = this.current_test.testAnalyticsId;
636+
}
635637
if(log.hook_run_uuid || log.test_run_uuid) {
636638
await uploadEventData({
637639
event_type: 'LogCreated',

0 commit comments

Comments
 (0)