Skip to content

Commit 30db980

Browse files
committed
updated code
1 parent a2c87e6 commit 30db980

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

bin/testObservability/cypress/index.js

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

204-
Cypress.Commands.overwrite('log', (originalFn, ...args) => {
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 || [];
205208
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
206209
const message = args.reduce((result, logItem) => {
207210
if (typeof logItem === 'object') {
@@ -213,13 +216,16 @@ Cypress.Commands.overwrite('log', (originalFn, ...args) => {
213216
eventsQueue.push({
214217
task: 'test_observability_log',
215218
data: {
216-
'level': 'info',
219+
level: 'info',
217220
message,
218221
timestamp: new Date().toISOString()
219222
},
220223
options: { log: false }
221224
});
225+
});
222226

227+
Cypress.Commands.overwrite('log', (originalFn, ...args) => {
228+
if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
223229
originalFn(...args);
224230
});
225231

bin/testObservability/reporter/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,7 @@ 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) {
635-
log.test_run_uuid = this.current_test.testAnalyticsId;
636-
}
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;
637635
if(log.hook_run_uuid || log.test_run_uuid) {
638636
await uploadEventData({
639637
event_type: 'LogCreated',

0 commit comments

Comments
 (0)