Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Capture metrics for usage of MooTools and certain polyfills #539

Merged
merged 7 commits into from
May 25, 2023

Conversation

patrickhousley
Copy link
Contributor

@patrickhousley patrickhousley commented May 23, 2023

New supportability metrics have been added to capture MooTools library usage and presence of customer-defined polyfills for certain native JavaScript features, such as function binding and ES6 Array prototype methods.

Overview

  • Moved the framework-detection script into the metrics aggregator folder since that is the only place it is used.
  • Added mootools detection to the framework-detection script.
  • Added a new script to detect polyfills for ES6+ globals and natives that we commonly rely upon within the agent.
    • The polyfills script will be overwritten in the ES5 webpack build so an empty array is always returned. This is because the usage of that build includes all the polyfills we are checking for. It seems redundant to report on the polyfills we supply with the ES5 build.

Related Issue(s)

https://issues.newrelic.com/browse/NR-119275

Testing

Build the agent and start the local test server. The test server already has a few pages for the different frameworks to demonstrate the framework supportability metrics.

The easiest way to test the polyfill metrics is to disable the file swap for the ES5 build in babel.config.js and rebuild the agent. Launch the test server and use IE11 in SauceLabs to test the polyfill metrics.

@github-actions
Copy link

github-actions bot commented May 23, 2023

Asset Size Report

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

Asset Name Previous Size New Size Diff
nr-loader-spa.min 52.09 kB / 17.78 kB (gzip) 52.09 kB / 17.78 kB (gzip) -0% / -0% (gzip)
nr-loader-full.min 46.17 kB / 15.99 kB (gzip) 46.17 kB / 15.99 kB (gzip) -0% / -0% (gzip)
nr-loader-rum.min 27.36 kB / 10.07 kB (gzip) 27.36 kB / 10.07 kB (gzip) -0% / +0.01% (gzip)
nr-loader-spa-polyfills.min 118.49 kB / 39.15 kB (gzip) 118.49 kB / 39.15 kB (gzip) -0% / -0.01% (gzip)
nr-loader-full-polyfills.min 111.75 kB / 37.26 kB (gzip) 111.75 kB / 37.26 kB (gzip) -0% / -0% (gzip)
nr-loader-rum-polyfills.min 90.84 kB / 30.91 kB (gzip) 90.84 kB / 30.91 kB (gzip) -0% / -0% (gzip)
nr-loader-worker.min 42.23 kB / 14.65 kB (gzip) 42.23 kB / 14.65 kB (gzip) -0% / -0.01% (gzip)

Merging this pull request will result in the following NPM package consumer size changes:

Asset Name Previous Size New Size Diff
Browser Agent 52.16 kB / 17.65 kB (gzip) 52.16 kB / 17.65 kB (gzip) -0% / -0% (gzip)
Custom Lite Agent 27.45 kB / 9.99 kB (gzip) 27.45 kB / 9.99 kB (gzip) -0% / -0% (gzip)
Custom Pro Agent 46.16 kB / 15.8 kB (gzip) 46.16 kB / 15.8 kB (gzip) -0% / -0% (gzip)
Custom SPA Agent 52.04 kB / 17.63 kB (gzip) 52.04 kB / 17.63 kB (gzip) -0% / -0% (gzip)
Worker Agent 300.38 kB / 93.51 kB (gzip) 302.15 kB / 93.77 kB (gzip) +0.59% / +0.27% (gzip)
Other Standard CDN Assets

Released Assets

Asset Name Asset Size
recorder.b9a5173b.min.js 166.07 kB / 52.31 kB (gzip)
spa-aggregate.ec1a70de.min.js 18.62 kB / 6.63 kB (gzip)
286.a2dfc50f.min.js 13.98 kB / 5.2 kB (gzip)
page_view_timing-aggregate.ddd91465.min.js 12.7 kB / 4.64 kB (gzip)
page_view_event-aggregate.edc9f963.min.js 11.25 kB / 4.2 kB (gzip)
875.feb6e14a.min.js 10.1 kB / 4.07 kB (gzip)
session_trace-aggregate.d4b3966c.min.js 8.11 kB / 3.07 kB (gzip)
compressor.92c94011.min.js 7.09 kB / 3.57 kB (gzip)
jserrors-aggregate.cb5045c7.min.js 7.07 kB / 2.75 kB (gzip)
ajax-aggregate.666f66ea.min.js 4.81 kB / 2.22 kB (gzip)
session_replay-aggregate.584320be.min.js 4.53 kB / 1.77 kB (gzip)
metrics-aggregate.2220dad8.min.js 4.39 kB / 1.72 kB (gzip)
async-api.288afefe.min.js 3 kB / 1.49 kB (gzip)
page_action-aggregate.aef67c05.min.js 2.42 kB / 1.05 kB (gzip)
session-manager.677b9b5a.min.js 2.23 kB / 1.03 kB (gzip)
lazy-feature-loader.4ee5b7c2.min.js 1.11 kB / 494 B (gzip)

