Skip to content

Commit a7ac827

Browse files
feat: Prepare agent to utilize v2 harvests for MFE registrations (#1495)
1 parent c28af11 commit a7ac827

File tree

76 files changed

+1355
-1427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1355
-1427
lines changed

.github/actions/build-ab/templates/postamble.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ if (!!newrelic && !!newrelic.log) {
6464
}
6565

6666
// Browser AI-Hackthon POC Prep
67-
try{
67+
try {
6868
const automatedHints = ['Headless', 'PhantomJS', 'Selenium', 'WebDriver', 'Puppeteer', 'Playwright']
6969
const botHints = ['bot', 'spider', 'crawler', 'scraper', 'robot', 'Googlebot', 'Bingbot', 'Slurp', 'DuckDuckBot', 'Baiduspider', 'YandexBot', 'AhrefsBot', 'SemrushBot', 'Exabot', 'facebot', 'ia_archiver', 'facebookexternalhit', 'Twitterbot', 'LinkedInBot', 'Slackbot', 'Discordbot', 'Pinterestbot', 'WhatsApp', 'TelegramBot', 'GoogleAdsBot', 'BingPreview']
70-
70+
7171
const automatedMatches = []
7272
const botMatches = []
7373

@@ -81,7 +81,7 @@ try{
8181

8282
const userAgentString = window.navigator.userAgent
8383

84-
if (userAgentString){
84+
if (userAgentString) {
8585
automatedHints.map(x => x.toLowerCase()).forEach((hint) => {
8686
if (userAgentString.toLowerCase().includes(hint)) {
8787
automatedMatches.push(hint);
@@ -107,7 +107,7 @@ try{
107107
newrelic.setCustomAttribute('userAgent', window.navigator.userAgent);
108108
}
109109
} catch (e) {
110-
newrelic.noticeError(new Error("NRBA: swallowed preamble error", {cause: e}));
110+
newrelic.noticeError(new Error("NRBA: swallowed preamble error", { cause: e }));
111111
}
112112

113113
try {
@@ -140,5 +140,5 @@ try {
140140
pressureObserver.observe("cpu", { sampleInterval: 1000 });
141141
}
142142
} catch (e) {
143-
newrelic.noticeError(new Error("NRBA: swallowed preamble error", {cause: e}));
143+
newrelic.noticeError(new Error("NRBA: swallowed preamble error", { cause: e }));
144144
}

.github/actions/build-ab/templates/released.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// config
22
window.NREUM={
33
init: {
4-
feature_flags: ['soft_nav', 'user_frustrations'],
4+
feature_flags: ['soft_nav', 'user_frustrations', 'register'], // add jserrors and generic events once the consumer(s) support it
55
distributed_tracing: {
66
enabled: true
77
},

.github/workflows/pull-request-checks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
description: 'Run the latest version of browsers only instead of all versions'
1414
default: true
1515
type: boolean
16+
boosted:
17+
description: 'Enable boosted testing (uses more resources)'
18+
default: false
19+
type: boolean
1620
pull_request:
1721

1822
jobs:
@@ -261,6 +265,7 @@ jobs:
261265
with:
262266
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
263267
latest-only: ${{ inputs.latest-only }}
268+
boosted: ${{ inputs.boosted }}
264269
secrets: inherit
265270

266271
complete-status-comment-pull-request:

.github/workflows/wdio-all-browsers.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
description: 'Run the latest version of browsers only instead of all versions'
1313
default: true
1414
type: boolean
15+
boosted:
16+
description: 'Enable boosted testing (uses more resources)'
17+
default: false
18+
type: boolean
1519
secrets:
1620
LAMBDA_USERNAME:
1721
required: true
@@ -24,27 +28,31 @@ jobs:
2428
with:
2529
ref: ${{ inputs.ref || github.ref }}
2630
browser-target: ${{ inputs.latest-only == true && 'chrome@latest' || 'chrome@*' }}
31+
concurrency: ${{ inputs.boosted == true && 20 || 10 }}
2732
secrets: inherit
2833

2934
firefox:
3035
uses: ./.github/workflows/wdio-single-browser.yml
3136
with:
3237
ref: ${{ inputs.ref || github.ref }}
3338
browser-target: ${{ inputs.latest-only == true && 'firefox@latest' || 'firefox@*' }}
39+
concurrency: ${{ inputs.boosted == true && 20 || 10 }}
3440
secrets: inherit
3541

3642
safari:
3743
uses: ./.github/workflows/wdio-single-browser.yml
3844
with:
3945
ref: ${{ inputs.ref || github.ref }}
4046
browser-target: ${{ inputs.latest-only == true && 'safari@latest' || 'safari@*' }}
47+
concurrency: ${{ inputs.boosted == true && 20 || 10 }}
4148
secrets: inherit
4249

4350
edge:
4451
uses: ./.github/workflows/wdio-single-browser.yml
4552
with:
4653
ref: ${{ inputs.ref || github.ref }}
4754
browser-target: ${{ inputs.latest-only == true && 'edge@latest' || 'edge@*' }}
55+
concurrency: ${{ inputs.boosted == true && 20 || 10 }}
4856
secrets: inherit
4957

5058
ios:
@@ -53,6 +61,7 @@ jobs:
5361
ref: ${{ inputs.ref || github.ref }}
5462
browser-target: ${{ inputs.latest-only == true && 'ios@latest' || 'ios@*' }}
5563
additional-flags: --timeout 120000 --session-timeout 240000
64+
concurrency: ${{ inputs.boosted == true && 20 || 10 }}
5665
secrets: inherit
5766

5867
android:
@@ -61,6 +70,7 @@ jobs:
6170
ref: ${{ inputs.ref || github.ref }}
6271
browser-target: ${{ inputs.latest-only == true && 'android@latest' || 'android@*' }}
6372
additional-flags: --timeout 120000 --session-timeout 240000
73+
concurrency: ${{ inputs.boosted == true && 20 || 10 }}
6474
secrets: inherit
6575

6676
ios-webview:

docs/warning-codes.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
### 47
9797
`We tried to access a stylesheet's contents but failed due to browser security. For best results, ensure that cross-domain CSS assets are decorated with "crossorigin='anonymous'" attribution or are otherwise publicly accessible.`
9898
### 48
99-
`Supplied an invalid API target. Must be an <Object> that contains licenseKey and applicationID properties.`
99+
`Supplied an invalid API target. Must be an <Object> that contains id and name properties.`
100100
### 49
101101
`Supplied API target is missing an entityGuid. Some APIs may not behave correctly without a valid entityGuid (ex. logs).`
102102
### 50
@@ -129,4 +129,3 @@
129129
`A single event was larger than the maximum allowed payload size`
130130
### 64
131131
`Required globals have been mutated before being accessed by the browser agent. This can cause issues and should be avoided.`
132-

src/common/config/init-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @property {Object} [metrics]
3636
* @property {boolean} [metrics.enabled] - Turn on/off the metrics feature (on by default).
3737
* @property {boolean} [metrics.autoStart] - If true, the agent will automatically start the metrics feature. Otherwise, it will be in a deferred state until the `start` API method is called.
38-
* @property {Array<Object>} [obfuscate] - Array of regexp and corresponding replacement patterns for obfuscating data.
38+
* @property {{regex: RegExp | string, replacement: string}[]} [obfuscate] - Array of regexp and corresponding replacement patterns for obfuscating data.
3939
* @property {Object} [page_action]
4040
* @property {boolean} [page_action.enabled] - Must be true to allow PageAction events to be captured.
4141
* @property {Object} [page_view_event]

src/common/config/init.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const InitModelFn = () => {
2121
const hiddenState = {
2222
feature_flags: [],
2323
experimental: {
24+
allow_registered_children: false,
2425
resources: false
2526
},
2627
mask_selector: '*',
@@ -48,7 +49,8 @@ const InitModelFn = () => {
4849
return {
4950
ajax: { deny_list: undefined, block_internal: true, enabled: true, autoStart: true },
5051
api: {
51-
allow_registered_children: true,
52+
get allow_registered_children () { return hiddenState.feature_flags.includes(FEATURE_FLAGS.REGISTER) || hiddenState.experimental.allow_registered_children },
53+
set allow_registered_children (val) { hiddenState.experimental.allow_registered_children = val },
5254
duplicate_registered_data: false
5355
},
5456
distributed_tracing: {

src/common/config/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const RuntimeModel = {
2525
customTransaction: undefined,
2626
denyList: undefined,
2727
disabled: false,
28-
entityManager: undefined,
2928
harvester: undefined,
3029
isolatedBacklog: false,
3130
isRecording: false, // true when actively recording, false when paused or stopped
@@ -37,6 +36,7 @@ const RuntimeModel = {
3736
releaseIds: {},
3837
session: undefined,
3938
timeKeeper: undefined,
39+
registeredEntities: [],
4040
/** a proxy is set in agent-session to track jsAttributes changes for harvesting mechanics */
4141
jsAttributesMetadata: { bytes: 0 },
4242
get harvestCount () { return ++_harvestCount }

src/common/constants/agent-constants.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5+
import { FEATURE_NAMES } from '../../loaders/features/features'
6+
57
export const IDEAL_PAYLOAD_SIZE = 16000
68
export const MAX_PAYLOAD_SIZE = 1000000
79
export const DEFAULT_KEY = 'NR_CONTAINER_AGENT'
810
export const SESSION_ERROR = 'SESSION_ERROR'
11+
12+
export const SUPPORTS_REGISTERED_ENTITIES = {
13+
[FEATURE_NAMES.logging]: true,
14+
// flip other features here when they are supported by DEM consumers
15+
[FEATURE_NAMES.genericEvents]: false,
16+
[FEATURE_NAMES.jserrors]: false,
17+
[FEATURE_NAMES.ajax]: false
18+
}

src/common/drain/drain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function drainGroup (agentIdentifier, group, activateGroup = true) {
123123

124124
if (!baseEE.isolatedBacklog) delete handlers[group]
125125
baseEE.backlog[group] = null
126-
baseEE.emit('drain-' + group, []) // TODO: Code exists purely for a unit test and needs to be refined
126+
baseEE.emit('drain-' + group, []) // Informs the feature that it has drained its backlog of events, this kicks off an immediate harvest to capture any load-driven events that were buffered.
127127
}
128128

129129
/**

0 commit comments

Comments
 (0)