def js_code_snippet(): api_id = get_create_api() api_region = region() endpoint = TRACK_ENDPOINT logger.info('AlephBet JS code snippet:') logger.info(""" <!-- Copy and paste this snippet to start tracking with gimel --> <script src="https://unpkg.com/alephbet/dist/alephbet.min.js"></script> <script> // * javascript code snippet to track experiments with AlephBet * // * For more information: https://github.com/Alephbet/alephbet * track_url = 'https://%(api_id)s.execute-api.%(api_region)s.amazonaws.com/prod/%(endpoint)s'; namespace = 'alephbet'; experiment = new AlephBet.Experiment({ name: 'my a/b test', tracking_adapter: new AlephBet.Gimel(track_url, namespace), // trigger: function() { ... }, // optional trigger variants: { 'red': function() { // add your code here }, 'blue': function() { // add your code here } } }); </script> """ % locals())
def create_update_api(role_arn, function_arn, wiring): logger.info("creating or updating api /{}".format(wiring["pathPart"])) api_id = get_create_api() resource_id = resource(api_id, wiring["pathPart"]) uri = function_uri(function_arn, region()) api_method(api_id, resource_id, role_arn, uri, wiring) cors(api_id, resource_id)
def create_update_api(role_arn, function_arn, wiring): logger.info('creating or updating api /{}'.format(wiring['pathPart'])) api_id = get_create_api() resource_id = resource(api_id, wiring['pathPart']) uri = function_uri(function_arn, region()) api_method(api_id, resource_id, role_arn, uri, wiring) cors(api_id, resource_id)
def js_code_snippet(): api_id = get_create_api() api_region = region() endpoint = TRACK_ENDPOINT logger.info('AlephBet JS code snippet:') logger.info( """ <!-- Copy and paste this snippet to start tracking with gimel --> <script src="https://bowercdn.net/c/alephbet-0.12.0/dist/alephbet.min.js"></script> <script> // * javascript code snippet to track experiments with AlephBet * // * For more information: https://github.com/Alephbet/alephbet * track_url = 'https://%(api_id)s.execute-api.%(api_region)s.amazonaws.com/prod/%(endpoint)s'; namespace = 'alephbet'; experiment = new AlephBet.Experiment({ name: 'my a/b test', tracking_adapter: new AlephBet.Gimel(track_url, namespace), // trigger: function() { ... }, // optional trigger variants: { 'red': function() { // add your code here }, 'blue': function() { // add your code here } } }); </script> """ % locals() )
def dashboard_url(namespace="alephbet"): api_id = get_create_api() api_region = region() endpoint = EXPERIMENTS_ENDPOINT experiments_url = "https://{}.execute-api.{}.amazonaws.com/prod/{}".format(api_id, api_region, endpoint) return ("https://fiddle.jshell.net/x9gr2xst/?experiment_url={}" "&api_key={}&namespace={}").format( experiments_url, get_api_key(), namespace )
def dashboard_url(namespace='alephbet'): api_id = get_create_api() api_region = region() endpoint = EXPERIMENTS_ENDPOINT experiments_url = 'https://{}.execute-api.{}.amazonaws.com/prod/{}'.format( api_id, api_region, endpoint) return ('https://fiddle.jshell.net/x9gr2xst/?experiment_url={}' '&api_key={}&namespace={}').format(experiments_url, get_api_key(), namespace)
def preflight_checks(): logger.info('checking aws credentials and region') if region() is None: logger.error('Region is not set up. please run aws configure') return False try: check_aws_credentials() except AttributeError: logger.error('AWS credentials not found. please run aws configure') return False logger.info('testing redis') try: from gimel import _redis _redis().ping() except: logger.error('Redis ping failed. Please run gimel configure') return False return True