Built Assets

Asset Name Asset Size
recorder.b9a5173b.min.js 166.07 kB / 52.31 kB (gzip)
spa-aggregate.ec1a70de.min.js 18.62 kB / 6.63 kB (gzip)
286.a2dfc50f.min.js 13.98 kB / 5.2 kB (gzip)
page_view_timing-aggregate.ddd91465.min.js 12.7 kB / 4.64 kB (gzip)
page_view_event-aggregate.edc9f963.min.js 11.25 kB / 4.2 kB (gzip)
875.feb6e14a.min.js 10.1 kB / 4.07 kB (gzip)
session_trace-aggregate.d4b3966c.min.js 8.11 kB / 3.07 kB (gzip)
compressor.92c94011.min.js 7.09 kB / 3.57 kB (gzip)
jserrors-aggregate.cb5045c7.min.js 7.07 kB / 2.75 kB (gzip)
metrics-aggregate.80e5be98.min.js 6.22 kB / 2.06 kB (gzip)
ajax-aggregate.666f66ea.min.js 4.81 kB / 2.22 kB (gzip)
session_replay-aggregate.584320be.min.js 4.53 kB / 1.77 kB (gzip)
async-api.288afefe.min.js 3 kB / 1.49 kB (gzip)
page_action-aggregate.aef67c05.min.js 2.42 kB / 1.05 kB (gzip)
session-manager.677b9b5a.min.js 2.23 kB / 1.03 kB (gzip)
lazy-feature-loader.25ca4880.min.js 1.11 kB / 495 B (gzip)
Other Polyfill CDN Assets

Released Assets

Asset Name Asset Size
recorder.b9a5173b-es5.min.js 166.76 kB / 52.35 kB (gzip)
nr-polyfills.min.js 52.15 kB / 17.96 kB (gzip)
compressor.39f21c15-es5.min.js 30.02 kB / 11.29 kB (gzip)
spa-aggregate.a2d4bd8d-es5.min.js 19.54 kB / 6.79 kB (gzip)
286.22d28761-es5.min.js 15.76 kB / 5.75 kB (gzip)
page_view_timing-aggregate.0b0f7c19-es5.min.js 13.43 kB / 4.8 kB (gzip)
875.d47c7b61-es5.min.js 12.55 kB / 4.83 kB (gzip)
session_replay-aggregate.4e039289-es5.min.js 12.53 kB / 4.6 kB (gzip)
page_view_event-aggregate.6ec43f65-es5.min.js 11.67 kB / 4.3 kB (gzip)
session_trace-aggregate.a193d3bf-es5.min.js 9.64 kB / 3.49 kB (gzip)
jserrors-aggregate.9b9e9ab4-es5.min.js 7.66 kB / 2.95 kB (gzip)
ajax-aggregate.f4dab427-es5.min.js 5.3 kB / 2.36 kB (gzip)
metrics-aggregate.85a6e71c-es5.min.js 4.92 kB / 1.93 kB (gzip)
async-api.fc5fff8e-es5.min.js 3.07 kB / 1.5 kB (gzip)
page_action-aggregate.357c95d1-es5.min.js 2.84 kB / 1.23 kB (gzip)
session-manager.e66d8dc1-es5.min.js 2.41 kB / 1.06 kB (gzip)
lazy-feature-loader.2734493f-es5.min.js 1.14 kB / 506 B (gzip)

Built Assets

