• /
  • EnglishEspañolFrançais日本語한국어Português
  • Log inStart now

Get started with Roku agent

The New Relic Roku Agent is designed to monitor the behavior of Roku applications, focusing on system-level and video-related events. It uses the Event API to send data via a REST interface, supporting five types of events:

  • ConnectedDeviceSystem: System events
  • VideoAction: Video events
  • VideoErrorAction: Error events
  • VideoAdAction: Ad events
  • VideoCustomAction: Custom events

Prerequisites

Before you install the Streaming Video & Ads agent for Roku, ensure you have:

  • Your New Relic account ID
  • Your New Relic
  • Reviewed the Streaming Video & Ads agent compatibility requirements

Install the Roku agent

Download and extract package

Download the Roku Video Agent package and unzip it to access the following file structure:

components/NewRelicAgent/
NRAgent.brs
NRAgent.xml
NRTask.brs
NRTask.xml
source/
NewRelicAgent.brs

Copy files to your project

Copy the NewRelicAgent folder to the components directory and the NewRelicAgent.brs file to the source directory of your Roku app project.

Initialize the agent

Initialize the New Relic Agent in your main BrightScript file (e.g., Main.brs):

m.nr = NewRelic("ACCOUNT ID", "LICENSE KEY")

Tip

Advanced configuration: You can optionally specify app name, application token, endpoint region, and logging:

m.nr = NewRelic("ACCOUNT ID", "LICENSE KEY", "APP NAME", "APPLICATION TOKEN", "US", true)

The default endpoint is US. For EU data centers, use EU.

Enable event captures

The New Relic media agent for Roku devices captures events that occur during the playback of video content. To enable automatic event capture, add these calls to your application:

Log application start

After initializing the agent, log the application start event:

nrAppStarted(m.nr, aa)

Enable system and video tracking

Activate system and video event tracking:

m.syslog = NewRelicSystemStart(m.port)

For video tracking, call NewRelicVideoStart(m.nr, m.video) in your scene component.

Process messages in wait loop

Handle system events in your main wait loop:

if nrProcessMessage(m.nr, msg) = false
' Process other messages
end if

Complete example

Below is a complete example of integrating the New Relic Agent into a Roku application:

Main.brs

sub Main(aa as Object)
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
'Create the main scene that contains a video player
scene = screen.CreateScene("VideoScene")
screen.show()
'Init New Relic Agent
m.nr = NewRelic("ACCOUNT ID", "LICENSE KEY")
'Send APP_STARTED event
nrAppStarted(m.nr, aa)
'Pass NewRelicAgent object to the main scene
scene.setField("nr", m.nr)
'Activate system tracking
m.syslog = NewRelicSystemStart(m.port)
while (true)
msg = wait(0, m.port)
if nrProcessMessage(m.nr, msg) = false
'It is not a system message captured by New Relic Agent
if type(msg) = "roPosterScreenEvent"
if msg.isScreenClosed()
exit while
end if
end if
end if
end while
end sub

VideoScene.xml

<?xml version="1.0" encoding="utf-8" ?>
<component name="VideoScene" extends="Scene">
<interface>
<!-- Field used to pass the NewRelicAgent object to the scene -->
<field id="nr" type="node" onChange="nrRefUpdated" />
</interface>
<children>
<Video
id="myVideo"
translation="[0,0]"
/>
</children>
<!-- New Relic Agent Interface -->
<script type="text/brightscript" uri="pkg:/source/NewRelicAgent.brs"/>
<script type="text/brightscript" uri="pkg:/components/VideoScene.brs"/>
</component>

VideoScene.brs

sub init()
m.top.setFocus(true)
setupVideoPlayer()
end sub
function nrRefUpdated()
m.nr = m.top.nr
'Activate video tracking
NewRelicVideoStart(m.nr, m.video)
end function
function setupVideoPlayer()
videoUrl = "http://..."
videoContent = createObject("RoSGNode", "ContentNode")
videoContent.url = videoUrl
videoContent.title = "Any Video"
m.video = m.top.findNode("myVideo")
m.video.content = videoContent
m.video.control = "play"
end function

What's next?

After installing the Roku agent, explore these resources to get the most out of your streaming video monitoring:

Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.