Skip to content

Commit 1f7a449

Browse files
chore: remove unneeded mfe mocks (#1777)
1 parent b49d2f4 commit 1f7a449

2 files changed

Lines changed: 0 additions & 262 deletions

File tree

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

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -9,137 +9,6 @@ window.NREUM.init.session_replay.enabled = true
99
window.NREUM.init.session_trace.enabled = true
1010
window.NREUM.init.user_actions = { elementAttributes: ['id', 'className', 'tagName', 'type', 'ariaLabel', 'alt', 'title'] }
1111

12-
// MFE API Registration Testing
13-
try {
14-
if (!!newrelic && !!newrelic.register) {
15-
// Generate random ID between 1-3
16-
const randomId = String(Math.floor(Math.random() * 3) + 1);
17-
const mfeName = `MOCK_MFE_${randomId}`;
18-
19-
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms))
20-
21-
for (let agentIdentifier in newrelic.initializedAgents) {
22-
const MfeToMfeParent = newrelic.initializedAgents[agentIdentifier].register({
23-
id: 'mfe-to-mfe-parent',
24-
name: 'MFE_TEST_PARENT',
25-
tags: { isParent: true, nested: true, dataTypes: 'all' }
26-
})
27-
28-
const MfeToMfeChild = newrelic.initializedAgents[agentIdentifier].register({
29-
id: 'mfe-to-mfe-child',
30-
name: 'MFE_TEST_CHILD',
31-
tags: { isChild: true, isParent: true, nested: true, dataTypes: 'all' },
32-
parent: MfeToMfeParent.metadata.target
33-
})
34-
35-
const MfeToMfeGrandchild = newrelic.initializedAgents[agentIdentifier].register({
36-
id: 'mfe-to-mfe-grandchild',
37-
name: 'MFE_TEST_GRANDCHILD',
38-
tags: { isChild: true, isParent: false, nested: true, dataTypes: 'all' },
39-
parent: MfeToMfeChild.metadata.target
40-
})
41-
42-
const jseOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
43-
id: 'jse-only-mfe',
44-
name: 'JSE_ONLY_MFE',
45-
tags: { isParent: false, isChild: false, dataTypes: 'errors' }
46-
})
47-
jseOnlyMfe.noticeError(new Error('NRBA: This is a test error from JSE_ONLY_MFE'));
48-
49-
const pageActionOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
50-
id: 'page-action-only-mfe',
51-
name: 'PAGE_ACTION_ONLY_MFE',
52-
tags: { isParent: false, isChild: false, dataTypes: 'page actions' }
53-
})
54-
pageActionOnlyMfe.addPageAction('TestPageAction', { message: 'This is a test page action from PAGE_ACTION_ONLY_MFE' });
55-
56-
const customEventOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
57-
id: 'custom-event-only-mfe',
58-
name: 'CUSTOM_EVENT_ONLY_MFE',
59-
tags: { isParent: false, isChild: false, dataTypes: 'custom events' }
60-
})
61-
customEventOnlyMfe.recordCustomEvent('TestCustomEvent', { message: 'This is a test custom event from CUSTOM_EVENT_ONLY_MFE' });
62-
63-
const measuresOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
64-
id: 'measures-only-mfe',
65-
name: 'MEASURES_ONLY_MFE',
66-
tags: { isParent: false, isChild: false, dataTypes: 'measures' }
67-
})
68-
measuresOnlyMfe.measure('TestMeasure');
69-
70-
const timingsTestMfe = newrelic.initializedAgents[agentIdentifier].register({
71-
id: 'timings-test-mfe',
72-
name: 'TIMINGS_TEST_MFE',
73-
tags: { isParent: false, isChild: false, dataTypes: 'micro frontend timings' }
74-
})
75-
setTimeout(() => timingsTestMfe.deregister(), 100)
76-
77-
// 5000ms timing test - runs independently
78-
;(async () => {
79-
await wait(5000)
80-
const fiveThousandMfe = newrelic.initializedAgents[agentIdentifier].register({
81-
id: '5000-mfe',
82-
name: 'FIVE_THOUSAND_MFE',
83-
tags: { isParent: false, isChild: false, dataTypes: 'micro frontend timings' }
84-
})
85-
await wait(5000)
86-
fiveThousandMfe.deregister()
87-
})()
88-
89-
// 10000ms timing test - runs independently
90-
;(async () => {
91-
await wait(10000)
92-
const tenThousandMfe = newrelic.initializedAgents[agentIdentifier].register({
93-
id: '10000-mfe',
94-
name: 'TEN_THOUSAND_MFE',
95-
tags: { isParent: false, isChild: false, dataTypes: 'micro frontend timings' }
96-
})
97-
await wait(10000)
98-
tenThousandMfe.deregister()
99-
})()
100-
101-
// Register the MFE API
102-
const mfeApi = newrelic.initializedAgents[agentIdentifier].register({ id: randomId, name: mfeName, tags: { isParent: false, isChild: false, dataTypes: 'all' } });
103-
104-
// Generate a random sentence for logging
105-
const randomSentences = [
106-
'This is a test log message from the registered MFE',
107-
'MFE logging functionality is working correctly',
108-
'Random simulation for testing purposes',
109-
'Demonstrating registered entity log capabilities',
110-
'Testing MFE API integration with New Relic',
111-
'Sample log from micro frontend',
112-
'Validating registered entity reporting',
113-
'MFE diagnostic message for debugging',
114-
'Testing cross-entity logging functionality',
115-
'Random MFE log event for validation'
116-
];
117-
const randomSentence = randomSentences[Math.floor(Math.random() * randomSentences.length)];
118-
119-
// Call log with error level
120-
mfeApi.log(randomSentence, { level: 'error' });
121-
mfeApi.noticeError(new Error(`NRBA: This is a test error from ${mfeName}`));
122-
mfeApi.addPageAction('TestPageAction', { message: `This is a test page action from ${mfeName}` });
123-
124-
MfeToMfeParent.log('This is a test log from MFE_TO_MFE_PARENT', { level: 'error' });
125-
MfeToMfeChild.log('This is a test log from MFE_TO_MFE_CHILD', { level: 'error' });
126-
MfeToMfeGrandchild.log('This is a test log from MFE_TO_MFE_GRANDCHILD', { level: 'error' });
127-
128-
MfeToMfeParent.noticeError(new Error('NRBA: This is a test error from MFE_TO_MFE_PARENT'));
129-
MfeToMfeChild.noticeError(new Error('NRBA: This is a test error from MFE_TO_MFE_CHILD'));
130-
MfeToMfeGrandchild.noticeError(new Error('NRBA: This is a test error from MFE_TO_MFE_GRANDCHILD'));
131-
132-
MfeToMfeParent.addPageAction('TestPageAction', { message: 'This is a test page action from MFE_TO_MFE_PARENT' });
133-
MfeToMfeChild.addPageAction('TestPageAction', { message: 'This is a test page action from MFE_TO_MFE_CHILD' });
134-
MfeToMfeGrandchild.addPageAction('TestPageAction', { message: 'This is a test page action from MFE_TO_MFE_GRANDCHILD' });
135-
}
136-
}
137-
} catch (e) {
138-
if (!!newrelic && !!newrelic.noticeError) {
139-
newrelic.noticeError(new Error("NRBA: MFE registration error", { cause: e }));
140-
}
141-
}
142-
14312
// Session replay entitlements check
14413
try {
14514
var xhr = new XMLHttpRequest()

.github/actions/internal-promotion/templates/postamble.js

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -9,137 +9,6 @@ window.NREUM.init.session_replay.enabled = true
99
window.NREUM.init.session_trace.enabled = true
1010
window.NREUM.init.user_actions = { elementAttributes: ['id', 'className', 'tagName', 'type', 'ariaLabel', 'alt', 'title'] }
1111

12-
// MFE API Registration Testing
13-
try {
14-
if (!!newrelic && !!newrelic.register) {
15-
// Generate random ID between 1-3
16-
const randomId = String(Math.floor(Math.random() * 3) + 1);
17-
const mfeName = `MOCK_MFE_${randomId}`;
18-
19-
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms))
20-
21-
for (let agentIdentifier in newrelic.initializedAgents) {
22-
const MfeToMfeParent = newrelic.initializedAgents[agentIdentifier].register({
23-
id: 'mfe-to-mfe-parent',
24-
name: 'MFE_TEST_PARENT',
25-
tags: { isParent: true, nested: true, dataTypes: 'all' }
26-
})
27-
28-
const MfeToMfeChild = newrelic.initializedAgents[agentIdentifier].register({
29-
id: 'mfe-to-mfe-child',
30-
name: 'MFE_TEST_CHILD',
31-
tags: { isChild: true, isParent: true, nested: true, dataTypes: 'all' },
32-
parent: MfeToMfeParent.metadata.target
33-
})
34-
35-
const MfeToMfeGrandchild = newrelic.initializedAgents[agentIdentifier].register({
36-
id: 'mfe-to-mfe-grandchild',
37-
name: 'MFE_TEST_GRANDCHILD',
38-
tags: { isChild: true, isParent: false, nested: true, dataTypes: 'all' },
39-
parent: MfeToMfeChild.metadata.target
40-
})
41-
42-
const jseOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
43-
id: 'jse-only-mfe',
44-
name: 'JSE_ONLY_MFE',
45-
tags: { isParent: false, isChild: false, dataTypes: 'errors' }
46-
})
47-
jseOnlyMfe.noticeError(new Error('NRBA: This is a test error from JSE_ONLY_MFE'));
48-
49-
const pageActionOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
50-
id: 'page-action-only-mfe',
51-
name: 'PAGE_ACTION_ONLY_MFE',
52-
tags: { isParent: false, isChild: false, dataTypes: 'page actions' }
53-
})
54-
pageActionOnlyMfe.addPageAction('TestPageAction', { message: 'This is a test page action from PAGE_ACTION_ONLY_MFE' });
55-
56-
const customEventOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
57-
id: 'custom-event-only-mfe',
58-
name: 'CUSTOM_EVENT_ONLY_MFE',
59-
tags: { isParent: false, isChild: false, dataTypes: 'custom events' }
60-
})
61-
customEventOnlyMfe.recordCustomEvent('TestCustomEvent', { message: 'This is a test custom event from CUSTOM_EVENT_ONLY_MFE' });
62-
63-
const measuresOnlyMfe = newrelic.initializedAgents[agentIdentifier].register({
64-
id: 'measures-only-mfe',
65-
name: 'MEASURES_ONLY_MFE',
66-
tags: { isParent: false, isChild: false, dataTypes: 'measures' }
67-
})
68-
measuresOnlyMfe.measure('TestMeasure');
69-
70-
const timingsTestMfe = newrelic.initializedAgents[agentIdentifier].register({
71-
id: 'timings-test-mfe',
72-
name: 'TIMINGS_TEST_MFE',
73-
tags: { isParent: false, isChild: false, dataTypes: 'micro frontend timings' }
74-
})
75-
setTimeout(() => timingsTestMfe.deregister(), 100)
76-
77-
// 5000ms timing test - runs independently
78-
;(async () => {
79-
await wait(5000)
80-
const fiveThousandMfe = newrelic.initializedAgents[agentIdentifier].register({
81-
id: '5000-mfe',
82-
name: 'FIVE_THOUSAND_MFE',
83-
tags: { isParent: false, isChild: false, dataTypes: 'micro frontend timings' }
84-
})
85-
await wait(5000)
86-
fiveThousandMfe.deregister()
87-
})()
88-
89-
// 10000ms timing test - runs independently
90-
;(async () => {
91-
await wait(10000)
92-
const tenThousandMfe = newrelic.initializedAgents[agentIdentifier].register({
93-
id: '10000-mfe',
94-
name: 'TEN_THOUSAND_MFE',
95-
tags: { isParent: false, isChild: false, dataTypes: 'micro frontend timings' }
96-
})
97-
await wait(10000)
98-
tenThousandMfe.deregister()
99-
})()
100-
101-
// Register the MFE API
102-
const mfeApi = newrelic.initializedAgents[agentIdentifier].register({ id: randomId, name: mfeName, tags: { isParent: false, isChild: false, dataTypes: 'all' } });
103-
104-
// Generate a random sentence for logging
105-
const randomSentences = [
106-
'This is a test log message from the registered MFE',
107-
'MFE logging functionality is working correctly',
108-
'Random simulation for testing purposes',
109-
'Demonstrating registered entity log capabilities',
110-
'Testing MFE API integration with New Relic',
111-
'Sample log from micro frontend',
112-
'Validating registered entity reporting',
113-
'MFE diagnostic message for debugging',
114-
'Testing cross-entity logging functionality',
115-
'Random MFE log event for validation'
116-
];
117-
const randomSentence = randomSentences[Math.floor(Math.random() * randomSentences.length)];
118-
119-
// Call log with error level
120-
mfeApi.log(randomSentence, { level: 'error' });
121-
mfeApi.noticeError(new Error(`NRBA: This is a test error from ${mfeName}`));
122-
mfeApi.addPageAction('TestPageAction', { message: `This is a test page action from ${mfeName}` });
123-
124-
MfeToMfeParent.log('This is a test log from MFE_TO_MFE_PARENT', { level: 'error' });
125-
MfeToMfeChild.log('This is a test log from MFE_TO_MFE_CHILD', { level: 'error' });
126-
MfeToMfeGrandchild.log('This is a test log from MFE_TO_MFE_GRANDCHILD', { level: 'error' });
127-
128-
MfeToMfeParent.noticeError(new Error('NRBA: This is a test error from MFE_TO_MFE_PARENT'));
129-
MfeToMfeChild.noticeError(new Error('NRBA: This is a test error from MFE_TO_MFE_CHILD'));
130-
MfeToMfeGrandchild.noticeError(new Error('NRBA: This is a test error from MFE_TO_MFE_GRANDCHILD'));
131-
132-
MfeToMfeParent.addPageAction('TestPageAction', { message: 'This is a test page action from MFE_TO_MFE_PARENT' });
133-
MfeToMfeChild.addPageAction('TestPageAction', { message: 'This is a test page action from MFE_TO_MFE_CHILD' });
134-
MfeToMfeGrandchild.addPageAction('TestPageAction', { message: 'This is a test page action from MFE_TO_MFE_GRANDCHILD' });
135-
}
136-
}
137-
} catch (e) {
138-
if (!!newrelic && !!newrelic.noticeError) {
139-
newrelic.noticeError(new Error("NRBA: MFE registration error", { cause: e }));
140-
}
141-
}
142-
14312
// Session replay entitlements check
14413
try {
14514
var xhr = new XMLHttpRequest()

0 commit comments

Comments
 (0)