Asset Name Asset Size
recorder.b9a5173b-es5.min.js 166.76 kB / 52.35 kB (gzip)
nr-polyfills.min.js 52.15 kB / 17.96 kB (gzip)
compressor.39f21c15-es5.min.js 30.02 kB / 11.29 kB (gzip)
spa-aggregate.a2d4bd8d-es5.min.js 19.54 kB / 6.79 kB (gzip)
286.22d28761-es5.min.js 15.76 kB / 5.75 kB (gzip)
page_view_timing-aggregate.0b0f7c19-es5.min.js 13.43 kB / 4.8 kB (gzip)
875.d47c7b61-es5.min.js 12.55 kB / 4.83 kB (gzip)
session_replay-aggregate.4e039289-es5.min.js 12.53 kB / 4.6 kB (gzip)
page_view_event-aggregate.6ec43f65-es5.min.js 11.67 kB / 4.3 kB (gzip)
session_trace-aggregate.a193d3bf-es5.min.js 9.64 kB / 3.49 kB (gzip)
jserrors-aggregate.9b9e9ab4-es5.min.js 7.66 kB / 2.95 kB (gzip)
metrics-aggregate.35f401a9-es5.min.js 5.4 kB / 1.93 kB (gzip)
ajax-aggregate.f4dab427-es5.min.js 5.3 kB / 2.36 kB (gzip)
async-api.fc5fff8e-es5.min.js 3.07 kB / 1.5 kB (gzip)
page_action-aggregate.357c95d1-es5.min.js 2.84 kB / 1.23 kB (gzip)
session-manager.e66d8dc1-es5.min.js 2.41 kB / 1.06 kB (gzip)
lazy-feature-loader.56c21909-es5.min.js 1.14 kB / 507 B (gzip)

@bjfield bjfield changed the title feat: adding mootools and polyfill supportability metrics feat: Capture metrics for usage of MooTools and certain polyfills May 24, 2023
Copy link
Contributor

@bjfield bjfield left a comment

Choose a reason for hiding this comment

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

By testing I've verified that the agent now identifies all the specified polyfills, as well as MooTools (1.5.1 nocompat and 1.6.0 nocompat). We can't know how many pages use incompatible MooTools builds because the agent breaks before it can capture the SM, but this does give us some idea of the relative popularity of compatible MooTools. In conjunction with other metrics sources about usage of frameworks, we may be able to extrapolate what percentage of MooTools instrumentation we aren't seeing due to breakage of our agent. E.g. MooTools is A% as popular as JQuery but we see only B% as much of MooTools as JQuery. Similarly, the polyfill metrics tell us how many non-breaking polyfill instances we run into, but not the instances that break our agent. Just noting these known limitations.

@codecov-commenter
Copy link

Codecov Report

Merging #539 (04f0688) into main (1ee675d) will increase coverage by 1.25%.
The diff coverage is 92.30%.

@@            Coverage Diff             @@
##             main     #539      +/-   ##
==========================================
+ Coverage   18.78%   20.03%   +1.25%     
==========================================
  Files         130      132       +2     
  Lines        4318     4347      +29     
  Branches     1089     1109      +20     
==========================================
+ Hits          811      871      +60     
+ Misses       2759     2745      -14     
+ Partials      748      731      -17     
Impacted Files Coverage Δ
src/features/metrics/aggregate/index.js 0.00% <0.00%> (ø)
.../features/metrics/aggregate/framework-detection.js 92.30% <92.30%> (ø)
...atures/metrics/aggregate/polyfill-detection.es5.js 100.00% <100.00%> (ø)
...c/features/metrics/aggregate/polyfill-detection.js 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@patrickhousley
Copy link
Contributor Author

Test run passes except Safari 15.

@patrickhousley patrickhousley merged commit 903a7e1 into main May 25, 2023
@patrickhousley patrickhousley deleted the mootools-support-metrics branch May 25, 2023 16:17
bjfield pushed a commit that referenced this pull request May 26, 2023
* Capture metrics for usage of MooTools and certain polyfills (#539) (903a7e1)

* Update agent internals in early preparation for new features (#532) (1ee675d)

* Address "configurable" warnings arising from user-agent module (#546) (7a7dace)

* Ensure runtime is preserved for late-configuration cases (#538) (229b8ed)

* Refactor usage of Array.from to address MooTools conflict (#544) (f1e6336)
metal-messiah pushed a commit that referenced this pull request Jun 5, 2023
* Capture metrics for usage of MooTools and certain polyfills (#539) (903a7e1)

* Update agent internals in early preparation for new features (#532) (1ee675d)

* Address "configurable" warnings arising from user-agent module (#546) (7a7dace)

* Ensure runtime is preserved for late-configuration cases (#538) (229b8ed)

* Refactor usage of Array.from to address MooTools conflict (#544) (f1e6336)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants