GithubHelp home page GithubHelp logo

Comments (10)

kyle-ssg avatar kyle-ssg commented on July 17, 2024 1

bullet-train-client and react-native-bullet-train have been updated to 0.0.42 to incorporate this.

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on July 17, 2024

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.

ukabu avatar ukabu commented on July 17, 2024

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.

ukabu avatar ukabu commented on July 17, 2024

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.

ukabu avatar ukabu commented on July 17, 2024

Here is the commit that switch the handling from an array to an object: 5c131e0

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on July 17, 2024

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.

kyle-ssg avatar kyle-ssg commented on July 17, 2024

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.

ukabu avatar ukabu commented on July 17, 2024

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.

ukabu avatar ukabu commented on July 17, 2024

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.

ukabu avatar ukabu commented on July 17, 2024

The bug is when bulletTrain.identify(...) has not been called.

if at https://github.com/SolidStateGroup/bullet-train-js-client/blob/f96cb36aabc8e77dabf790e36b78dbc9f898ec45/bullet-train-core.js#L65

you would call handleResponse({flags: res}) instead of handleresponse(res) that would solve the problem.

from flagsmith-js-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.