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-1517] split domain utils #2105

Merged
merged 9 commits into from
Mar 28, 2023
Merged

♻️[RUMF-1517] split domain utils #2105

merged 9 commits into from
Mar 28, 2023

Conversation

bcaudan
Copy link
Contributor

@bcaudan bcaudan commented Mar 24, 2023

Motivation

Avoid single utils files

Changes

Remove record/utils and record/observers/utils by:

  • moving getPathToNestedCSSRule to styleSheetObserver
  • moving forEach and listenerObserver to core/tools/utils (for future specialisation)
  • creating record/assembly (observer -> record assembly -> emit design could later evolve to match what we have for rum and logs events)
  • creating eventsUtils
  • creating recordIds

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@bcaudan bcaudan marked this pull request as ready for review March 24, 2023 14:52
@bcaudan bcaudan requested review from a team as code owners March 24, 2023 14:52
let nextId = 1

return {
get(event: Event): number {
Copy link
Member

Choose a reason for hiding this comment

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

❓ question: ‏Why not keeping this a singleton?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at it, it was not utility code but domain logic, so following the convention, I passed it as a dependency rather than statically import it.
By automatism, I switched the singleton getter to an object but indeed we could keep the singleton getter and pass it as a dependency.
Any pros/cons to favour the singleton?

Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit surprised to see this kind of change included in a PR focused on splitting files. I have mixed feelings on enforcing the "dependency as parameter" policy when it's not really needed, but fine.

Still, I think the getRecordIdForEvent name was clearer than recordIds.get. Maybe we could rename it recordIds.getIdForEvent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we could rename it recordIds.getIdForEvent?

LGTM

I have mixed feelings on enforcing the "dependency as parameter" policy when it's not really needed, but fine.

We should chat about that to see if we can get aligned

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2023

Codecov Report

Merging #2105 (af37b16) into main (28d26bb) will decrease coverage by 0.12%.
The diff coverage is 94.59%.

@@            Coverage Diff             @@
##             main    #2105      +/-   ##
==========================================
- Coverage   93.67%   93.55%   -0.12%     
==========================================
  Files         163      164       +1     
  Lines        5691     5694       +3     
  Branches     1303     1303              
==========================================
- Hits         5331     5327       -4     
- Misses        360      367       +7     
Impacted Files Coverage Δ
packages/core/src/tools/utils.ts 81.56% <0.00%> (-0.65%) ⬇️
...s/rum/src/domain/record/observers/focusObserver.ts 100.00% <ø> (ø)
...s/rum/src/domain/record/observers/inputObserver.ts 79.06% <ø> (ø)
...omain/record/observers/mediaInteractionObserver.ts 27.27% <ø> (ø)
...es/rum/src/domain/record/observers/moveObserver.ts 95.65% <ø> (ø)
.../rum/src/domain/record/observers/scrollObserver.ts 25.00% <ø> (ø)
.../domain/record/observers/viewportResizeObserver.ts 78.57% <ø> (ø)
packages/rum/src/domain/record/record.ts 79.06% <ø> (ø)
packages/rum/src/domain/record/assembly.ts 100.00% <100.00%> (ø)
packages/rum/src/domain/record/eventsUtils.ts 100.00% <100.00%> (ø)
... and 5 more

... and 2 files with indirect coverage changes

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

@bcaudan bcaudan merged commit 7e0d78c into main Mar 28, 2023
@bcaudan bcaudan deleted the bcaudan/domain-utils branch March 28, 2023 12:35
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