Coder Social home page Coder Social logo

Comments (14)

kyle-ssg avatar kyle-ssg commented on June 22, 2024 2

Ah I believe it’s actually identify that can be called before init, which prevents fetching flags in init without the user, though I’ll add a note for the other calls like setTrait.

Yes batching traits and sending as an object would be useful, this is currently in our backlog.

I imagine it would something like
bulletTrain.setTraits({username:’abc’, otherProp’xyz’})

Edit: I’ve renamed the issue to something more actionable, I’ll keep this open until setTraits is done and can be called before init

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on June 22, 2024 2

Right, sorry yep I see, there was a couple conversations going on here. In future I'll try to limit these issues to 1 topic so we have something that's concise and actionable.

The latest release 0.1.1 of the JS and React Native clients include the following

  • setTraits, allowing you to specify key value pairs for multiple traits, setting null as the value for any trait will remove the trait.
  • calling setTrait and setTraits will not attempt a call to getFlags if it is called before bulletTrain.init
  • documentation updated to describe how the above works.

I'll leave this issue open incase you guys have any feedback @davidskaarup @adenta @OscarGalindo.

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on June 22, 2024 1

No it wont @davidskaarup, this is intentional.

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on June 22, 2024

Hey @OscarGalindo Correct you can’t call setTrait before init, are you expecting to be able to? Or are you just wanting better error handling for this?

from flagsmith-js-client.

OscarGalindo avatar OscarGalindo commented on June 22, 2024

Actually will be fine if I can set everything before initialisation and then the client sdk only do 1 single request instead of 3-4 (one per trait + init).

But in any case, at least, the documentation should be fixed

Thanks!

from flagsmith-js-client.

adenta avatar adenta commented on June 22, 2024

Whats the progress on this? Every trait I set causes a rerender

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on June 22, 2024

Hey @adenta, will have a discussion with backend team about getting this progressed this evening. Thanks for being patient!

from flagsmith-js-client.

davidskaarup avatar davidskaarup commented on June 22, 2024

In this example in the documentation setTrait is called before init:

/*
Can be called both before or after you're done initialising the project.
Calling identify before will prevent flags being fetched twice.
*/
bulletTrain.identify("bullet_train_sample_user"}); //This will create a user in the dashboard if they don't already exist
bulletTrain.setTrait("favourite_colour","blue"); //This save the trait against the user, it can be queried with bulletTrain.getTrait 

//Standard project initialisation
bulletTrain.init({
...

It also seems to work when I try it. Has there been updates since this conversation?
PS: We also really need a setTraits function since having getFlags called for every setTrait is really bad.

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on June 22, 2024

In this example in the documentation setTrait is called before init:

/*
Can be called both before or after you're done initialising the project.
Calling identify before will prevent flags being fetched twice.
*/
bulletTrain.identify("bullet_train_sample_user"}); //This will create a user in the dashboard if they don't already exist
bulletTrain.setTrait("favourite_colour","blue"); //This save the trait against the user, it can be queried with bulletTrain.getTrait 

//Standard project initialisation
bulletTrain.init({
...

It also seems to work when I try it. Has there been updates since this conversation?
PS: We also really need a setTraits function since having getFlags called for every setTrait is really bad.

Yeah none of the conversation really affects this, identify will still not hit the api if it is called before init even after this PR.

RE setTraits, the new API piece is on our staging environment, I'll be doing some final testing against it in the next couple hours.

I'll then be releasing this under version 0.1.0 for both the JS and react-native clients.

from flagsmith-js-client.

davidskaarup avatar davidskaarup commented on June 22, 2024

Yeah none of the conversation really affects this, identify will still not hit the api if it is called before init even after this PR.

But it also calls setTrait just after identify, before init, isn't that what the conversation is about?

RE setTraits, the new API piece is on our staging environment, I'll be doing some final testing against it in the next couple hours.

I'll then be releasing this under version 0.1.0 for both the JS and react-native clients.

That sounds great!

from flagsmith-js-client.

davidskaarup avatar davidskaarup commented on June 22, 2024

Thank you - I will try it out right away 👍

from flagsmith-js-client.

davidskaarup avatar davidskaarup commented on June 22, 2024

@kyle-ssg I have a quick question about setTraits. In the documentation it says:

Setting a value of null for a trait will remove that trait.

Will that work the same way if the value is undefined?

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on June 22, 2024

Going to close this, feel free to re-open if you guys have any issues.

from flagsmith-js-client.

mbugbee avatar mbugbee commented on June 22, 2024

setTrait is still unable to be called before init. It looks like it's expecting api to be set and throwing an error if it isn't. Should that code fallback to the default api value if init hasn't been called?

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.