-
Notifications
You must be signed in to change notification settings - Fork 251
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
Recursive metadata is now handled in react native #1643
Conversation
3363f11
to
b6afa26
Compare
|
Minified | Minfied + Gzipped | |
---|---|---|
Before | 41.58 kB |
12.80 kB |
After | 41.58 kB |
12.80 kB |
± | No change | No change |
code coverage diff
Ok | File | Lines | Branches | Functions | Statements |
---|---|---|---|---|---|
✅ | /home/runner/work/bugsnag-js/bugsnag-js/packages/delivery-react-native/delivery.js | 72.73% (+2.73%) |
42.86% (+0%) |
60% (+0%) |
75% (+2.27%) |
✅ | /home/runner/work/bugsnag-js/bugsnag-js/packages/delivery-react-native/make-safe.js | 89.47% (+89.47%) |
84.62% (+84.62%) |
83.33% (+83.33%) |
87.5% (+87.5%) |
Total:
Lines | Branches | Functions | Statements |
---|---|---|---|
81.65%(+0.07%) | 71.52%(+0.16%) | 82.67%(+0%) | 80.71%(+0.06%) |
b6afa26
to
2500451
Compare
} | ||
|
||
// handle arrays, and all iterable non-array types (such as Set) | ||
if (isArray(obj) || obj[Symbol.iterator]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all versions of RN support Symbol
?
I can't really find anything very helpful, but there's this error from not having a Symbol
global on SO which may mean we need to be careful about using Symbol
Something like this might be safer:
if (isArray(obj) || obj[Symbol.iterator]) { | |
if (isArray(obj) || (Symbol && obj[Symbol.iterator])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symbol
is available on all the RN versions we support, but I'm happy to addd the secondary check for safety sake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's supported everywhere then it's probably fine as-is, I just couldn't find anything definitive in a quick search
// ensure that circular references are safely handled | ||
metaData.circle = metaData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add this to the expected breadcrumb?
import makeSafe from '../make-safe' | ||
|
||
describe('delivery: react native makeSafe', () => { | ||
it('leaves simple types intact', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add more types to this test? e.g. null
& undefined
(as they are special cased), Symbol
, maybe a Map
or other non-array iterable?
…t to native notifiers
Goal
Make it safe to specify complex and recursive objects as metadata for breadcrumbs and events in react native applications.
Design
Added a new
makeSafe
function to thedelivery-react-native
which behaves similarly to thesafe-json-stringify
module but specifically for the react native JS bridge, which does not invoketoJSON
functions.Testing
New unit tests to cover the
makeSafe
function, and adjustments to the existing Mazerunner tests to ensure circular references are correctly flattened and don't cause a crash.