File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
libs/providers/flagsmith-client/src/lib Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,18 @@ export class FlagsmithClientProvider implements Provider {
56
56
if ( isLogout ) {
57
57
return this . _client . logout ( ) ;
58
58
}
59
- if ( identity ) {
60
- const { targetingKey, ...traits } = context ;
61
- return this . _client . identify ( identity , traits as any ) ;
59
+ if ( context ?. targetingKey ) {
60
+ const { targetingKey, ...contextTraits } = context ;
61
+ // OpenFeature context attributes can be Date objects, but Flagsmith traits can't
62
+ const traits : Parameters < IFlagsmith [ 'identify' ] > [ 1 ] = { } ;
63
+ for ( const [ key , value ] of Object . entries ( contextTraits ) ) {
64
+ if ( value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' ) {
65
+ traits [ key ] = value ;
66
+ } else if ( value instanceof Date ) {
67
+ traits [ key ] = value . toISOString ( ) ;
68
+ }
69
+ }
70
+ return this . _client . identify ( targetingKey , traits ) ;
62
71
}
63
72
return this . _client . getFlags ( ) ;
64
73
}
You can’t perform that action at this time.
0 commit comments