Skip to main content

Roku SDK Getting Started

GitHub

Initializing the SDK

We recommend initializing the SDK once and passing around the client instance around in your app. Initialize the DevCycle SDK by providing the DevCycle User, DevCycle mobile SDK key and any other start options along with the relevant TaskNode as defined in the MainScene.xml:

<!-- Within your MainScene.xml -->
<?xml version="1.0" encoding="utf-8" ?>
<component name="MainScene" extends="Scene">
<script type="text/brightscript" uri="MainScene.brs" />
<script
type="text/brightscript"
uri="pkg:/components/DevCycle/DevCycleSGClient.brs"
/>
<children>
<DevCycleTask id="devCycleTask" />
<!-- Other Child Nodes / Elements -->
</children>
</component>
// Within your MainScene.brs
sub init()
...
m.devCycleTask = m.top.findNode('devCycleTask')

sdkKey = '<DEVCYCLE_MOBILE_SDK_KEY>'
options = {
enableEdgeDB: true,
}
user = {
user_id: 'my_user_id',
}

InitializeDevCycleClient(sdkKey, user, options, m.devCycleTask)
m.devcycleClient = DevCycleSGClient(m.devCycleTask)
...
end sub

The user object may specify a unqiue user_id for a given User. If the user_id is not specified, the User is considered to be anonymous and we will utilize the Device ID as a unique identifier.

DevCycle Client

The DevCycleClient can be built using the following methods:

DevCycle Client

MethodParameterDescription
sdkKeyStringDevCycle SDK Key
userDevCycleUserDevCycle User object
optionsDevCycleOptionsDevCycle Options object

DevCycle User Object

The DevCycleUser can be built using the following methods DevCycleUser. Passing an empty string for the user_id will result in a thrown error. In order to create an anonymous user, omit passing a user_id.

MethodParameterDescription
user_idStringUnique user ID
nameStringUser's name
emailStringUser's email
countryStringUser's country
customDataJSONKey/value map of properties to be used for targeting.
privateCustomDataJSONKey/value map of properties to be used for targeting. Private properties will not be included in event logging.

DevCycle Options

The SDK exposes various initialization options which can be used by passing a DevCycleOptions object to the options parameter of InitializeDevCycleClient method:

DevCycle Options

MethodParameterDefaultDescription
flushEventsIntervalMsInt10000Controls the interval between flushing events to the DevCycle servers in milliseconds, defaults to 10 seconds.
enableEdgeDBBooleanfalseEnables the usage of EdgeDB for DevCycle that syncs User Data to DevCycle.
disableAutomaticEventLoggingBooleanfalseDisables logging of sdk generated events (e.g. variableEvaluated, variableDefaulted) to DevCycle.
disableCustomEventLoggingBooleanfalseDisables logging of custom events, from track() method, and user data to DevCycle.
apiProxyURLStringinvalidAllows the SDK to communicate with a proxy of DevCycle Client SDK API.
eventsApiProxyURLStringinvalidAllows the SDK to communicate with a proxy of DevCycle Events API.