File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1010
1111- fix(ttid): End and measure TTID regardless current active span ([ #4019 ] ( https://github.com/getsentry/sentry-react-native/pull/4019 ) )
1212 - Fixes possible missing TTID measurements and spans
13+ - Fix crash when passing array as data to ` Sentry.addBreadcrumb({ data: [] }) ` ([ #4021 ] ( https://github.com/getsentry/sentry-react-native/pull/4021 ) )
14+ - The expected ` data ` type is plain JS object, otherwise the data might be lost.
1315
1416### Dependencies
1517
Original file line number Diff line number Diff line change @@ -8,12 +8,17 @@ const KEY = 'value';
88// eslint-disable-next-line @typescript-eslint/no-explicit-any
99export function convertToNormalizedObject ( data : unknown ) : Record < string , any > {
1010 const normalized : unknown = normalize ( data ) ;
11- if ( normalized === null || typeof normalized !== 'object' ) {
11+ if (
12+ normalized !== null &&
13+ typeof normalized === 'object' &&
14+ ! Array . isArray ( normalized ) &&
15+ normalized . constructor === Object
16+ ) {
17+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18+ return normalized as Record < string , any > ;
19+ } else {
1220 return {
1321 [ KEY ] : normalized ,
1422 } ;
15- } else {
16- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17- return normalized as Record < string , any > ;
1823 }
1924}
Original file line number Diff line number Diff line change @@ -21,5 +21,18 @@ describe('normalize', () => {
2121 const actualResult = convertToNormalizedObject ( null ) ;
2222 expect ( actualResult ) . toEqual ( { value : null } ) ;
2323 } ) ;
24+
25+ test ( 'converts array to an object' , ( ) => {
26+ const actualResult = convertToNormalizedObject ( [ ] ) ;
27+ expect ( actualResult ) . toEqual ( { value : [ ] } ) ;
28+ } ) ;
29+
30+ test ( 'converts custom class to an object' , ( ) => {
31+ class TestClass {
32+ test : string = 'foo' ;
33+ }
34+ const actualResult = convertToNormalizedObject ( new TestClass ( ) ) ;
35+ expect ( actualResult ) . toEqual ( { test : 'foo' } ) ;
36+ } ) ;
2437 } ) ;
2538} ) ;
You can’t perform that action at this time.
0 commit comments