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: Remove img, jsonp, and xhrGet methods #576

Merged
merged 39 commits into from
Jun 21, 2023
Merged

Conversation

patrickhousley
Copy link
Contributor

@patrickhousley patrickhousley commented Jun 8, 2023

Unused agent network methods have been removed. All data transmitted by the agent will now default to using XMLHttpRequest POST calls except for data transmitted during a visibility change or page unload. Visibility changes and page unloads will use sendBeacon with a fallback to fetch with keepalive. For browsers that do not support sendBeacon, the final data transmission will use XMLHttpRequest POST.

Overview

Removing the unused sendData methods jsonp, img', and xhrGet. All data will now be transmitted using XMLHttpRequestviaPOST. For browsers that support sendBeacon, the final harvest will fallback to fetchwithkeepalive: true`.

All tests for harvest.js and harvest-scheduler.js modules have been converted to Jest and WDIO. In doing so, I have created many auto-mock files in __mock__ directories. Using this style of mocking modules will let us manage the mock in a central location for each module and eventually enabled auto mocking globally for our jest unit tests.

Minor cleanup work was done with the util/global-scope.js and browser-version/*.js modules. Since these modules exported constants that were determined at runtime, I moved them into the common/constants folder into a single module. This will reduce import/require statements in the final bundle.

The pull request checks workflow has been updated to add the size check comment to PRs. The babel and ts configs have been updated so the test files and mocks do not get included in our /dist/ directory.

Related Issue(s)

Functional test conversions:

Browser test conversions:

Testing

Unit and integration tests have been updated.

@github-actions
Copy link

github-actions bot commented Jun 9, 2023

Static Badge

Last ran on June 17, 2023 14:30:21 CDT
Checking merge of (01dfb7e) into main (3d49a65)

@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Merging #576 (01dfb7e) into main (1371a53) will increase coverage by 1.58%.
The diff coverage is 92.81%.

❗ Current head 01dfb7e differs from pull request most recent head a5d54c6. Consider uploading reports for the commit a5d54c6 to get more accurate results

@@            Coverage Diff             @@
##             main     #576      +/-   ##
==========================================
+ Coverage   66.74%   68.33%   +1.58%     
==========================================
  Files         131      129       -2     
  Lines        6021     5960      -61     
  Branches     1121     1120       -1     
==========================================
+ Hits         4019     4073      +54     
+ Misses       1626     1532      -94     
+ Partials      376      355      -21     
Flag Coverage Δ
integration-tests 84.53% <89.87%> (+2.08%) ⬆️
jest-component 21.06% <38.80%> (-1.29%) ⬇️
jest-unit 22.36% <91.04%> (+4.00%) ⬆️

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

Impacted Files Coverage Δ
src/common/config/state/init.js 92.59% <ø> (+0.28%) ⬆️
src/common/config/state/runtime.js 100.00% <ø> (ø)
src/common/event-listener/event-listener-opts.js 92.00% <ø> (ø)
src/common/ids/id.js 100.00% <ø> (ø)
src/common/ids/unique-id.js 95.45% <ø> (ø)
src/common/session/session-entity.js 87.66% <ø> (ø)
src/common/timer/interaction-timer.js 91.11% <ø> (ø)
src/common/unload/eol.js 30.43% <ø> (ø)
src/common/url/canonicalize-url.js 100.00% <ø> (ø)
src/common/url/parse-url.js 93.75% <ø> (ø)
... and 35 more

... and 7 files with indirect coverage changes

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

@github-actions
Copy link

github-actions bot commented Jun 9, 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 50.86 kB / 17.31 kB (gzip) 51.02 kB / 17.32 kB (gzip) +0.33% / +0.06% (gzip)
nr-loader-full.min 44.94 kB / 15.52 kB (gzip) 45.11 kB / 15.54 kB (gzip) +0.37% / +0.12% (gzip)
nr-loader-rum.min 26.18 kB / 9.64 kB (gzip) 26.48 kB / 9.71 kB (gzip) +1.13% / +0.73% (gzip)
nr-loader-spa-polyfills.min 123.45 kB / 39.49 kB (gzip) 123.53 kB / 39.45 kB (gzip) +0.07% / -0.09% (gzip)
nr-loader-full-polyfills.min 115.97 kB / 37.54 kB (gzip) 116.05 kB / 37.51 kB (gzip) +0.07% / -0.07% (gzip)
nr-loader-rum-polyfills.min 94.31 kB / 31.21 kB (gzip) 94.55 kB / 31.23 kB (gzip) +0.26% / +0.08% (gzip)
nr-loader-worker.min 41.02 kB / 14.17 kB (gzip) 41.2 kB / 14.19 kB (gzip) +0.42% / +0.09% (gzip)

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

Asset Name Previous Size New Size Diff
Browser Agent 50.95 kB / 17.18 kB (gzip) 51.13 kB / 17.18 kB (gzip) +0.34% / +0.03% (gzip)
Custom Lite Agent 26.29 kB / 9.53 kB (gzip) 26.6 kB / 9.61 kB (gzip) +1.15% / +0.82% (gzip)
Custom Pro Agent 44.96 kB / 15.33 kB (gzip) 45.14 kB / 15.35 kB (gzip) +0.39% / +0.08% (gzip)
Custom SPA Agent 50.84 kB / 17.14 kB (gzip) 51.01 kB / 17.16 kB (gzip) +0.34% / +0.09% (gzip)
Worker Agent 302.65 kB / 93.95 kB (gzip) 302.69 kB / 93.76 kB (gzip) +0.01% / -0.2% (gzip)
Other Standard CDN Assets

Released Assets

Asset Name Asset Size
recorder.1b18459f.min.js 166.07 kB / 52.32 kB (gzip)
spa-aggregate.5c4318f2.min.js 21.06 kB / 7.49 kB (gzip)
page_view_timing-aggregate.1c78d061.min.js 15.15 kB / 5.51 kB (gzip)
860.1901dce6.min.js 14.34 kB / 5.33 kB (gzip)
session_trace-aggregate.3fd0206d.min.js 11.54 kB / 4.33 kB (gzip)
page_view_event-aggregate.a7935af6.min.js 11.08 kB / 4.18 kB (gzip)
jserrors-aggregate.dcb6ac07.min.js 9.67 kB / 3.72 kB (gzip)
metrics-aggregate.7ece083a.min.js 8.7 kB / 3.01 kB (gzip)
148.03807465.min.js 7.64 kB / 3.27 kB (gzip)
session_replay-aggregate.83969083.min.js 7.53 kB / 2.87 kB (gzip)
ajax-aggregate.09a31ca7.min.js 7.26 kB / 3.12 kB (gzip)
compressor.ae9f91a8.min.js 7.09 kB / 3.57 kB (gzip)
page_action-aggregate.af5d1c80.min.js 4.87 kB / 1.98 kB (gzip)
async-api.d1647fbb.min.js 2.97 kB / 1.48 kB (gzip)
session-manager.2a64278a.min.js 1.47 kB / 740 B (gzip)
lazy-feature-loader.0ba331d7.min.js 1.17 kB / 499 B (gzip)

Built Assets

Asset Name Asset Size
recorder.1b18459f.min.js 166.07 kB / 52.32 kB (gzip)
spa-aggregate.084ee148.min.js 20.93 kB / 7.42 kB (gzip)
page_view_timing-aggregate.ba48a30f.min.js 14.97 kB / 5.43 kB (gzip)
860.004c3391.min.js 14.34 kB / 5.33 kB (gzip)
session_trace-aggregate.4fa4b5a5.min.js 11.4 kB / 4.27 kB (gzip)
page_view_event-aggregate.b566f156.min.js 11.07 kB / 4.17 kB (gzip)
jserrors-aggregate.6787bff1.min.js 9.58 kB / 3.67 kB (gzip)
metrics-aggregate.3728fba2.min.js 8.56 kB / 2.93 kB (gzip)
148.9b104f6e.min.js 7.85 kB / 3.26 kB (gzip)
session_replay-aggregate.3c109355.min.js 7.25 kB / 2.73 kB (gzip)
ajax-aggregate.d6946c36.min.js 7.13 kB / 3.06 kB (gzip)
compressor.ae9f91a8.min.js 7.09 kB / 3.57 kB (gzip)
page_action-aggregate.5ff09456.min.js 4.73 kB / 1.92 kB (gzip)
async-api.44b145a1.min.js 2.92 kB / 1.46 kB (gzip)
session-manager.2a64278a.min.js 1.47 kB / 740 B (gzip)
lazy-feature-loader.0ba331d7.min.js 1.17 kB / 499 B (gzip)
Other Polyfill CDN Assets

Released Assets

Asset Name Asset Size
recorder.1b18459f-es5.min.js 166.76 kB / 52.35 kB (gzip)
nr-polyfills.min.js 52.15 kB / 17.95 kB (gzip)
session_trace-aggregate.d00569c1-es5.min.js 31.06 kB / 8.16 kB (gzip)
compressor.79fb47d9-es5.min.js 30.02 kB / 11.29 kB (gzip)
spa-aggregate.ce409f4e-es5.min.js 24.14 kB / 8.15 kB (gzip)
session_replay-aggregate.4e1233da-es5.min.js 18.81 kB / 6.43 kB (gzip)
page_view_timing-aggregate.23a9e65b-es5.min.js 18.05 kB / 6.19 kB (gzip)
173.6ecb0a79-es5.min.js 17.68 kB / 6.2 kB (gzip)
page_view_event-aggregate.13577da3-es5.min.js 12.6 kB / 4.78 kB (gzip)
jserrors-aggregate.376eb554-es5.min.js 12.46 kB / 4.45 kB (gzip)
metrics-aggregate.2d734bb0-es5.min.js 10.03 kB / 3.39 kB (gzip)
ajax-aggregate.91d28a76-es5.min.js 9.92 kB / 3.79 kB (gzip)
646.1bb2a03c-es5.min.js 9.2 kB / 3.64 kB (gzip)
page_action-aggregate.bd238cb1-es5.min.js 7.45 kB / 2.69 kB (gzip)
async-api.697c7985-es5.min.js 4.12 kB / 2 kB (gzip)
session-manager.ae4f9cf3-es5.min.js 1.7 kB / 785 B (gzip)
lazy-feature-loader.fe02c936-es5.min.js 1.2 kB / 509 B (gzip)

Built Assets

Asset Name Asset Size
recorder.1b18459f-es5.min.js 166.76 kB / 52.35 kB (gzip)
nr-polyfills.min.js 52.15 kB / 17.95 kB (gzip)
session_trace-aggregate.b90b0fc6-es5.min.js 30.93 kB / 8.12 kB (gzip)
compressor.79fb47d9-es5.min.js 30.02 kB / 11.29 kB (gzip)
spa-aggregate.5d42071b-es5.min.js 24.02 kB / 8.11 kB (gzip)
page_view_timing-aggregate.37dab318-es5.min.js 18.67 kB / 6.17 kB (gzip)
session_replay-aggregate.5fabead4-es5.min.js 18.54 kB / 6.32 kB (gzip)
173.2ba87fb3-es5.min.js 17.68 kB / 6.2 kB (gzip)
page_view_event-aggregate.c52d6109-es5.min.js 12.59 kB / 4.78 kB (gzip)
jserrors-aggregate.21b50a10-es5.min.js 12.38 kB / 4.42 kB (gzip)
ajax-aggregate.efddc02b-es5.min.js 10.58 kB / 3.78 kB (gzip)
646.cadfd5a4-es5.min.js 10.4 kB / 4.08 kB (gzip)
metrics-aggregate.c503733c-es5.min.js 9.91 kB / 3.35 kB (gzip)
page_action-aggregate.9576f950-es5.min.js 7.33 kB / 2.64 kB (gzip)
async-api.b0969e41-es5.min.js 4.16 kB / 1.99 kB (gzip)
session-manager.ae4f9cf3-es5.min.js 1.7 kB / 785 B (gzip)
lazy-feature-loader.fe02c936-es5.min.js 1.2 kB / 509 B (gzip)

@patrickhousley patrickhousley force-pushed the remove-img-network branch 4 times, most recently from 175825e to 32bcf4b Compare June 13, 2023 15:00
@bjfield bjfield changed the title feat: removing img, jsonp, and xhrGet methods feat: Remove img, jsonp, and xhrGet methods Jun 20, 2023
Copy link
Member

@metal-messiah metal-messiah left a comment

Choose a reason for hiding this comment

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

I think this covers all the topics mentioned and I have not been able to find any faults from the migration of the previous implementation. This still likely represents a change that affects the entire agent, so I think we should consider deploying this as a standalone shipment, but i think it looks G2G. approved!

@cwli24
Copy link
Contributor

cwli24 commented Jun 21, 2023

To clarify since it wasn't explicitly stated elsewhere, this will remove the ability for IE11 (those still on it) to send out data on page unload events, yes?

@patrickhousley
Copy link
Contributor Author

To clarify since it wasn't explicitly stated elsewhere, this will remove the ability for IE11 (those still on it) to send out data on page unload events, yes?

Not entirely. For IE11, the img method was used before and now XHR will be used. Both methods are a best effort and we cannot guarantee that either will actually result in the data making it out of the browser before the browser kills the JS process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium Medium Engineering Effort MMF Work directly planned for in an MMF
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants