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

🐛 Allow both history and History prototype to be patched by 3rd party #2968

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

thomas-lebeau
Copy link
Collaborator

@thomas-lebeau thomas-lebeau commented Sep 3, 2024

Motivation

Since #2944, we broke the instrumentation for NextJs that is patching history.pushState instead of History.prototype.pushState. This PR allow both way to be patched (even if incorrect)

Changes

  • wrap history.pushState if it is already patched that way, otherwise wrap History.prototype.pushState
  • Refactor mockLocation because using spyOn is effectively the same as wrapping so this make testing difficult.

Testing

I've added unit test, to cover both #2956 and #2943

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

}

registerCleanupTask(() => {
// @ts-expect-error reseting history instance to its original state

Choose a reason for hiding this comment

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

Code Quality Violation

Disallow `// tslint:` comments (...read more)

Correct your types instead of disabling TypeScript.

View in Datadog  Leave us feedback  Documentation

@thomas-lebeau thomas-lebeau marked this pull request as ready for review September 4, 2024 08:10
@thomas-lebeau thomas-lebeau requested a review from a team as a code owner September 4, 2024 08:10
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: Because we don't mock the location anymore in mockLocation, maybe rename this file. (Don't put buildLocation into testSetupBuilder.ts as it will conflict with #2952)

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.50%. Comparing base (ca23b46) to head (1040139).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2968   +/-   ##
=======================================
  Coverage   93.49%   93.50%           
=======================================
  Files         271      271           
  Lines        7640     7631    -9     
  Branches     1703     1704    +1     
=======================================
- Hits         7143     7135    -8     
+ Misses        497      496    -1     

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

Copy link

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.05 KiB 161.14 KiB 95 B +0.06%
Logs 56.12 KiB 56.12 KiB 0 B 0.00%
Rum Slim 109.66 KiB 109.75 KiB 95 B +0.08%
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.003 0.002 -0.001
addaction 0.059 0.033 -0.027
addtiming 0.001 0.001 -0.000
adderror 0.041 0.035 -0.006
startstopsessionreplayrecording 1.186 0.810 -0.376
startview 1.183 0.976 -0.207
logmessage 0.028 0.020 -0.009
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 8.60 KiB 9.54 KiB 961 B
addaction 40.02 KiB 41.21 KiB 1.19 KiB
addtiming 7.10 KiB 7.09 KiB -14 B
adderror 44.99 KiB 45.34 KiB 359 B
startstopsessionreplayrecording 5.34 KiB 5.91 KiB 582 B
startview 316.01 KiB 323.46 KiB 7.45 KiB
logmessage 39.91 KiB 41.42 KiB 1.51 KiB

🔗 RealWorld

@thomas-lebeau
Copy link
Collaborator Author

/to-staging

@dd-devflow
Copy link
Contributor

dd-devflow bot commented Sep 4, 2024

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

Commit 1040139db3 will soon be integrated into staging-36.

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

dd-mergequeue bot added a commit that referenced this pull request Sep 4, 2024
Integrated commit sha: 1040139

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

dd-devflow bot commented Sep 4, 2024

🚂 Branch Integration: This commit was successfully integrated

Commit 1040139db3 has been merged into staging-36 in merge commit 37b8d9ecb6.

Check out the triggered pipeline on Gitlab 🦊

@dd-devflow dd-devflow bot added the staging-36 label Sep 4, 2024
@thomas-lebeau thomas-lebeau merged commit 02e5c3a into main Sep 4, 2024
21 checks passed
@thomas-lebeau thomas-lebeau deleted the thomas.lebeau/history-pushstate branch September 4, 2024 13:21
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