Users

A user is an identified unique individual evaluated on each project environment. Each time your application sent via SDK a new user with id and attributes, it's created as a user in Koople platform.

Let's see how this works with the SDK

import {PFClient} from "@pataflags/sdk-js";

const user = { 
    "id": "anonymous", 
    "context": { 
        "country": "atlantis" 
    }
};

const user1 = { 
    "id": "1", 
    "context": { 
        "email": "user1@koople.io", 
        "firstname": "user", 
        "lastname": "one", 
        "country": "gondor", 
        "age": 33 
    }
};

const user2 = { 
    "id": "2", 
    "context": { 
        "email": "user2@koople.io", 
        "firstname": "user", 
        "lastname": "two", 
        "country": "lilliput", 
        "age": 19 
    }
};

const pfclient = PFClient.initialize('YOUR_API_KEY', user);
const pfclient1 = PFClient.initialize('YOUR_API_KEY', user1);
const pfclient2 = PFClient.initialize('YOUR_API_KEY', user2);

When the SDK calls the Koople platform, each user and his context is saved. Then you can see this information in the Users section.

The user icon is getting from Gravatar, so if the user has an image associated with the email, it will be displayed in the logs.

The email, identity, firstname and lastname are recognized data in the audit logs. Consider adding this information in your context to provide more information to the logs.

Moreover, when you click in the user row, you can see the saved additional information (the context). As you can see in the below image, in the top bar, the user is identified by his identifier. The left box has the user context data, and the right box has the last evaluation result of all active release toggles for the user.

Let's change add a new attribute to the user 2.

import {PFClient} from "@pataflags/sdk-js";

const user2 = { 
    "id": "2", 
    "context": { 
        "email": "user2@koople.io", 
        "firstname": "user", 
        "lastname": "two", 
        "country": "lilliput", 
        "age": 19,
        "vip": true
    }
};

const pfclient2 = PFClient.initialize('YOUR_API_KEY', user2);

Then, the user data and evaluation results change automatically.

Last updated