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

🐛 [RUMF-1305] forbid the usage of Date.now #1600

Merged
merged 2 commits into from
Jun 21, 2022

Conversation

BenoitZugmeyer
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer commented Jun 17, 2022

Motivation

Do not use Date.now because sometimes websites are wrongly "polyfilling" it. For example, we had some users using a very old version of datejs, which patched Date.now to return a Date instance instead of a timestamp. Those users are unlikely to fix this, so let's handle this case ourselves.

Changes

  • Replace Date.now usages with a utility function
  • Adjust the ESLint configuration to make sure we don't use Date.now in our source files

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner June 17, 2022 09:44
@codecov-commenter
Copy link

Codecov Report

Merging #1600 (a275548) into main (7ab2389) will decrease coverage by 0.01%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##             main    #1600      +/-   ##
==========================================
- Coverage   90.84%   90.83%   -0.02%     
==========================================
  Files         123      123              
  Lines        4557     4559       +2     
  Branches     1021     1021              
==========================================
+ Hits         4140     4141       +1     
- Misses        417      418       +1     
Impacted Files Coverage Δ
...ages/rum-core/src/browser/performanceCollection.ts 14.00% <0.00%> (ø)
...ages/core/src/domain/session/sessionCookieStore.ts 100.00% <100.00%> (ø)
packages/core/src/domain/session/sessionStore.ts 100.00% <100.00%> (ø)
packages/core/src/tools/timeUtils.ts 97.29% <100.00%> (-2.71%) ⬇️
.../rum-core/src/domain/tracing/getDocumentTraceId.ts 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@BenoitZugmeyer BenoitZugmeyer merged commit f53b72f into main Jun 21, 2022
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/forbid-usages-of-date-now branch June 21, 2022 12:12
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