Sha256: ec97686199c467bfafa4a3eb56f170c5481d47a30af6e5dc59bdcedf83f7834e

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

require 'sinatra'
require "sinatra/reloader" if development?
require 'devcycle-server-sdk'

token = ARGV[0]

if !token 
    fail Exception, 'Must provide server SDK token'
end

DevCycle.configure do |config|
    # Configure API key authorization: bearerAuth
    config.api_key['bearerAuth'] = token
    # config.debugging = true
end

api_instance = DevCycle::DVCClient.new
user_data = DevCycle::UserData.new({
    user_id: 'my-user',
    app_version: '1.2.3'
})

get '/' do
  'Hello world!'
end

get '/experiment' do
    result = api_instance.variable("test-feature", user_data, false)
    p result

    "Your variable result is: #{result.value}"
end

get '/track-event' do
    event_data = DevCycle::Event.new({        
        # type: "my-event",
        target: "some_event_target",
        value: 12,
        meta_data: {
            myKey: "my-value"
        }
    })

    result = api_instance.track(user_data, event_data)

    p result
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/devcycle-server-sdk-1.0.1/examples/sinatra/app.rb
devcycle-server-sdk-1.0.1 examples/sinatra/app.rb