Skip to content

feat: Automatically Detect MFE AJAX#1722

Merged
metal-messiah merged 18 commits into
mainfrom
mfe-auto-ajax
Mar 24, 2026
Merged

feat: Automatically Detect MFE AJAX#1722
metal-messiah merged 18 commits into
mainfrom
mfe-auto-ajax

Conversation

@metal-messiah

@metal-messiah metal-messiah commented Mar 12, 2026

Copy link
Copy Markdown
Member

Add support for automatic Micro Frontend (MFE) attribution of AjaxRequest events. Previously, AjaxRequest events were only ever captured globally by the container browser application. With this change, the agent cross-compares the call stack signature of the AJAX call to the call stack signature of the MFE module that registered with the register API. If the file that is responsible for registering with the browser agent is found in the call stack signature of the AJAX request being triggered, that event will be attributed to the MFE instead of the container.


Overview

Split from #1706

Line by line in the trace, If any file path in the call stack of the AJAX executor contains a match to the file path captured during use of the .register API, the event is captured as belonging to that MFE.

Logic is included to support reporting to both the MFE and the container application if the duplication configuration is enabled.

Testing

The vite-react-mfe test build is a great example app that implements the register API and supplies the correct set ups to replicate the behaviors across the auto-MFE PRs. See the new e2e and jest tests around this new behavior and play around with that vite build to see this in action.

@github-actions

Copy link
Copy Markdown

Supportability Metric Usage Changes:

No matching changes found

Supportability Metrics .md File Changes:

supportability_metrics.md was changed? false

New supportability metrics require changes to supportability_metrics.md, as well as a new PR to Angler. Please ensure an Angler PR is created and linked to this PR.

@github-actions

github-actions Bot commented Mar 12, 2026

Copy link
Copy Markdown

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 26.55 kB / 10.06 kB (gzip) 26.55 kB / 10.06 kB (gzip) 0% / -0.02% (gzip)
lite async-chunk 55.07 kB / 18.52 kB (gzip) 55.07 kB / 18.52 kB (gzip) 0% / 0% (gzip)
pro loader 62.4 kB / 21.93 kB (gzip) 63.17 kB / 22.24 kB (gzip) 1.23% / 1.43% (gzip)
pro async-chunk 91.24 kB / 28.92 kB (gzip) 91.51 kB / 28.98 kB (gzip) 0.29% / 0.22% (gzip)
spa loader 64.8 kB / 22.73 kB (gzip) 65.57 kB / 23.09 kB (gzip) 1.18% / 1.56% (gzip)
spa async-chunk 102.46 kB / 31.77 kB (gzip) 102.77 kB / 31.85 kB (gzip) 0.31% / 0.24% (gzip)

@codecov

codecov Bot commented Mar 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.08108% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.74%. Comparing base (847b6a7) to head (d145b55).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/features/ajax/instrument/index.js 40.00% 6 Missing ⚠️
src/loaders/api/register.js 42.85% 4 Missing ⚠️
src/common/util/v2.js 86.95% 2 Missing and 1 partial ⚠️
src/common/wrap/wrap-fetch.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1722   +/-   ##
=======================================
  Coverage   88.74%   88.74%           
=======================================
  Files         210      209    -1     
  Lines        7567     7598   +31     
  Branches     1559     1599   +40     
=======================================
+ Hits         6715     6743   +28     
- Misses        759      761    +2     
- Partials       93       94    +1     
Flag Coverage Δ
unit-tests 82.47% <81.08%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@metal-messiah metal-messiah changed the title feat: Automatically detect MFE AJAX feat: Automatically Detect MFE AJAX Mar 13, 2026
@metal-messiah metal-messiah marked this pull request as ready for review March 16, 2026 15:04
@github-actions

github-actions Bot commented Mar 16, 2026

Copy link
Copy Markdown

Static Badge

Last ran on March 17, 2026 10:11:24 CDT
Checking merge of (dccdc6a) into main (76024d0)

ptang-nr
ptang-nr previously approved these changes Mar 20, 2026

@ptang-nr ptang-nr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed to the best of my abilities. Might be good to get another set of eyes.

Comment thread src/common/util/v2.js Outdated
Comment thread src/loaders/api/register.js Outdated
Comment thread tests/specs/api/register/test-helpers.js
Comment thread tests/specs/api/register/test-helpers.js
Co-authored-by: ptang-nr <ptang@newrelic.com>
Comment thread src/common/constants/agent-constants.js
Comment thread src/common/util/v2.js Outdated
Comment thread src/common/util/v2.js Outdated
Comment thread src/common/wrap/wrap-fetch.js Outdated
Comment thread src/common/wrap/wrap-xhr.js Outdated
Comment thread src/features/ajax/instrument/index.js Outdated
Comment thread src/features/ajax/instrument/index.js Outdated
Comment thread src/features/ajax/aggregate/index.js Outdated
Comment thread src/loaders/api/register.js Outdated
metal-messiah and others added 2 commits March 23, 2026 12:14
Co-authored-by: Chunwai Li <cli@newrelic.com>
Co-authored-by: Chunwai Li <cli@newrelic.com>

@cwli24 cwli24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@metal-messiah metal-messiah merged commit ed8e90c into main Mar 24, 2026
24 of 25 checks passed
@metal-messiah metal-messiah deleted the mfe-auto-ajax branch March 24, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants