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

🧪 Update browser matrix for tests #2884

Merged
merged 7 commits into from
Jul 30, 2024

Conversation

thomas-lebeau
Copy link
Collaborator

@thomas-lebeau thomas-lebeau commented Jul 22, 2024

Motivation

Until now we're testing only on somewhat recent version off different browsers. However, as we're defining a new browser support matrix I thought it would be better to test on the actual minimum version of the browsers we're supporting.

This PR only focus on unit tests. I'll investigate separately for e2e tests as it's a bit more complicated.

Changes

  • separate unit and e2e browser matrix
  • use new browser matrix for unit tests.
  • properly check feature availability before running unit tests
  • refactor onunhandledrejection to handle the case where it's not supported (Firefox 67 & 68)

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

Copy link

cit-pr-commenter bot commented Jul 22, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 158.86 KiB 158.92 KiB 57 B +0.04%
Logs 55.74 KiB 55.75 KiB 11 B +0.02%
Rum Slim 107.47 KiB 107.53 KiB 57 B +0.05%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.002 0.001 -0.001
addaction 0.049 0.035 -0.014
adderror 0.053 0.037 -0.016
addtiming 0.001 0.001 -0.000
startview 1.272 1.001 -0.271
startstopsessionreplayrecording 1.485 0.798 -0.688
logmessage 0.030 0.019 -0.010
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 21.42 KiB 20.59 KiB -848 B
addaction 69.60 KiB 71.88 KiB 2.27 KiB
adderror 84.54 KiB 87.78 KiB 3.24 KiB
addtiming 17.93 KiB 19.67 KiB 1.75 KiB
startview 347.79 KiB 351.50 KiB 3.71 KiB
startstopsessionreplayrecording 13.47 KiB 13.02 KiB -464 B
logmessage 69.32 KiB 72.06 KiB 2.73 KiB

