Coder Social home page Coder Social logo

Comments (3)

lomse avatar lomse commented on June 22, 2024 1

Hi @kyle-ssg, thanks for suggesting this approach. Works great.

from flagsmith-js-client.

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

You cannot get whether a user belongs to a segment directly, we may allow such things in the future but that is perhaps a misuse of the library.

The idea of segments is to control feature flags and remote config with segment overrides.

For your scenario of "trial users" you have 2 options:

Option 1: use setTrait and getTrait to detect and set whether the user is a "trial user".

Although this approach is simple it may not give you the most flexibility.

Suggested approach

It's better to create a feature called "trial_user" and override its enabled state for a segment. I'll explain with some screenshots here to give you a better idea of how this would work:

Step 1 : Create your feature flag for trial users, using whatever default you feel is best for on or off

image

Step 2: Create a segment that drives the feature flag

image

Step 3: Set the feature flag to be turned on for that segment

image

Your code would then be driven by bulletTrain.hasFeature. You'd also get the additional benefit of being able to override this feature on a per user basis / add other segments that have this feature enabled e.g by an email address regex.

from flagsmith-js-client.

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

Hopefully this answers your question! If not feel free to reply and I'll get back to you.

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.