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 {
5656 if ( isLogout ) {
5757 return this . _client . logout ( ) ;
5858 }
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 ) ;
6271 }
6372 return this . _client . getFlags ( ) ;
6473 }
You can’t perform that action at this time.
0 commit comments