Skip to main content

VWO Feature Management and Experimentation SDK for Python

Project description

VWO Feature Management and Experimentation SDK for Python

PyPI version CI codecov License

This open source library allows you to A/B Test your Website at server-side.

Requirements

  • Works with Python: 3.6 onwards.

Installation

It's recommended you use virtualenv to create isolated Python environments.

pip install vwo-fme-python-sdk

Basic usage

from vwo import init

options = {
    'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
    'account_id': '123456' # VWO Account ID
}

vwo_client = init(options)

# set user context
user_context = {'id': 'unique_user_id'}
# returns a flag object
get_flag = vwo_client.get_flag('feature_key', user_context)
# check if flag is enabled
is_enabled = get_flag.is_enabled()
# get varible
int_var = get_flag.get_variable('int_variable_key', 'default_value')

# track event
vwo_client.track_event('event_name', user_context, event_properties)

# set attribute
vwo_client.set_attribute('attribute_key', 'attribute_value', user_context)
  • Storage
from vwo import StorageConnector
class UserStorage(StorageConnector):
    def get(self, key: str, user_id: str):
        return client_db.get(f"{key}_{user_id}")

    def set(self, value: dict):
        key = f"{value.get('featureKey')}_{value.get('user')}"
        client_db[key] = {
            'rolloutKey': value.get('rolloutKey'),
            'rolloutVariationId': value.get('rolloutVariationId'),
            'rolloutId': value.get('rolloutId'),
            'experimentKey': value.get('experimentKey'),
            'experimentVariationId': value.get('experimentVariationId'),
            'experimentId': value.get('experimentId'),
        }
        return True
        
options = {
    'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
    'account_id': '123456', # VWO Account ID
    'storage': UserStorage()
}

vwo_client = init(options)
  • Log messages
from vwo import LogLevelEnum
options = {
    'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
    'account_id': '123456', # VWO Account ID
    'logger': {
        'level': LogLevelEnum.DEBUG,
        'prefix': 'VWO-FME-PYTHON-SDK'
    }
}

vwo_client = init(options)
  • Polling support
options = {
    'sdk_key': '32-alpha-numeric-sdk-key', # SDK Key
    'account_id': '123456', # VWO Account ID
    'poll_interval': 5000 # in milliseconds
}

vwo_client = init(options)

Local development

python setup.py develop

Running Unit Tests

python setup.py test

Authors

Changelog

Refer CHANGELOG.md

Contributing

Please go through our contributing guidelines

Code of Conduct

Code of Conduct

License

Apache License, Version 2.0

Copyright 2024 Wingify Software Pvt. Ltd.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vwo-fme-python-sdk-1.0.0.tar.gz (54.5 kB view details)

Uploaded Source

File details

Details for the file vwo-fme-python-sdk-1.0.0.tar.gz.

File metadata

  • Download URL: vwo-fme-python-sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.0

File hashes

Hashes for vwo-fme-python-sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6f2da42b56adf87e72955201b8f10843ba5de3e67fe5c3dd1d9b9e8141d7a537
MD5 10db4a67cb714cb0a4909536e9fdf7cf
BLAKE2b-256 3c9a29f768a29d7cee6d35d3103e8d89403f44ea8b1853d3abbd53810d6c7ea4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page