🔗 RealWorld

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.67%. Comparing base (6dc4216) to head (569a30e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2884      +/-   ##
==========================================
+ Coverage   93.65%   93.67%   +0.01%     
==========================================
  Files         268      268              
  Lines        7584     7584              
  Branches     1686     1687       +1     
==========================================
+ Hits         7103     7104       +1     
+ Misses        481      480       -1     

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

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/update-test-browser-matrix branch 7 times, most recently from 13b2419 to 8bb6673 Compare July 25, 2024 09:44
Comment on lines +12 to +13
getSpy: spyOnProperty(document, 'cookie', 'get').and.callFake(() => cookie),
setSpy: spyOnProperty(document, 'cookie', 'set').and.callFake((newCookie) => (cookie = newCookie)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fix for Firefox 67

@@ -46,7 +46,7 @@ describe('sanitize', () => {
const symbolFunction: (description: string) => any = (window as any).Symbol
if (typeof symbolFunction === 'function') {
const symbol = symbolFunction('description')
expect(sanitize(symbol)).toEqual('[Symbol] description')
expect(sanitize(symbol)).toMatch(/\[Symbol\] (?:Symbol\()?description\)?/)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this match better the implementation:

return `[Symbol] ${(value as symbolWithDescription).description || value.toString()}

which will return [Symbol] foo if Symbol.description is supported and [Symbol] Symbol(foo)otherwise

@@ -77,7 +77,7 @@ export function instrumentMethod<TARGET extends { [key: string]: any }, METHOD e
let original = targetPrototype[method]

if (typeof original !== 'function') {
if (startsWith(method, 'on')) {
if (method in targetPrototype && startsWith(method, 'on')) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if the event is not supported (e.g 'onunhandledrejection' in window) we should replace it.

Comment on lines 186 to 203
let onunhandledrejectionSpy: jasmine.Spy

beforeEach(() => {
onunhandledrejectionSpy = jasmine.createSpy()
window.onunhandledrejection = onunhandledrejectionSpy

registerCleanupTask(() => {
window.onunhandledrejection = null
})
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

unused

Comment on lines -47 to -52
window.onunhandledrejection = (ev: PromiseRejectionEvent) => {
throw new Error(`unhandled rejected promise \n ${ev.reason as string}`)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

unused

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/update-test-browser-matrix branch from 8bb6673 to 0ecbfef Compare July 25, 2024 10:05
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/update-test-browser-matrix branch from 0ecbfef to 7e10985 Compare July 26, 2024 04:53
@thomas-lebeau thomas-lebeau changed the base branch from v6 to main July 26, 2024 09:00
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/update-test-browser-matrix branch from 7e10985 to c051ad0 Compare July 26, 2024 09:08
@thomas-lebeau
Copy link
Collaborator Author

/to-staging

@dd-devflow
Copy link

dd-devflow bot commented Jul 26, 2024

🚂 Branch Integration: starting soon, median merge time is 11m

Commit 111f94454a will soon be integrated into staging-30.

Use /to-staging -c to cancel this operation!

dd-devflow bot added a commit that referenced this pull request Jul 26, 2024
@dd-devflow
Copy link

dd-devflow bot commented Jul 26, 2024

🚨 Branch Integration: This merge request has conflicts

We couldn't automatically merge the commit 111f94454a into staging-30!

You can use this resolution PR: #2898 to fix the conflicts.

If you need support, contact us on Slack #devflow with those details!

@thomas-lebeau thomas-lebeau marked this pull request as ready for review July 26, 2024 10:46
@thomas-lebeau thomas-lebeau requested a review from a team as a code owner July 26, 2024 10:46
@@ -138,5 +137,5 @@ function slidingSessionWindow() {
* Check whether `layout-shift` is supported by the browser.
*/
export function isLayoutShiftSupported() {
return supportPerformanceTimingEvent(RumPerformanceEntryType.LAYOUT_SHIFT)
return supportPerformanceTimingEvent(RumPerformanceEntryType.LAYOUT_SHIFT) && 'WeakRef' in window
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We used WeakRef to avoid memory leak when tracking CLS vital and assumed that browsers supporting layout-shift where also supporting WeakRef. Unfortunately that's not true and there is a few browsers versions that does support layout shift but not WeakRef. Unfortunately we were never testing on such browsers :(

This bug affect the following browsers:

  • Chrome 77 to 83
  • Edge 79 to 83
  • Opera 64 to 69

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this is communicated, but it's worth mentioning in our documentation I guess

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree, although currently there is a lot of gaps on how we document the features supported by browsers and does not includes version.

My RFC around dropping IE11 proposes to remediates to this issue:

Additionally we can update the feature support by browser to also include specific version numbers.

packages/core/src/domain/error/trackRuntimeError.spec.ts Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 Praise: Thanks for the cleanup

@@ -138,5 +137,5 @@ function slidingSessionWindow() {
* Check whether `layout-shift` is supported by the browser.
*/
export function isLayoutShiftSupported() {
return supportPerformanceTimingEvent(RumPerformanceEntryType.LAYOUT_SHIFT)
return supportPerformanceTimingEvent(RumPerformanceEntryType.LAYOUT_SHIFT) && 'WeakRef' in window
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this is communicated, but it's worth mentioning in our documentation I guess

@N-Boutaib N-Boutaib requested a review from a team July 26, 2024 12:35
@dd-devflow
Copy link

dd-devflow bot commented Jul 26, 2024

🚂 Branch Integration: starting soon, median merge time is 11m

Commit 111f94454a will soon be integrated into staging-30.

@dd-devflow
Copy link

dd-devflow bot commented Jul 26, 2024

🚨 Branch integration failed

Have a look at the resolution PR #2898 for more information.

@dd-devflow
Copy link

dd-devflow bot commented Jul 26, 2024

🚂 Branch Integration: starting soon, median merge time is 11m

Commit 111f94454a will soon be integrated into staging-30.

@dd-devflow
Copy link

dd-devflow bot commented Jul 26, 2024

🚨 Branch integration failed

Have a look at the resolution PR #2898 for more information.

@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/update-test-browser-matrix branch from fdc61b0 to fe33e68 Compare July 29, 2024 17:51
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/update-test-browser-matrix branch from fe33e68 to 58b2726 Compare July 29, 2024 18:05
@thomas-lebeau
Copy link
Collaborator Author

/to-staging

@dd-devflow
Copy link

dd-devflow bot commented Jul 30, 2024

🚂 Branch Integration: starting soon, median merge time is 0s

Commit efe8b8cd27 will soon be integrated into staging-31.

Use /to-staging -c to cancel this operation!

dd-mergequeue bot added a commit that referenced this pull request Jul 30, 2024
…ng-31

Integrated commit sha: efe8b8c

Co-authored-by: Thomas Lebeau <thomas.lebeau@datadoghq.com>
@dd-devflow
Copy link

dd-devflow bot commented Jul 30, 2024

🚂 Branch Integration: This commit was successfully integrated

Commit efe8b8cd27 has been merged into staging-31 in merge commit 367f4caa30.

Check out the triggered pipeline on Gitlab 🦊

Copy link
Member

Choose a reason for hiding this comment

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

Suggestion:

  • move browsers.e2e.conf.js to e2e/browsers.conf.js
  • move browsers.unit.conf.js to unit/browsers.conf.js
  • remove unnecessary entries from browsers used by e2e tests (see
    .filter(
    (configuration) =>
    configuration.sessionName !== 'IE' &&
    // Safari mobile on iOS <= 14.0 does not support
    // the way we flush events on page change
    // TODO check newer version on browserstack
    configuration.sessionName !== 'Safari mobile'
    )
    )

@thomas-lebeau thomas-lebeau merged commit 9d19ead into main Jul 30, 2024
20 checks passed
@thomas-lebeau thomas-lebeau deleted the thomas.lebeau/update-test-browser-matrix branch July 30, 2024 11:22
thomas-lebeau added a commit that referenced this pull request Jul 30, 2024
 pm_trace_id: 40455230
 feature_branch_pipeline_id: 40455230
 source: to-staging

* commit 'fa9bb6a410d74e6371b6d5de41b230878c2c2768':
  [RUM-5590] Add telemetry for INP null target (#2895)
  🧪 Update browser matrix for tests (#2884)
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.

4 participants