@@ -9,7 +9,7 @@ export default (payload: IdentifyEventType) => {
99 ReactAppboy . changeUser ( payload . userId ) ;
1010 }
1111
12- if ( payload . traits . birthday ) {
12+ if ( payload . traits ? .birthday !== undefined ) {
1313 const data = new Date ( payload . traits . birthday ) ;
1414 ReactAppboy . setDateOfBirth (
1515 data . getFullYear ( ) ,
@@ -19,19 +19,19 @@ export default (payload: IdentifyEventType) => {
1919 ) ;
2020 }
2121
22- if ( payload . traits . email ) {
22+ if ( payload . traits ? .email !== undefined ) {
2323 ReactAppboy . setEmail ( payload . traits . email ) ;
2424 }
2525
26- if ( payload . traits . firstName ) {
26+ if ( payload . traits ? .firstName !== undefined ) {
2727 ReactAppboy . setFirstName ( payload . traits . firstName ) ;
2828 }
2929
30- if ( payload . traits . lastName ) {
30+ if ( payload . traits ? .lastName !== undefined ) {
3131 ReactAppboy . setLastName ( payload . traits . lastName ) ;
3232 }
3333
34- if ( payload . traits . gender ) {
34+ if ( payload . traits ? .gender !== undefined ) {
3535 const validGenders = [ 'm' , 'f' , 'n' , 'o' , 'p' , 'u' ] ;
3636 const isValidGender = validGenders . indexOf ( payload . traits . gender ) > - 1 ;
3737 if ( isValidGender ) {
@@ -41,15 +41,15 @@ export default (payload: IdentifyEventType) => {
4141 }
4242 }
4343
44- if ( payload . traits . phone ) {
44+ if ( payload . traits ? .phone !== undefined ) {
4545 ReactAppboy . setPhoneNumber ( payload . traits . phone ) ;
4646 }
4747
48- if ( payload . traits . address ) {
49- if ( payload . traits . address . city ) {
48+ if ( payload . traits ? .address !== undefined ) {
49+ if ( payload . traits . address . city !== undefined ) {
5050 ReactAppboy . setHomeCity ( payload . traits . address . city ) ;
5151 }
52- if ( payload . traits . address . country ) {
52+ if ( payload . traits ? .address . country !== undefined ) {
5353 ReactAppboy . setCountry ( payload . traits . address . country ) ;
5454 }
5555 }
@@ -64,7 +64,7 @@ export default (payload: IdentifyEventType) => {
6464 'address' ,
6565 ] ;
6666
67- Object . entries ( payload . traits ) . forEach ( ( [ key , value ] ) => {
67+ Object . entries ( payload . traits ?? { } ) . forEach ( ( [ key , value ] ) => {
6868 if ( appBoyTraits . indexOf ( key ) < 0 ) {
6969 ReactAppboy . setCustomUserAttribute ( key , value as any ) ;
7070 }
0 commit comments