Comments (10)
bullet-train-client and react-native-bullet-train have been updated to 0.0.42 to incorporate this.
from flagsmith-js-client.
Can you confirm this is due to using a self hosted api? I feel like this is a duplicate of #2
from flagsmith-js-client.
It,s not duplicate of #2 , here, I'm loading the client from the CDN (https://cdn.jsdelivr.net/npm/bullet-train-client/lib/index.js) and it loads and connect to the API server properly. The client does receive a response from the API server that contains the feature flag, but the bulletTrain.getAllFlags()
call returns an empty object. I also tried with bulletTrain.hasFeature("hello_world") and it always returns false... Even though I specified a default flag value of
true` and I receive the flag (set to true) from the API server.
from flagsmith-js-client.
The code seems wrong, in bullet-train-core, this calls the handleResponse(res) function, the response from the API is an array: https://github.com/SolidStateGroup/bullet-train-js-client/blob/f96cb36aabc8e77dabf790e36b78dbc9f898ec45/bullet-train-core.js#L65
But the handleResponse
expect an object with the shape {flags: [], traits: []}
: https://github.com/SolidStateGroup/bullet-train-js-client/blob/f96cb36aabc8e77dabf790e36b78dbc9f898ec45/bullet-train-core.js#L31
For reference, the bullet-train-fronend app interpret the response from the API as an array: https://github.com/SolidStateGroup/bullet-train-frontend/blob/e062cfd406e85c0220c2759556129a0776ae9975/web/components/TryIt.js#L22
from flagsmith-js-client.
Here is the commit that switch the handling from an array to an object: 5c131e0
from flagsmith-js-client.
The response from getting flags is not an array since implementing user traits it is an object. Are you sure your API is set up correctly and you are using the latest version?
curl 'https://api.bullet-train.io/api/v1/identities/bullet_train_sample_user/?format=json' -H 'x-environment-key: QjgYur4LQTwe5HpvbvhpzK' -H 'Referer: http://localhost:3000/' -H 'Origin: http://localhost:3000' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36' -H 'Content-Type: application/json; charset=utf-8' --compressed
from flagsmith-js-client.
To demonstrate this, there's a super simple react app that lets you retrieve flags+traits and toggle a user trait.
https://github.com/SolidStateGroup/bullet-train-js-client/tree/master/bullet-train-client/example
from flagsmith-js-client.
Looks like my api server is not up to date. It's a bummer that the api changes in incompatible ways like that.
I will update my server and test it.
from flagsmith-js-client.
Now i'm running that latest api server from github and I still get an array
curl 'https://bullet-train-api-experiment.....com/api/v1/flags/?format=json' -H 'x-environment-key: m...G' -H 'Referer: http://localhost:3000/?q=portail' -H 'Origin: http://localhost:3000' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' -H 'Content-Type: application/json; charset=utf-8' --compressed
response:
[{"id":2,"feature":{"id":1,"name":"hello_world","created_date":"2018-12-11T20:55:38.891097Z","initial_value":null,"description":null,"default_enabled":false,"type":"FLAG","project":1},"feature_state_value":null,"enabled":true,"environment":2,"identity":null}]
from flagsmith-js-client.
The bug is when bulletTrain.identify(...)
has not been called.
you would call handleResponse({flags: res})
instead of handleresponse(res)
that would solve the problem.
from flagsmith-js-client.
Related Issues (20)
- isLoading never updates to false HOT 2
- Flagsmith's `loadingState.error` is not respect actual error state HOT 11
- [Bug] - NextJS >= 13.0.0 SSR `useFlagsmith` state not matching the state that is passed to the provider. HOT 16
- flagsmith/react only works in React 18 HOT 3
- [Bug] - TypeError: Cannot read properties of null (reading 'getValue') HOT 5
- Flagsmith's 'useFlags' doesn't return actual cached flags when request failed HOT 2
- Rollup Name for react HOT 5
- Inconsistent license information HOT 2
- Caching with multiple instance doesn't work HOT 6
- Typing issue in react.tsx: 'flagsmith' is possibly 'null' HOT 3
- useFlags() race condition HOT 8
- Different environments not working HOT 5
- Localstorage cache is not being wiped out in some edge cases HOT 3
- Support `getValue` fallback without `json` flag HOT 2
- useFlags not updating values in react18/Nextjs App Router
- 3.23.0 seems to have broken something HOT 4
- Intermittent Flakiness in Feature Flags on Safari/MacOS HOT 2
- Flags are null when the cacheFlags option is true HOT 3
- Typescript compiler errror `Cannot find name 'F'.` when compiling flagsmith in Angular project HOT 3
- Bundle ES(flagsmith-es) and combine with standard CJS module (flagsmith)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flagsmith-js-client.