Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Record that a variant was successful for a user
@param experiment_id : A single experiment id
@param user_id : An identifier for the user
@param client_id : Bernoulli Client ID

        def record_goal_attained(experiment_id, user_id, client_id = None):
    """
    Record that a variant was successful for a user
    @param experiment_id : A single experiment id
    @param user_id : An identifier for the user
    @param client_id : Bernoulli Client ID
    """

    if not client_id:
        client_id = os.environ.get('BERNOULLI_CLIENT_ID')

    if not client_id:
        raise Exception("client_id is required")

    try:
        response = requests.post(BASE_URL, data={
            'clientId': client_id,
            'userId': user_id,
            'experimentId': experiment_id,
        })
    except requests.ConnectionError:
        raise Exception("Unable to access services")

    val = response.json()
    if val['status'] != 'ok':
        raise Exception(val['message'])

    return val['value'] # Should be True
        


src/b/e/bernoulli_django-0.1.8/bernoulli_django/__init__.py   bernoulli_django(Download)
from bernoulli import record_goal_attained
from django.conf import settings
 
def record_variant_goal(request, experiment_id):
    user_id = request.user.id
 
    if request.user.is_anonymous():
        user_id = request.session.get('bernoulli_id', None)
 
    return record_goal_attained(client_id=settings.BERNOULLI_CLIENT_ID, experiment_id=experiment_id, user_id=user_id)