Skip to content

Commit

Permalink
chore: apply pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
devcorpio committed Dec 27, 2023
1 parent 92f455b commit 19bc012
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/rum-core/src/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -204,7 +204,7 @@ export {
CONFIG_CHANGE,
QUEUE_FLUSH,
QUEUE_ADD_TRANSACTION,
TRANSACTION_DISCARD,
TRANSACTION_IGNORE,
XMLHTTPREQUEST,
FETCH,
HISTORY,
Expand Down
8 changes: 4 additions & 4 deletions packages/rum-core/src/common/observers/page-visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import {
QUEUE_ADD_TRANSACTION,
QUEUE_FLUSH,
TRANSACTION_DISCARD
TRANSACTION_IGNORE
} from '../constants'
import { state } from '../../state'
import { now } from '../utils'
Expand Down Expand Up @@ -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
Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
OUTCOME_SUCCESS,
OUTCOME_UNKNOWN,
QUEUE_ADD_TRANSACTION,
TRANSACTION_DISCARD
TRANSACTION_IGNORE
} from '../common/constants'
import {
truncateModel,
Expand Down Expand Up @@ -425,6 +425,6 @@ export default class PerformanceMonitoring {
return this.createTransactionDataModel(transaction)
}

this._configService.dispatchEvent(TRANSACTION_DISCARD)
this._configService.dispatchEvent(TRANSACTION_IGNORE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
NAME_UNKNOWN,
TRANSACTION_START,
TRANSACTION_END,
TRANSACTION_DISCARD,
TRANSACTION_IGNORE,
TEMPORARY_TYPE,
TRANSACTION_TYPE_ORDER,
LARGEST_CONTENTFUL_PAINT,
Expand Down Expand Up @@ -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
}

Expand All @@ -268,7 +268,7 @@ class TransactionService {
`transaction(${tr.id}, ${name}, ${type}) is ignored`
)
}
this._config.dispatchEvent(TRANSACTION_DISCARD)
this._config.dispatchEvent(TRANSACTION_IGNORE)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand All @@ -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 () => {
Expand All @@ -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', () => {
Expand Down

0 comments on commit 19bc012

Please sign in to comment.