diff --git a/packages/rum-core/src/common/constants.js b/packages/rum-core/src/common/constants.js index bfb9c054e..99eaf6a4b 100644 --- a/packages/rum-core/src/common/constants.js +++ b/packages/rum-core/src/common/constants.js @@ -110,7 +110,7 @@ const TRANSACTION_END = 'transaction:end' const CONFIG_CHANGE = 'config:change' const QUEUE_FLUSH = 'queue:flush' const QUEUE_ADD_TRANSACTION = 'queue:add_transaction' -const TRANSACTION_DISCARD = 'transaction:discard' +const TRANSACTION_IGNORE = 'transaction:ignore' /** * Events types that are used to toggle auto instrumentations @@ -204,7 +204,7 @@ export { CONFIG_CHANGE, QUEUE_FLUSH, QUEUE_ADD_TRANSACTION, - TRANSACTION_DISCARD, + TRANSACTION_IGNORE, XMLHTTPREQUEST, FETCH, HISTORY, diff --git a/packages/rum-core/src/common/observers/page-visibility.js b/packages/rum-core/src/common/observers/page-visibility.js index b3ceee96e..6d928bb5c 100644 --- a/packages/rum-core/src/common/observers/page-visibility.js +++ b/packages/rum-core/src/common/observers/page-visibility.js @@ -26,7 +26,7 @@ import { QUEUE_ADD_TRANSACTION, QUEUE_FLUSH, - TRANSACTION_DISCARD + TRANSACTION_IGNORE } from '../constants' import { state } from '../../state' import { now } from '../utils' @@ -82,8 +82,8 @@ export function observePageVisibility(configService, transactionService) { function onPageHidden(configService, transactionService) { const inpTr = reportInp(transactionService) // we don't want to flush the queue for every transaction that is ended when page becomes hidden - // and given the async nature of the ending process of transactions - // will need to coordinate the flushing process + // as transaction ends are scheduled async as microtasks(promise), + // so we are coordinating the flushing process if (inpTr) { const unobserve = configService.observeEvent(QUEUE_ADD_TRANSACTION, () => { // At this point the INP transaction is in the queue @@ -105,7 +105,7 @@ function endManagedTransaction(configService, transactionService) { // Make sure that we still update lastHiddenStart if the managed transaction // ends up being discarded const unobserveDiscard = configService.observeEvent( - TRANSACTION_DISCARD, + TRANSACTION_IGNORE, () => { state.lastHiddenStart = now() diff --git a/packages/rum-core/src/performance-monitoring/performance-monitoring.js b/packages/rum-core/src/performance-monitoring/performance-monitoring.js index 58c53da26..82c680ab5 100644 --- a/packages/rum-core/src/performance-monitoring/performance-monitoring.js +++ b/packages/rum-core/src/performance-monitoring/performance-monitoring.js @@ -48,7 +48,7 @@ import { OUTCOME_SUCCESS, OUTCOME_UNKNOWN, QUEUE_ADD_TRANSACTION, - TRANSACTION_DISCARD + TRANSACTION_IGNORE } from '../common/constants' import { truncateModel, @@ -425,6 +425,6 @@ export default class PerformanceMonitoring { return this.createTransactionDataModel(transaction) } - this._configService.dispatchEvent(TRANSACTION_DISCARD) + this._configService.dispatchEvent(TRANSACTION_IGNORE) } } diff --git a/packages/rum-core/src/performance-monitoring/transaction-service.js b/packages/rum-core/src/performance-monitoring/transaction-service.js index 4a6d4a19d..a69e8ca66 100644 --- a/packages/rum-core/src/performance-monitoring/transaction-service.js +++ b/packages/rum-core/src/performance-monitoring/transaction-service.js @@ -45,7 +45,7 @@ import { NAME_UNKNOWN, TRANSACTION_START, TRANSACTION_END, - TRANSACTION_DISCARD, + TRANSACTION_IGNORE, TEMPORARY_TYPE, TRANSACTION_TYPE_ORDER, LARGEST_CONTENTFUL_PAINT, @@ -258,7 +258,7 @@ class TransactionService { `transaction(${tr.id}, ${name}, ${type}) was discarded! The page was hidden during the transaction!` ) } - this._config.dispatchEvent(TRANSACTION_DISCARD) + this._config.dispatchEvent(TRANSACTION_IGNORE) return } @@ -268,7 +268,7 @@ class TransactionService { `transaction(${tr.id}, ${name}, ${type}) is ignored` ) } - this._config.dispatchEvent(TRANSACTION_DISCARD) + this._config.dispatchEvent(TRANSACTION_IGNORE) return } diff --git a/packages/rum-core/test/performance-monitoring/performance-monitoring.spec.js b/packages/rum-core/test/performance-monitoring/performance-monitoring.spec.js index 5f735ddb8..5bbfd0c17 100644 --- a/packages/rum-core/test/performance-monitoring/performance-monitoring.spec.js +++ b/packages/rum-core/test/performance-monitoring/performance-monitoring.spec.js @@ -50,7 +50,7 @@ import { CONFIG_SERVICE, APM_SERVER, PERFORMANCE_MONITORING, - TRANSACTION_DISCARD + TRANSACTION_IGNORE } from '../../src/common/constants' import { state } from '../../src/state' import patchEventHandler from '../common/patch' @@ -203,9 +203,7 @@ describe('PerformanceMonitoring', function () { var payload = performanceMonitoring.createTransactionPayload(tr) expect(payload).toBeUndefined() - expect(configService.dispatchEvent).toHaveBeenCalledWith( - TRANSACTION_DISCARD - ) + expect(configService.dispatchEvent).toHaveBeenCalledWith(TRANSACTION_IGNORE) }) it('should sendPageLoadMetrics', function (done) { diff --git a/packages/rum-core/test/performance-monitoring/transaction-service.spec.js b/packages/rum-core/test/performance-monitoring/transaction-service.spec.js index bf8ffaec1..ce511c99f 100644 --- a/packages/rum-core/test/performance-monitoring/transaction-service.spec.js +++ b/packages/rum-core/test/performance-monitoring/transaction-service.spec.js @@ -40,7 +40,7 @@ import { FIRST_INPUT, LAYOUT_SHIFT, LOCAL_CONFIG_KEY, - TRANSACTION_DISCARD + TRANSACTION_IGNORE } from '../../src/common/constants' import { state } from '../../src/state' import { isPerfTypeSupported } from '../../src/common/utils' @@ -734,7 +734,7 @@ describe('TransactionService', function () { expect(logger.debug).toHaveBeenCalledWith( `transaction(${tr.id}, ${tr.name}, ${tr.type}) was discarded! The page was hidden during the transaction!` ) - expect(config.dispatchEvent).toHaveBeenCalledWith(TRANSACTION_DISCARD) + expect(config.dispatchEvent).toHaveBeenCalledWith(TRANSACTION_IGNORE) state.lastHiddenStart = performance.now() - 1000 tr = transactionService.startTransaction('test-name', 'test-type') @@ -751,7 +751,7 @@ describe('TransactionService', function () { expect(logger.debug).toHaveBeenCalledWith( `transaction(${tr.id}, ${tr.name}, ${tr.type}) is ignored` ) - expect(config.dispatchEvent).toHaveBeenCalledWith(TRANSACTION_DISCARD) + expect(config.dispatchEvent).toHaveBeenCalledWith(TRANSACTION_IGNORE) }) it('should discard transaction configured to be ignored', async () => { @@ -764,7 +764,7 @@ describe('TransactionService', function () { expect(logger.debug).toHaveBeenCalledWith( `transaction(${tr.id}, ${tr.name}, ${tr.type}) is ignored` ) - expect(config.dispatchEvent).toHaveBeenCalledWith(TRANSACTION_DISCARD) + expect(config.dispatchEvent).toHaveBeenCalledWith(TRANSACTION_IGNORE) }) it('should set session information on transaction', () => {