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

🐛 [RUM-87] AddError should support Error instances coming from other JS contexts #3144

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

RomanGaignault
Copy link
Contributor

Motivation

using DD_RUM.addError(error) but the error comes from a different context than the document (ex: created insde an iframe or a window.open), the SDK doesn not consider it as an Error instance and serializes it as JSON.

Changes

Use class object to determine if it's an error or not.

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@RomanGaignault RomanGaignault requested a review from a team as a code owner November 19, 2024 10:48
@RomanGaignault RomanGaignault changed the title add a function isError / delete instanceOf 🐛 [RUM-87] AddError should support Error instances coming from other JS contexts Nov 19, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.21%. Comparing base (0a018d6) to head (f228a75).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3144      +/-   ##
==========================================
- Coverage   93.71%   93.21%   -0.50%     
==========================================
  Files         279      279              
  Lines        7682     7682              
  Branches     1718     1716       -2     
==========================================
- Hits         7199     7161      -38     
- Misses        483      521      +38     

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

@RomanGaignault
Copy link
Contributor Author

/to-staging

@dd-devflow
Copy link
Contributor

dd-devflow bot commented Nov 19, 2024

Devflow running: /to-staging

View all feedbacks in Devflow UI.


2024-11-19 10:51:46 UTC ℹ️ Branch Integration: starting soon, median merge time is 0s

Commit 2f313ff0f1 will soon be integrated into staging-47.


2024-11-19 11:00:37 UTC ℹ️ Branch Integration: This commit was successfully integrated

Commit 2f313ff0f1 has been merged into staging-47 in merge commit c9a4836892.

Check out the triggered pipeline on Gitlab 🦊

dd-mergequeue bot added a commit that referenced this pull request Nov 19, 2024
…staging-47

Integrated commit sha: 2f313ff

Co-authored-by: roman.gaignault <roman.gaignault@datadoghq.com>
Copy link

cit-pr-commenter bot commented Nov 20, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.52 KiB 161.46 KiB -56 B -0.03%
Logs 55.77 KiB 55.72 KiB -56 B -0.10%
Rum Slim 110.36 KiB 110.30 KiB -56 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.001 0.002 0.000
addaction 0.038 0.048 0.010
addtiming 0.001 0.001 0.000
adderror 0.034 0.036 0.002
startstopsessionreplayrecording 0.902 0.984 0.082
startview 0.986 1.098 0.112
logmessage 0.020 0.025 0.006
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 6.75 KiB 7.42 KiB 684 B
addaction 38.88 KiB 39.04 KiB 160 B
addtiming 5.85 KiB 8.34 KiB 2.49 KiB
adderror 42.85 KiB 44.55 KiB 1.70 KiB
startstopsessionreplayrecording 5.70 KiB 4.43 KiB -1299 B
startview 424.00 KiB 428.58 KiB 4.58 KiB
logmessage 40.75 KiB 40.31 KiB -451 B

🔗 RealWorld

@amortemousque
Copy link
Collaborator

amortemousque commented Nov 25, 2024

Should we do the same everytime we check instanceof Error?
Like in the logger:

stackTrace: error instanceof Error ? computeStackTrace(error) : undefined,

in the telemetry:

cc @BenoitZugmeyer

@@ -64,7 +65,7 @@ export class Logger {

if (error !== undefined && error !== null) {
const rawError = computeRawError({
stackTrace: error instanceof Error ? computeStackTrace(error) : undefined,
stackTrace: isError(error) ? computeStackTrace(error) : undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 suggestion: Could be nice to have a test about it.‏

@RomanGaignault RomanGaignault merged commit a46fd38 into main Nov 26, 2024
19 checks passed
@RomanGaignault RomanGaignault deleted the romanG/add-error-fix-outside-document-context branch November 26, 2024 13:52
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