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

🐛 Improve context properties sanitization #3475

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

amortemousque
Copy link
Collaborator

@amortemousque amortemousque commented Apr 7, 2025

Motivation

Certain context properties like usr.id and usr.name are converted to strings. This PR stops converting undefined and null values to strings, aligning the behavior with other context properties.

ex:

DD_RUM.setUser({ id: null, name: undefined })
BeforeAfter
{ 
  "id": "null", 
  "name": "undefined", 
}
{ 
}

Changes

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@amortemousque amortemousque requested a review from a team as a code owner April 7, 2025 12:28
@amortemousque amortemousque changed the title Improve context properties sanitization 🐛 Improve context properties sanitization Apr 7, 2025
display.warn(`The property ${key} of ${name} is required; context will not be sent to the intake.`)
}
}

return newContext
}

function isNullish(value: unknown) {
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: isNullish is not very explicit. Maybe rename to isDefined?

Copy link

cit-pr-commenter bot commented Apr 7, 2025

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 0 B 145.14 KiB 145.14 KiB N/A%
Rum.recorder 0 B 18.02 KiB 18.02 KiB N/A%
Rum.profiler 0 B 4.64 KiB 4.64 KiB N/A%
Logs 0 B 50.20 KiB 50.20 KiB N/A%
Rum Slim 0 B 104.68 KiB 104.68 KiB N/A%
Worker 0 B 23.59 KiB 23.59 KiB N/A%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.003 0.004 0.000
addaction 0.046 0.063 0.017
addtiming 0.001 0.002 0.000
adderror 0.050 0.066 0.016
startstopsessionreplayrecording 0.009 0.015 0.007
startview 0.423 0.567 0.144
logmessage 0.020 0.029 0.009
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 26.29 KiB 26.75 KiB 467 B
addaction 56.40 KiB 54.64 KiB -1803 B
addtiming 23.58 KiB 23.79 KiB 216 B
adderror 59.77 KiB 58.46 KiB -1338 B
startstopsessionreplayrecording 24.50 KiB 23.13 KiB -1406 B
startview 430.05 KiB 426.00 KiB -4150 B
logmessage 61.73 KiB 51.28 KiB -10704 B

🔗 RealWorld

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.99%. Comparing base (66ce71d) to head (4158a43).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3475   +/-   ##
=======================================
  Coverage   91.98%   91.99%           
=======================================
  Files         310      310           
  Lines        8026     8028    +2     
  Branches     1820     1821    +1     
=======================================
+ Hits         7383     7385    +2     
  Misses        643      643           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants