Skip to content

Commit 3e8c644

Browse files
chore: generate test log data to registered entities (#1608)
1 parent 8bc153a commit 3e8c644

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,38 @@ try {
141141
}
142142
} catch (e) {
143143
newrelic.noticeError(new Error("NRBA: swallowed preamble error", { cause: e }));
144-
}
144+
}
145+
146+
// MFE API Registration Testing
147+
try {
148+
if (!!newrelic && !!newrelic.register) {
149+
// Generate random ID between 1-3
150+
const randomId = Math.floor(Math.random() * 3) + 1;
151+
const mfeName = `MOCK_MFE_${randomId}`;
152+
153+
// Register the MFE API
154+
const mfeApi = newrelic.register({ id: randomId, name: mfeName });
155+
156+
// Generate a random sentence for logging
157+
const randomSentences = [
158+
'This is a test log message from the registered MFE',
159+
'MFE logging functionality is working correctly',
160+
'Random simulation for testing purposes',
161+
'Demonstrating registered entity log capabilities',
162+
'Testing MFE API integration with New Relic',
163+
'Sample log from micro frontend',
164+
'Validating registered entity reporting',
165+
'MFE diagnostic message for debugging',
166+
'Testing cross-entity logging functionality',
167+
'Random MFE log event for validation'
168+
];
169+
const randomSentence = randomSentences[Math.floor(Math.random() * randomSentences.length)];
170+
171+
// Call log with error level
172+
mfeApi.log(randomSentence, { level: 'error' });
173+
}
174+
} catch (e) {
175+
if (!!newrelic && !!newrelic.noticeError) {
176+
newrelic.noticeError(new Error("NRBA: MFE registration error", { cause: e }));
177+
}
178+
}

0 commit comments

Comments
 (0)