From 7e65d23ac784364aa3258ff3d65abe5751294191 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Wed, 23 Jul 2025 15:13:56 +0530 Subject: [PATCH 01/10] fix: cy.now with cy.task --- bin/testObservability/cypress/index.js | 94 ++++++++----------- .../helper/cleanupQueueSync.js | 3 +- bin/testObservability/helper/helper.js | 20 ++-- .../helper/requestQueueHandler.js | 2 +- bin/testObservability/plugin/ipcServer.js | 2 +- bin/testObservability/reporter/index.js | 1 - 6 files changed, 54 insertions(+), 68 deletions(-) diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index 78482442..1e49a230 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -1,21 +1,31 @@ /* Event listeners + custom commands for Cypress */ /* Used to detect Gherkin steps */ + +const browserStackLog = (message) => { + if (!Cypress.env('BROWSERSTACK_LOGS')) return; + cy.task('browserstack_log', message); +} + +const shouldSkipCommand = (command) => { + return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command'].some(event => command.attributes.args.includes(event)))); +} + Cypress.on('log:added', (log) => { - return () => { - return cy.now('task', 'test_observability_step', { - log - }, {log: false}) - } - }); - + return () => { + return cy.task('test_observability_step', { + log + }, { log: false }) + } +}); + Cypress.on('command:start', (command) => { - if(!command || !command.attributes) return; - if(command.attributes.name == 'log' || (command.attributes.name == 'task' && (command.attributes.args.includes('test_observability_command') || command.attributes.args.includes('test_observability_log')))) { + if (!command || !command.attributes) return; + if (shouldSkipCommand(command)) { return; } /* Send command details */ - cy.now('task', 'test_observability_command', { + cy.task('test_observability_command', { type: 'COMMAND_START', command: { attributes: { @@ -25,27 +35,23 @@ Cypress.on('command:start', (command) => { }, state: 'pending' } - }, {log: false}).then((res) => { - }).catch((err) => { - }); + }, { log: false }); /* Send platform details */ - cy.now('task', 'test_observability_platform_details', { - testTitle: Cypress.currentTest.title, + cy.task('test_observability_platform_details', { + testTitle: Cypress.currentRunnable?.title || '', browser: Cypress.browser, platform: Cypress.platform, cypressVersion: Cypress.version - }, {log: false}).then((res) => { - }).catch((err) => { - }); + }, { log: false }); }); Cypress.on('command:retry', (command) => { - if(!command || !command.attributes) return; - if(command.attributes.name == 'log' || (command.attributes.name == 'task' && (command.attributes.args.includes('test_observability_command') || command.attributes.args.includes('test_observability_log')))) { + if (!command || !command.attributes) return; + if (shouldSkipCommand(command)) { return; } - cy.now('task', 'test_observability_command', { + cy.task('test_observability_command', { type: 'COMMAND_RETRY', command: { _log: command._log, @@ -54,17 +60,15 @@ Cypress.on('command:retry', (command) => { isDefaultAssertionErr: command && command.error ? command.error.isDefaultAssertionErr : null } } - }, {log: false}).then((res) => { - }).catch((err) => { - }); + }, { log: false }); }); Cypress.on('command:end', (command) => { - if(!command || !command.attributes) return; - if(command.attributes.name == 'log' || (command.attributes.name == 'task' && (command.attributes.args.includes('test_observability_command') || command.attributes.args.includes('test_observability_log')))) { + if (!command || !command.attributes) return; + if (shouldSkipCommand(command)) { return; } - cy.now('task', 'test_observability_command', { + cy.task('test_observability_command', { 'type': 'COMMAND_END', 'command': { 'attributes': { @@ -74,13 +78,11 @@ Cypress.on('command:end', (command) => { }, 'state': command.state } - }, {log: false}).then((res) => { - }).catch((err) => { - }); + }, { log: false }); }); Cypress.Commands.overwrite('log', (originalFn, ...args) => { - if(args.includes('test_observability_log') || args.includes('test_observability_command')) return; + if (args.includes('test_observability_log') || args.includes('test_observability_command')) return; const message = args.reduce((result, logItem) => { if (typeof logItem === 'object') { return [result, JSON.stringify(logItem)].join(' '); @@ -88,71 +90,57 @@ Cypress.Commands.overwrite('log', (originalFn, ...args) => { return [result, logItem ? logItem.toString() : ''].join(' '); }, ''); - cy.now('task', 'test_observability_log', { + cy.task('test_observability_log', { 'level': 'info', message, - }, {log: false}).then((res) => { - }).catch((err) => { - }); + }, { log: false }); originalFn(...args); }); Cypress.Commands.add('trace', (message, file) => { - cy.now('task', 'test_observability_log', { + cy.task('test_observability_log', { level: 'trace', message, file, - }).then((res) => { - }).catch((err) => { }); }); Cypress.Commands.add('logDebug', (message, file) => { - cy.now('task', 'test_observability_log', { + cy.task('test_observability_log', { level: 'debug', message, file, - }).then((res) => { - }).catch((err) => { }); }); Cypress.Commands.add('info', (message, file) => { - cy.now('task', 'test_observability_log', { + cy.task('test_observability_log', { level: 'info', message, file, - }).then((res) => { - }).catch((err) => { }); }); Cypress.Commands.add('warn', (message, file) => { - cy.now('task', 'test_observability_log', { + cy.task('test_observability_log', { level: 'warn', message, file, - }).then((res) => { - }).catch((err) => { }); }); Cypress.Commands.add('error', (message, file) => { - cy.now('task', 'test_observability_log', { + cy.task('test_observability_log', { level: 'error', message, file, - }).then((res) => { - }).catch((err) => { }); }); Cypress.Commands.add('fatal', (message, file) => { - cy.now('task', 'test_observability_log', { + cy.task('test_observability_log', { level: 'fatal', message, file, - }).then((res) => { - }).catch((err) => { }); }); diff --git a/bin/testObservability/helper/cleanupQueueSync.js b/bin/testObservability/helper/cleanupQueueSync.js index aa2603f4..3cf76c10 100644 --- a/bin/testObservability/helper/cleanupQueueSync.js +++ b/bin/testObservability/helper/cleanupQueueSync.js @@ -2,10 +2,9 @@ * Sending all the remaining queues for synchronous manner */ -const RequestQueueHandler = require('./requestQueueHandler'); +const requestHandler = require('./requestQueueHandler'); const shutdown = async () => { - const requestHandler = new RequestQueueHandler(); requestHandler.queue = require(process.argv[2].trim()); await requestHandler.shutdown(); } diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 467f090c..2898e6a6 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -117,6 +117,7 @@ exports.printBuildLink = async (shouldStopSession, exitCode = null) => { } const nodeRequest = (type, url, data, config) => { + const requestQueueHandler = require('./requestQueueHandler'); return new Promise(async (resolve, reject) => { const options = { ...config, @@ -140,8 +141,8 @@ const nodeRequest = (type, url, data, config) => { options.proxy = false options.httpsAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY); } - - if(url === exports.requestQueueHandler.screenshotEventUrl) { + + if(url === requestQueueHandler.screenshotEventUrl) { options.agent = httpsScreenshotsKeepAliveAgent; } axios(options) @@ -521,10 +522,9 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => { } } -const RequestQueueHandler = require('./requestQueueHandler'); -exports.requestQueueHandler = new RequestQueueHandler(); - exports.uploadEventData = async (eventData, run=0) => { + + const requestQueueHandler = require('./requestQueueHandler'); exports.debugOnConsole(`[uploadEventData] ${eventData.event_type}`); const log_tag = { ['TestRunStarted']: 'Test_Start_Upload', @@ -550,8 +550,8 @@ exports.uploadEventData = async (eventData, run=0) => { } else { let data = eventData, event_api_url = 'api/v1/event'; - exports.requestQueueHandler.start(); - const { shouldProceed, proceedWithData, proceedWithUrl } = exports.requestQueueHandler.add(eventData); + requestQueueHandler.start(); + const { shouldProceed, proceedWithData, proceedWithUrl } = requestQueueHandler.add(eventData); exports.debugOnConsole(`[Request Queue] ${eventData.event_type} with uuid ${eventData.test_run ? eventData.test_run.uuid : (eventData.hook_run ? eventData.hook_run.uuid : null)} is added`) if(!shouldProceed) { return; @@ -576,7 +576,7 @@ exports.uploadEventData = async (eventData, run=0) => { if(response.data.error) { throw({message: response.data.error}); } else { - exports.debug(`${event_api_url !== exports.requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'}[${run}] event successfull!`) + exports.debug(`${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'}[${run}] event successfull!`) exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count - (event_api_url === 'api/v1/event' ? 1 : data.length)); return { status: 'success', @@ -586,9 +586,9 @@ exports.uploadEventData = async (eventData, run=0) => { } catch(error) { exports.debugOnConsole(`[Request Error] Error in sending request ${util.format(error)}`); if (error.response) { - exports.debug(`EXCEPTION IN ${event_api_url !== exports.requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO TEST OBSERVABILITY : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error); + exports.debug(`EXCEPTION IN ${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO TEST OBSERVABILITY : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error); } else { - exports.debug(`EXCEPTION IN ${event_api_url !== exports.requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO TEST OBSERVABILITY : ${error.message || error}`, true, error); + exports.debug(`EXCEPTION IN ${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO TEST OBSERVABILITY : ${error.message || error}`, true, error); } exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count - (event_api_url === 'api/v1/event' ? 1 : data.length)); return { diff --git a/bin/testObservability/helper/requestQueueHandler.js b/bin/testObservability/helper/requestQueueHandler.js index 424e1a20..245a4bd8 100644 --- a/bin/testObservability/helper/requestQueueHandler.js +++ b/bin/testObservability/helper/requestQueueHandler.js @@ -98,4 +98,4 @@ class RequestQueueHandler { } } -module.exports = RequestQueueHandler; +module.exports = new RequestQueueHandler(); diff --git a/bin/testObservability/plugin/ipcServer.js b/bin/testObservability/plugin/ipcServer.js index 62e84394..9ac1b398 100644 --- a/bin/testObservability/plugin/ipcServer.js +++ b/bin/testObservability/plugin/ipcServer.js @@ -1,6 +1,6 @@ const ipc = require('node-ipc'); const { consoleHolder } = require('../helper/constants'); -const { requestQueueHandler } = require('../helper/helper'); +const requestQueueHandler = require('../helper/requestQueueHandler'); exports.startIPCServer = (subscribeServerEvents, unsubscribeServerEvents) => { if (ipc.server) { diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index 396ad0e3..949d3046 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -52,7 +52,6 @@ const { mapTestHooks, debug, isBrowserstackInfra, - requestQueueHandler, getHookSkippedTests, getOSDetailsFromSystem, findGitConfig, From 4e6c2d0a0a1a2d273da410f9b740a91f3f3bb6ae Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Wed, 30 Jul 2025 17:44:11 +0530 Subject: [PATCH 02/10] fix: e2e file modification --- bin/commands/runs.js | 9 ++++++++- bin/testObservability/cypress/index.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 0a439ff6..ffbf2506 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -41,6 +41,8 @@ const { isTurboScaleSession, getTurboScaleGridDetails, patchCypressConfigFileCon module.exports = function run(args, rawArgs) { + console.log(`BrowserStack Cypress CLI v${pkg.version}`); + markBlockStart('preBuild'); // set debug mode (--cli-debug) utils.setDebugMode(args); @@ -192,6 +194,10 @@ module.exports = function run(args, rawArgs) { logger.debug("Completed setting the configs"); if(!isBrowserstackInfra) { + if(process.env.BS_TESTOPS_BUILD_COMPLETED) { + setEventListeners(bsConfig); + } + return runCypressTestsLocally(bsConfig, args, rawArgs); } @@ -202,8 +208,9 @@ module.exports = function run(args, rawArgs) { if(process.env.BROWSERSTACK_TEST_ACCESSIBILITY) { setAccessibilityEventListeners(bsConfig); } + console.log('BrowserStack Test Observability Plugin initialized ' + process.env.BS_TESTOPS_BUILD_COMPLETED); if(process.env.BS_TESTOPS_BUILD_COMPLETED) { - // setEventListeners(bsConfig); + setEventListeners(bsConfig); } markBlockEnd('validateConfig'); logger.debug("Completed configs validation"); diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index 1e49a230..168ec306 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -8,7 +8,7 @@ const browserStackLog = (message) => { } const shouldSkipCommand = (command) => { - return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command'].some(event => command.attributes.args.includes(event)))); + return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command', 'browserstack_log'].some(event => command.attributes.args.includes(event)))); } Cypress.on('log:added', (log) => { From 9ce92f7dcd03d65f53189e8c46d7384a175bcd77 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Wed, 30 Jul 2025 18:13:36 +0530 Subject: [PATCH 03/10] chore: logs --- bin/commands/runs.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index ffbf2506..dd04775f 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -41,8 +41,6 @@ const { isTurboScaleSession, getTurboScaleGridDetails, patchCypressConfigFileCon module.exports = function run(args, rawArgs) { - console.log(`BrowserStack Cypress CLI v${pkg.version}`); - markBlockStart('preBuild'); // set debug mode (--cli-debug) utils.setDebugMode(args); @@ -197,7 +195,7 @@ module.exports = function run(args, rawArgs) { if(process.env.BS_TESTOPS_BUILD_COMPLETED) { setEventListeners(bsConfig); } - + return runCypressTestsLocally(bsConfig, args, rawArgs); } @@ -208,7 +206,6 @@ module.exports = function run(args, rawArgs) { if(process.env.BROWSERSTACK_TEST_ACCESSIBILITY) { setAccessibilityEventListeners(bsConfig); } - console.log('BrowserStack Test Observability Plugin initialized ' + process.env.BS_TESTOPS_BUILD_COMPLETED); if(process.env.BS_TESTOPS_BUILD_COMPLETED) { setEventListeners(bsConfig); } From a9d94c4b06ff461d3ced140cd238771bd81f0a7d Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Fri, 1 Aug 2025 15:01:51 +0530 Subject: [PATCH 04/10] update: approach 2 --- bin/testObservability/cypress/index.js | 219 ++++++++++++++++-------- bin/testObservability/helper/helper.js | 7 +- bin/testObservability/plugin/index.js | 4 + bin/testObservability/reporter/index.js | 38 ++-- 4 files changed, 186 insertions(+), 82 deletions(-) diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index 168ec306..865a98bb 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -2,6 +2,10 @@ /* Used to detect Gherkin steps */ +const util = require('util'); + +let eventsQueue = []; + const browserStackLog = (message) => { if (!Cypress.env('BROWSERSTACK_LOGS')) return; cy.task('browserstack_log', message); @@ -13,37 +17,55 @@ const shouldSkipCommand = (command) => { Cypress.on('log:added', (log) => { return () => { - return cy.task('test_observability_step', { - log - }, { log: false }) + eventsQueue.push({ + task: 'test_observability_step', + data: { + log, + started_at: new Date().toISOString(), + finished_at: new Date().toISOString() + }, + options: { log: false } + }); } }); Cypress.on('command:start', (command) => { + if (!command || !command.attributes) return; if (shouldSkipCommand(command)) { return; } - /* Send command details */ - cy.task('test_observability_command', { - type: 'COMMAND_START', - command: { - attributes: { - id: command.attributes.id, - name: command.attributes.name, - args: command.attributes.args - }, - state: 'pending' - } - }, { log: false }); + /* Send command details */ + eventsQueue.push({ + task: 'test_observability_command', + data: { + type: 'COMMAND_START', + command: { + attributes: { + id: command.attributes.id, + name: command.attributes.name, + args: command.attributes.args + }, + state: 'pending', + started_at: new Date().toISOString() + } + }, + options: { log: false } + }); + browserStackLog(`Command started: with args: ${util.format(Cypress.mocha?.getRunner()?.suite?.ctx?.currentTest?.title)}}`); + // browserStackLog(`Command started: ${util.format(command.attributes)} with args: ${util.format(Cypress.mocha)}}`); /* Send platform details */ - cy.task('test_observability_platform_details', { - testTitle: Cypress.currentRunnable?.title || '', - browser: Cypress.browser, - platform: Cypress.platform, - cypressVersion: Cypress.version - }, { log: false }); + eventsQueue.push({ + task: 'test_observability_platform_details', + data: { + testTitle: Cypress?.mocha?.getRunner()?.suite?.ctx?.currentTest?.title || Cypress?.mocha?.getRunner()?.suite?.ctx?._runnable?.title, + browser: Cypress.browser, + platform: Cypress.platform, + cypressVersion: Cypress.version + }, + options: { log: false } + }); }); Cypress.on('command:retry', (command) => { @@ -51,16 +73,20 @@ Cypress.on('command:retry', (command) => { if (shouldSkipCommand(command)) { return; } - cy.task('test_observability_command', { - type: 'COMMAND_RETRY', - command: { - _log: command._log, - error: { - message: command && command.error ? command.error.message : null, - isDefaultAssertionErr: command && command.error ? command.error.isDefaultAssertionErr : null + eventsQueue.push({ + task: 'test_observability_command', + data: { + type: 'COMMAND_RETRY', + command: { + _log: command._log, + error: { + message: command && command.error ? command.error.message : null, + isDefaultAssertionErr: command && command.error ? command.error.isDefaultAssertionErr : null + } } - } - }, { log: false }); + }, + options: { log: false } + }); }); Cypress.on('command:end', (command) => { @@ -68,17 +94,22 @@ Cypress.on('command:end', (command) => { if (shouldSkipCommand(command)) { return; } - cy.task('test_observability_command', { - 'type': 'COMMAND_END', - 'command': { - 'attributes': { - 'id': command.attributes.id, - 'name': command.attributes.name, - 'args': command.attributes.args - }, - 'state': command.state - } - }, { log: false }); + eventsQueue.push({ + task: 'test_observability_command', + data: { + 'type': 'COMMAND_END', + 'command': { + 'attributes': { + 'id': command.attributes.id, + 'name': command.attributes.name, + 'args': command.attributes.args + }, + 'state': command.state, + finished_at: new Date().toISOString() + } + }, + options: { log: false } + }); }); Cypress.Commands.overwrite('log', (originalFn, ...args) => { @@ -90,57 +121,107 @@ Cypress.Commands.overwrite('log', (originalFn, ...args) => { return [result, logItem ? logItem.toString() : ''].join(' '); }, ''); - cy.task('test_observability_log', { - 'level': 'info', - message, - }, { log: false }); + eventsQueue.push({ + task: 'test_observability_log', + data: { + 'level': 'info', + message, + timestamp: new Date().toISOString() + }, + options: { log: false } + }); originalFn(...args); }); Cypress.Commands.add('trace', (message, file) => { - cy.task('test_observability_log', { - level: 'trace', - message, - file, + eventsQueue.push({ + task: 'test_observability_log', + data: { + level: 'trace', + message, + file, + }, + options: { log: false } }); }); Cypress.Commands.add('logDebug', (message, file) => { - cy.task('test_observability_log', { - level: 'debug', - message, - file, + eventsQueue.push({ + task: 'test_observability_log', + data: { + level: 'debug', + message, + file, + }, + options: { log: false } }); }); Cypress.Commands.add('info', (message, file) => { - cy.task('test_observability_log', { - level: 'info', - message, - file, + eventsQueue.push({ + task: 'test_observability_log', + data: { + level: 'info', + message, + file, + }, + options: { log: false } }); }); Cypress.Commands.add('warn', (message, file) => { - cy.task('test_observability_log', { - level: 'warn', - message, - file, + eventsQueue.push({ + task: 'test_observability_log', + data: { + level: 'warn', + message, + file, + }, + options: { log: false } }); }); Cypress.Commands.add('error', (message, file) => { - cy.task('test_observability_log', { - level: 'error', - message, - file, + eventsQueue.push({ + task: 'test_observability_log', + data: { + level: 'error', + message, + file, + }, + options: { log: false } }); }); Cypress.Commands.add('fatal', (message, file) => { - cy.task('test_observability_log', { - level: 'fatal', - message, - file, + eventsQueue.push({ + task: 'test_observability_log', + data: { + level: 'fatal', + message, + file, + }, + options: { log: false } }); }); + +beforeEach(() => { + /* browserstack internal helper hook */ + if (eventsQueue.length > 0) { + eventsQueue.forEach(event => { + cy.task(event.task, event.data, event.options); + }); + } + eventsQueue = []; +}); + +afterEach(function() { + /* browserstack internal helper hook */ + if (eventsQueue.length > 0) { + eventsQueue.forEach(event => { + cy.task(event.task, event.data, event.options); + }); + } + + eventsQueue = []; +}); diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index 2898e6a6..cba8a99b 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -468,6 +468,7 @@ exports.getHooksForTest = (test) => { ['_beforeAll','_afterAll','_beforeEach','_afterEach'].forEach(hookType => { let hooks = test.parent[hookType] || [] hooks.forEach(testHook => { + this.debugOnConsole(`[getHooksForTest] Hook ${util.format(testHook)} with title ${testHook.title} and analyticsId ${testHook.hookAnalyticsId}`); if(testHook.hookAnalyticsId) hooksArr.push(testHook.hookAnalyticsId); }) }); @@ -479,6 +480,7 @@ exports.mapTestHooks = (test) => { ['_beforeAll','_afterAll','_beforeEach','_afterEach'].forEach(hookType => { let hooks = test.parent[hookType] || [] hooks.forEach(testHook => { + this.debugOnConsole(`[mapTestHooks] Hook ${util.format(testHook)} with title ${testHook.title} and analyticsId ${testHook.hookAnalyticsId}`); if(!testHook.hookAnalyticsId) { testHook.hookAnalyticsId = uuidv4(); } else if(testHook.markedStatus && hookType == '_afterEach') { @@ -523,6 +525,9 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => { } exports.uploadEventData = async (eventData, run=0) => { + + + this.debugOnConsole('event data is ' + util.format(eventData)) const requestQueueHandler = require('./requestQueueHandler'); exports.debugOnConsole(`[uploadEventData] ${eventData.event_type}`); @@ -925,7 +930,7 @@ exports.runCypressTestsLocally = (bsConfig, args, rawArgs) => { logger.info(`Running npx cypress run ${getReRunSpecs(rawArgs.slice(1)).join(' ')} ${getLocalSessionReporter().join(' ')}`); const cypressProcess = spawn( 'npx', - ['cypress', 'run', ...getReRunSpecs(rawArgs.slice(1)), ...getLocalSessionReporter()], + ['cypress', 'run', '--headed', ...getReRunSpecs(rawArgs.slice(1)), ...getLocalSessionReporter()], { stdio: 'inherit', cwd: process.cwd(), env: process.env, shell: true } ); cypressProcess.on('close', async (code) => { diff --git a/bin/testObservability/plugin/index.js b/bin/testObservability/plugin/index.js index 6880eb75..92d4eb63 100644 --- a/bin/testObservability/plugin/index.js +++ b/bin/testObservability/plugin/index.js @@ -7,18 +7,22 @@ const browserstackTestObservabilityPlugin = (on, config, callbacks) => { on('task', { test_observability_log(log) { + console.log('test_observability_log', log); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.LOG, log); return null; }, test_observability_command(commandObj) { + console.log('test_observability_command', commandObj); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.COMMAND, commandObj); return null; }, test_observability_platform_details(platformObj) { + console.log('test_observability_platform_details', platformObj); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.PLATFORM_DETAILS, platformObj); return null; }, test_observability_step(log) { + console.log('test_observability_step', log); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.CUCUMBER, log); return null; } diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index 949d3046..93187699 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -87,6 +87,7 @@ class MyReporter { }) .on(EVENT_HOOK_BEGIN, async (hook) => { + if (this.isInternalHook(hook)) return; debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_BEGIN`); if(this.testObservability == true) { if(!hook.hookAnalyticsId) { @@ -104,6 +105,7 @@ class MyReporter { }) .on(EVENT_HOOK_END, async (hook) => { + if (this.isInternalHook(hook)) return; debugOnConsole(`[MOCHA EVENT] EVENT_HOOK_END`); if(this.testObservability == true) { if(!this.runStatusMarkedHash[hook.hookAnalyticsId]) { @@ -205,6 +207,13 @@ class MyReporter { }); } + isInternalHook(hook) { + if (hook && hook.body && hook.body.includes('/* browserstack internal helper hook */')) { + return true; + } + return false; + } + registerListeners() { startIPCServer( (server) => { @@ -247,6 +256,7 @@ class MyReporter { } uploadTestSteps = async (shouldClearCurrentSteps = true, cypressSteps = null) => { + console.log('uploading test steps'); const currentTestSteps = cypressSteps ? cypressSteps : JSON.parse(JSON.stringify(this.currentTestSteps)); /* TODO - Send as test logs */ const allStepsAsLogs = []; @@ -342,6 +352,8 @@ class MyReporter { } const { os, os_version } = await getOSDetailsFromSystem(process.env.observability_product); + debugOnConsole(`${process.env.observability_integration} is integration env`); + debugOnConsole(`platformdetails map is ${util.format(this.platformDetailsMap)} ${process.pid}`); if(process.env.observability_integration) { testData = {...testData, integrations: { [process.env.observability_integration || 'local_grid' ]: { @@ -356,6 +368,7 @@ class MyReporter { } }}; } else if(this.platformDetailsMap[process.pid] && this.platformDetailsMap[process.pid][test.title]) { + debugOnConsole(`Platform details found for test title: ${test.title}`); const {browser, platform} = this.platformDetailsMap[process.pid][test.title]; testData = {...testData, integrations: { 'local_grid': { @@ -517,7 +530,7 @@ class MyReporter { cypressConfigListener = async (config) => { } - cypressCucumberStepListener = async ({log}) => { + cypressCucumberStepListener = async ({log, started_at, finished_at}) => { if(log.name == 'step' && log.consoleProps && log.consoleProps.step && log.consoleProps.step.keyword) { this.currentTestCucumberSteps = [ ...this.currentTestCucumberSteps, @@ -525,8 +538,8 @@ class MyReporter { id: log.chainerId, keyword: log.consoleProps.step.keyword, text: log.consoleProps.step.text, - started_at: new Date().toISOString(), - finished_at: new Date().toISOString(), + started_at: started_at || new Date().toISOString(), + finished_at: finished_at || new Date().toISOString(), duration: 0, result: 'passed' } @@ -536,8 +549,8 @@ class MyReporter { if(gherkinStep.id == log.chainerId) { this.currentTestCucumberSteps[idx] = { ...gherkinStep, - finished_at: new Date().toISOString(), - duration: Date.now() - (new Date(gherkinStep.started_at)).getTime(), + finished_at: finished_at || new Date().toISOString(), + duration: (finished_at ? new Date(finished_at).getTime() : Date.now()) - (new Date(gherkinStep.started_at)).getTime(), result: log.state, failure: log.err?.stack || log.err?.message, failure_reason: log.err?.stack || log.err?.message, @@ -548,9 +561,9 @@ class MyReporter { } } - cypressLogListener = async ({level, message, file}) => { + cypressLogListener = async ({timestamp, level, message}) => { this.appendTestItemLog({ - timestamp: new Date().toISOString(), + timestamp: timestamp || new Date().toISOString(), level: level.toUpperCase(), message, kind: 'TEST_LOG', @@ -572,6 +585,7 @@ class MyReporter { } cypressPlatformDetailsListener = async({testTitle, browser, platform, cypressVersion}) => { + debugOnConsole(`[MOCHA EVENT] cypressPlatformDetailsListener for testTitle: ${testTitle} ${process.env.observability_integration} ${process.pid}`); if(!process.env.observability_integration) { this.platformDetailsMap[process.pid] = this.platformDetailsMap[process.pid] || {}; if(testTitle) this.platformDetailsMap[process.pid][testTitle] = { browser, platform }; @@ -611,12 +625,12 @@ class MyReporter { const currentStepObj = { id: command.attributes.id, text: 'cy.' + command.attributes.name + '(' + this.getFormattedArgs(command.attributes.args) + ')', - started_at: new Date().toISOString(), + started_at: command.started_at || new Date().toISOString(), finished_at: null, duration: null, result: 'pending', - test_run_uuid: this.current_test?.testAnalyticsId && !this.runStatusMarkedHash[this.current_test.testAnalyticsId] ? this.current_test.testAnalyticsId : null, - hook_run_uuid : this.current_hook?.hookAnalyticsId && !this.runStatusMarkedHash[this.current_hook.hookAnalyticsId] ? this.current_hook.hookAnalyticsId : null + test_run_uuid: this.current_test?.testAnalyticsId, + hook_run_uuid : this.current_hook?.hookAnalyticsId }; if(currentStepObj.hook_run_uuid && currentStepObj.test_run_uuid) delete currentStepObj.test_run_uuid; this.currentTestSteps = [ @@ -629,8 +643,8 @@ class MyReporter { if(val.id == command.attributes.id) { this.currentTestSteps[idx] = { ...val, - finished_at: new Date().toISOString(), - duration: Date.now() - (new Date(val.started_at)).getTime(), + finished_at: command.finished_at || new Date().toISOString(), + duration: (command.finished_at ? new Date(command.finished_at).getTime() : Date.now()) - (new Date(val.started_at)).getTime(), result: command.state }; stepUpdated = true; From 80b4c6e9f8e352fe4e2be6477da28907e3e19257 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Fri, 1 Aug 2025 17:00:14 +0530 Subject: [PATCH 05/10] fix: failure case --- bin/testObservability/cypress/index.js | 12 +++++++++--- bin/testObservability/reporter/index.js | 8 ++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index 865a98bb..8fab2016 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -5,6 +5,7 @@ const util = require('util'); let eventsQueue = []; +let testRunStarted = false; const browserStackLog = (message) => { if (!Cypress.env('BROWSERSTACK_LOGS')) return; @@ -48,7 +49,8 @@ Cypress.on('command:start', (command) => { args: command.attributes.args }, state: 'pending', - started_at: new Date().toISOString() + started_at: new Date().toISOString(), + location: testRunStarted ? 'test' : 'hook' } }, options: { log: false } @@ -82,7 +84,8 @@ Cypress.on('command:retry', (command) => { error: { message: command && command.error ? command.error.message : null, isDefaultAssertionErr: command && command.error ? command.error.isDefaultAssertionErr : null - } + }, + location: testRunStarted ? 'test' : 'hook' } }, options: { log: false } @@ -105,7 +108,8 @@ Cypress.on('command:end', (command) => { 'args': command.attributes.args }, 'state': command.state, - finished_at: new Date().toISOString() + finished_at: new Date().toISOString(), + location: testRunStarted ? 'test' : 'hook' } }, options: { log: false } @@ -213,6 +217,7 @@ beforeEach(() => { }); } eventsQueue = []; + testRunStarted = true; }); afterEach(function() { @@ -224,4 +229,5 @@ afterEach(function() { } eventsQueue = []; + testRunStarted = false; }); diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index 93187699..6d369cf1 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -629,8 +629,8 @@ class MyReporter { finished_at: null, duration: null, result: 'pending', - test_run_uuid: this.current_test?.testAnalyticsId, - hook_run_uuid : this.current_hook?.hookAnalyticsId + test_run_uuid: command.location === 'test' ? this.current_test?.testAnalyticsId : null, + hook_run_uuid : command.location === 'hook' ? this.current_hook?.hookAnalyticsId : null }; if(currentStepObj.hook_run_uuid && currentStepObj.test_run_uuid) delete currentStepObj.test_run_uuid; this.currentTestSteps = [ @@ -660,8 +660,8 @@ class MyReporter { finished_at: new Date().toISOString(), duration: 0, result: command.state, - test_run_uuid: this.current_test?.testAnalyticsId && !this.runStatusMarkedHash[this.current_test.testAnalyticsId] ? this.current_test.testAnalyticsId : null, - hook_run_uuid : this.current_hook?.hookAnalyticsId && !this.runStatusMarkedHash[this.current_hook.hookAnalyticsId] ? this.current_hook.hookAnalyticsId : null + test_run_uuid: command.location === 'test' ? this.current_test?.testAnalyticsId : null, + hook_run_uuid : command.location === 'hook' ? this.current_hook?.hookAnalyticsId : null }; if(currentStepObj.hook_run_uuid && currentStepObj.test_run_uuid) delete currentStepObj.test_run_uuid; this.currentTestSteps = [ From 6e2cffc345bac27a8478da137a78efe5ff208657 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Tue, 5 Aug 2025 15:51:53 +0530 Subject: [PATCH 06/10] chore: logs --- bin/testObservability/cypress/index.js | 3 +-- bin/testObservability/helper/helper.js | 8 +------- bin/testObservability/plugin/index.js | 4 ---- bin/testObservability/reporter/index.js | 7 +------ 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index 8fab2016..bbd65c59 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -8,6 +8,7 @@ let eventsQueue = []; let testRunStarted = false; const browserStackLog = (message) => { + if (!Cypress.env('BROWSERSTACK_LOGS')) return; cy.task('browserstack_log', message); } @@ -55,8 +56,6 @@ Cypress.on('command:start', (command) => { }, options: { log: false } }); - browserStackLog(`Command started: with args: ${util.format(Cypress.mocha?.getRunner()?.suite?.ctx?.currentTest?.title)}}`); - // browserStackLog(`Command started: ${util.format(command.attributes)} with args: ${util.format(Cypress.mocha)}}`); /* Send platform details */ eventsQueue.push({ task: 'test_observability_platform_details', diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index cba8a99b..2b253416 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -468,7 +468,6 @@ exports.getHooksForTest = (test) => { ['_beforeAll','_afterAll','_beforeEach','_afterEach'].forEach(hookType => { let hooks = test.parent[hookType] || [] hooks.forEach(testHook => { - this.debugOnConsole(`[getHooksForTest] Hook ${util.format(testHook)} with title ${testHook.title} and analyticsId ${testHook.hookAnalyticsId}`); if(testHook.hookAnalyticsId) hooksArr.push(testHook.hookAnalyticsId); }) }); @@ -480,7 +479,6 @@ exports.mapTestHooks = (test) => { ['_beforeAll','_afterAll','_beforeEach','_afterEach'].forEach(hookType => { let hooks = test.parent[hookType] || [] hooks.forEach(testHook => { - this.debugOnConsole(`[mapTestHooks] Hook ${util.format(testHook)} with title ${testHook.title} and analyticsId ${testHook.hookAnalyticsId}`); if(!testHook.hookAnalyticsId) { testHook.hookAnalyticsId = uuidv4(); } else if(testHook.markedStatus && hookType == '_afterEach') { @@ -525,10 +523,6 @@ exports.batchAndPostEvents = async (eventUrl, kind, data) => { } exports.uploadEventData = async (eventData, run=0) => { - - - this.debugOnConsole('event data is ' + util.format(eventData)) - const requestQueueHandler = require('./requestQueueHandler'); exports.debugOnConsole(`[uploadEventData] ${eventData.event_type}`); const log_tag = { @@ -930,7 +924,7 @@ exports.runCypressTestsLocally = (bsConfig, args, rawArgs) => { logger.info(`Running npx cypress run ${getReRunSpecs(rawArgs.slice(1)).join(' ')} ${getLocalSessionReporter().join(' ')}`); const cypressProcess = spawn( 'npx', - ['cypress', 'run', '--headed', ...getReRunSpecs(rawArgs.slice(1)), ...getLocalSessionReporter()], + ['cypress', 'run', ...getReRunSpecs(rawArgs.slice(1)), ...getLocalSessionReporter()], { stdio: 'inherit', cwd: process.cwd(), env: process.env, shell: true } ); cypressProcess.on('close', async (code) => { diff --git a/bin/testObservability/plugin/index.js b/bin/testObservability/plugin/index.js index 92d4eb63..6880eb75 100644 --- a/bin/testObservability/plugin/index.js +++ b/bin/testObservability/plugin/index.js @@ -7,22 +7,18 @@ const browserstackTestObservabilityPlugin = (on, config, callbacks) => { on('task', { test_observability_log(log) { - console.log('test_observability_log', log); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.LOG, log); return null; }, test_observability_command(commandObj) { - console.log('test_observability_command', commandObj); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.COMMAND, commandObj); return null; }, test_observability_platform_details(platformObj) { - console.log('test_observability_platform_details', platformObj); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.PLATFORM_DETAILS, platformObj); return null; }, test_observability_step(log) { - console.log('test_observability_step', log); ipc.of.browserstackTestObservability.emit(IPC_EVENTS.CUCUMBER, log); return null; } diff --git a/bin/testObservability/reporter/index.js b/bin/testObservability/reporter/index.js index 6d369cf1..9e18b4df 100644 --- a/bin/testObservability/reporter/index.js +++ b/bin/testObservability/reporter/index.js @@ -255,8 +255,7 @@ class MyReporter { } } - uploadTestSteps = async (shouldClearCurrentSteps = true, cypressSteps = null) => { - console.log('uploading test steps'); + uploadTestSteps = async (shouldClearCurrentSteps = true, cypressSteps = null) => { const currentTestSteps = cypressSteps ? cypressSteps : JSON.parse(JSON.stringify(this.currentTestSteps)); /* TODO - Send as test logs */ const allStepsAsLogs = []; @@ -352,8 +351,6 @@ class MyReporter { } const { os, os_version } = await getOSDetailsFromSystem(process.env.observability_product); - debugOnConsole(`${process.env.observability_integration} is integration env`); - debugOnConsole(`platformdetails map is ${util.format(this.platformDetailsMap)} ${process.pid}`); if(process.env.observability_integration) { testData = {...testData, integrations: { [process.env.observability_integration || 'local_grid' ]: { @@ -368,7 +365,6 @@ class MyReporter { } }}; } else if(this.platformDetailsMap[process.pid] && this.platformDetailsMap[process.pid][test.title]) { - debugOnConsole(`Platform details found for test title: ${test.title}`); const {browser, platform} = this.platformDetailsMap[process.pid][test.title]; testData = {...testData, integrations: { 'local_grid': { @@ -585,7 +581,6 @@ class MyReporter { } cypressPlatformDetailsListener = async({testTitle, browser, platform, cypressVersion}) => { - debugOnConsole(`[MOCHA EVENT] cypressPlatformDetailsListener for testTitle: ${testTitle} ${process.env.observability_integration} ${process.pid}`); if(!process.env.observability_integration) { this.platformDetailsMap[process.pid] = this.platformDetailsMap[process.pid] || {}; if(testTitle) this.platformDetailsMap[process.pid][testTitle] = { browser, platform }; From f105e9e9c6598361be130510eb3f2005351aec99 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Tue, 5 Aug 2025 16:00:32 +0530 Subject: [PATCH 07/10] chore: comments --- bin/testObservability/cypress/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index bbd65c59..83ef80b6 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -14,7 +14,7 @@ const browserStackLog = (message) => { } const shouldSkipCommand = (command) => { - return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command', 'browserstack_log'].some(event => command.attributes.args.includes(event)))); + return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command', 'browserstack_log', 'test_observability_log'].some(event => command.attributes.args.includes(event)))); } Cypress.on('log:added', (log) => { From f93465f2e63f1b666e3e0abdb9679367d9072a24 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Tue, 12 Aug 2025 11:20:54 +0530 Subject: [PATCH 08/10] fix: cypress v12 --- bin/testObservability/cypress/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index 83ef80b6..6713c874 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -57,10 +57,19 @@ Cypress.on('command:start', (command) => { options: { log: false } }); /* Send platform details */ + let testTitle = ''; + try { + const runner = Cypress.mocha.getRunner(); + const ctx = runner.suite.ctx; + testTitle = ctx.currentTest.title || ctx._runnable.title; + } catch (error) { + // Silently handle if any property is undefined + } + eventsQueue.push({ task: 'test_observability_platform_details', data: { - testTitle: Cypress?.mocha?.getRunner()?.suite?.ctx?.currentTest?.title || Cypress?.mocha?.getRunner()?.suite?.ctx?._runnable?.title, + testTitle, browser: Cypress.browser, platform: Cypress.platform, cypressVersion: Cypress.version From 4aad557126c91bdf24f0e53148a912858cfd19d2 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Tue, 12 Aug 2025 12:40:24 +0530 Subject: [PATCH 09/10] chore: handle plugin not imported --- bin/testObservability/cypress/index.js | 15 +++++++++++++++ bin/testObservability/plugin/index.js | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/bin/testObservability/cypress/index.js b/bin/testObservability/cypress/index.js index 6713c874..0eb2f3d8 100644 --- a/bin/testObservability/cypress/index.js +++ b/bin/testObservability/cypress/index.js @@ -14,11 +14,17 @@ const browserStackLog = (message) => { } const shouldSkipCommand = (command) => { + if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) { + return true; + } return command.attributes.name == 'log' || (command.attributes.name == 'task' && (['test_observability_platform_details', 'test_observability_step', 'test_observability_command', 'browserstack_log', 'test_observability_log'].some(event => command.attributes.args.includes(event)))); } Cypress.on('log:added', (log) => { return () => { + if (shouldSkipCommand(command)) { + return; + } eventsQueue.push({ task: 'test_observability_step', data: { @@ -219,6 +225,11 @@ Cypress.Commands.add('fatal', (message, file) => { beforeEach(() => { /* browserstack internal helper hook */ + + if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) { + return; + } + if (eventsQueue.length > 0) { eventsQueue.forEach(event => { cy.task(event.task, event.data, event.options); @@ -230,6 +241,10 @@ beforeEach(() => { afterEach(function() { /* browserstack internal helper hook */ + if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) { + return; + } + if (eventsQueue.length > 0) { eventsQueue.forEach(event => { cy.task(event.task, event.data, event.options); diff --git a/bin/testObservability/plugin/index.js b/bin/testObservability/plugin/index.js index 6880eb75..d32ade0d 100644 --- a/bin/testObservability/plugin/index.js +++ b/bin/testObservability/plugin/index.js @@ -3,6 +3,12 @@ const { connectIPCClient } = require('./ipcClient'); const { IPC_EVENTS } = require('../helper/constants'); const browserstackTestObservabilityPlugin = (on, config, callbacks) => { + + try { + config.env.BROWSERSTACK_O11Y_LOGS = 'true'; + process.env.BROWSERSTACK_O11Y_LOGS = 'true'; + } catch (err) {} + connectIPCClient(config); on('task', { From 4021b8575eb78fe6531f9f4f64981c8748800c58 Mon Sep 17 00:00:00 2001 From: 07souravkunda Date: Mon, 18 Aug 2025 15:21:13 +0530 Subject: [PATCH 10/10] fix: requestQueueHandler --- bin/testObservability/helper/helper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/testObservability/helper/helper.js b/bin/testObservability/helper/helper.js index c4506eb0..ea9130cf 100644 --- a/bin/testObservability/helper/helper.js +++ b/bin/testObservability/helper/helper.js @@ -585,9 +585,9 @@ exports.uploadEventData = async (eventData, run=0) => { } catch(error) { exports.debugOnConsole(`[Request Error] Error in sending request ${util.format(error)}`); if (error.response) { - exports.debug(`EXCEPTION IN ${event_api_url !== exports.requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error); + exports.debug(`EXCEPTION IN ${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`, true, error); } else { - exports.debug(`EXCEPTION IN ${event_api_url !== exports.requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.message || error}`, true, error); + exports.debug(`EXCEPTION IN ${event_api_url !== requestQueueHandler.eventUrl ? log_tag : 'Batch-Queue'} REQUEST TO ${TEST_REPORTING_ANALYTICS} : ${error.message || error}`, true, error); } exports.pending_test_uploads.count = Math.max(0,exports.pending_test_uploads.count - (event_api_url === 'api/v1/event' ? 1 : data.length)); return {