Skip to content

Commit

Permalink
fix: Undefined deny list ignores block internal (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley authored Aug 1, 2023
1 parent 503b38a commit 27a1b04
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
13 changes: 11 additions & 2 deletions src/loaders/configure/configure.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setAPI, setTopLevelCallers } from '../api/api'
import { addToNREUM, gosCDN, gosNREUMInitializedAgents } from '../../common/window/nreum'
import { setConfiguration, setInfo, setLoaderConfig, setRuntime } from '../../common/config/config'
import { getConfiguration, setConfiguration, setInfo, setLoaderConfig, setRuntime } from '../../common/config/config'
import { activatedFeatures } from '../../common/util/feature-flags'
import { isWorkerScope } from '../../common/constants/runtime'

Expand All @@ -22,7 +22,16 @@ export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
}
setInfo(agentIdentifier, info)

runtime.denyList = init.ajax?.block_internal ? (init.ajax.deny_list || []).concat(info.beacon, info.errorBeacon) : init.ajax?.deny_list
const updatedInit = getConfiguration(agentIdentifier)
runtime.denyList = [
...(updatedInit.ajax?.deny_list || []),
...(updatedInit.ajax?.block_internal
? [
info.beacon,
info.errorBeacon
]
: [])
]
setRuntime(agentIdentifier, runtime)

setTopLevelCallers()
Expand Down
44 changes: 33 additions & 11 deletions tests/specs/spa/harvesting.e2e.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
describe('spa harvesting', () => {
it('should set correct customEnd value on multiple custom interactions', async () => {
const [interactionResults] = await Promise.all([
// interaction3 will eventually be harvested so we need to capture two harvests here

const [interactionResults1, interactionResults2] = await Promise.all([
browser.testHandle.expectInteractionEvents(),
browser.testHandle.expectInteractionEvents(),
browser.url(await browser.testHandle.assetURL('spa/multiple-custom-interactions.html'))
.then(() => browser.waitForAgentLoad())
])

const interactions = interactionResults.request.body
expect(interactions.length).toEqual(3)
const interactions = [
...interactionResults1.request.body,
...interactionResults2.request.body
]
expect(interactions.length).toEqual(4)
expect(interactions).toEqual(expect.arrayContaining([
expect.objectContaining({
customName: 'interaction1'
customName: 'interaction1',
children: expect.arrayContaining([expect.objectContaining({
type: 'customEnd'
})])
}),
expect.objectContaining({
customName: 'interaction2'
customName: 'interaction2',
children: expect.arrayContaining([expect.objectContaining({
type: 'customEnd'
})])
}),
expect.objectContaining({
customName: 'interaction4'
customName: 'interaction3',
children: expect.not.arrayContaining([expect.objectContaining({
type: 'customEnd'
})])
}),
expect.objectContaining({
customName: 'interaction4',
children: expect.arrayContaining([expect.objectContaining({
type: 'customEnd'
})])
})
]))
interactions.forEach(interaction => {
const customEndTime = interaction.children.find(child => child.type === 'customEnd')
expect(customEndTime.time).toBeGreaterThanOrEqual(interaction.end)
})
interactions
.filter(interaction => ['interaction1', 'interaction2', 'interaction4'].includes(interaction.customName))
.forEach(interaction => {
const customEndTime = interaction.children.find(child => child.type === 'customEnd')
expect(customEndTime.time).toBeGreaterThanOrEqual(interaction.end)
})
})
})

0 comments on commit 27a1b04

Please sign in to comment.