@snowplow/roku-tracker
v0.2.0
Published
Roku tracker for Snowplow
Downloads
7
Readme
Roku Analytics for Snowplow
Snowplow is a scalable open-source platform for rich, high quality, low-latency data collection. It is designed to collect high quality, complete behavioral data for enterprise business.
To find out more, please check out the Snowplow website and our documentation.
Snowplow Roku Tracker Overview
The Snowplow Roku Tracker allows you to add analytics to your Roku apps when using a Snowplow pipeline.
With this tracker you can collect granular event-level data as your users interact with your Roku applications.
Technical documentation can be found for each tracker in our Documentation.
Quick Start
Installation Using Roku Package Manager (ropm)
Install the package using ropm in your project:
ropm install snowplow@npm:@snowplow/roku-tracker
Manual Installation
- Download and unpack the
dist.zip
ordist.tar.gz
package from the latest release build on Github. - Copy the following folders and files to your Roku project:
- Contents of
dist/source
into yoursource
directory - Contents of
dist/components
into yourcomponents
directory
- Contents of
Using the Tracker
It is recommended that you instantiate Snowplow and add it to the global scope.
In this way, it will be accessible from anywhere within your SceneGraph application.
You may create the instance in the init
function of your main scene.
If you installed the package using ropm, mount the component as follows:
m.global.AddField("snowplow", "node", false)
m.global.snowplow = CreateObject("roSGNode", "snowplow_Snowplow")
If you installed the package manually, mount the component as follows:
m.global.AddField("snowplow", "node", false)
m.global.snowplow = CreateObject("roSGNode", "Snowplow")
Trackers are initialized by setting the init
property with configuration of the tracker.
Below is an example configuration, please refer to the documentation for a complete specification.
m.global.snowplow.init = {
namespace: "ns1", ' optional, defaults to "default"
network: {
collector: "https://...",
method: "POST",
retryCount: 3 ' optional, defaults to 0
},
subject: {
domainUserId: "",
networkUserId: "",
appId: ""
}
}
You may initialize multiple trackers with different namespaces.
Setting the init
property with the same tracker namespace updates the configuration of the tracker.
When no namespace is given, a namespace with the name "default" is used (both in configuration and when tracking events).
To track events, simply assign their properties as associative arrays to fields corresponding to event types.
Events will be sent to all initialized trackers (with any namespace) when setting the event types on the Snowplow instance.
To send events to a specific tracker, call its namespace as follows: m.global.snowplow.trackerNamespace.structured = {...}
.
The following are some examples of the tracked events.
Please refer to the documentation for specificiation of event properties.
' Tracking a screen view event using all initialized trackers
m.global.snowplow.screenView = {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "HomeScene",
type: "scene",
transitionType: "init"
}
' Tracking a screen view event using a tracker with the namespace "ns1"
m.global.snowplow.ns1.screenView = {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "HomeScene",
type: "scene",
transitionType: "init"
}
' Tracking a self-describing events
m.global.snowplow.selfDescribing = {
data: {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "name",
type: "type"
},
schema: "iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0"
}
' Tracking a structured event
m.global.snowplow.structured = {
namespace: "otherNamespace",
se_ca: "category",
se_ac: "action",
se_la: "label",
se_pr: "property",
se_va: 10
}
' Adding context to an event
m.global.snowplow.structured = {
...
context: [
{
data: {
id: CreateObject("roDeviceInfo").GetRandomUUID(),
name: "contextName",
type: "type"
},
schema: "iglu:com.snowplowanalytics.mobile/screen_view/jsonschema/1-0-0"
}
]
}
To enable video tracking for a Video node, assign a roAssociativeArray
with the video node to the enableVideoTracking
property:
m.global.snowplow.enableVideoTracking = {
video: m.Video
}
Find Out More
| Technical Docs | Setup Guide | |-----------------------------------|-----------------------------| | | | | Technical Docs | Setup Guide |
Maintainers
| Contributing | |----------------------------------------------| | | | Contributing |
Maintainer Quick Start
Assuming git, Node.js 12 LTS or 16 LTS are installed.
The tracker is implemented using BrighterScript.
Clone Repository
git clone https://github.com/snowplow-incubator/snowplow-roku-tracker.git
Building
To build the package in order to include it in other Roku projects:
- Run
npm install
on the project - Install ropm
npm i ropm -g
- Install ropm packages
ropm install
- Run
npm run build
- The package source files will be placed in the
dist
folder and may be copied for use in another Roku project
Demo App
The tracker comes with a demo app that shows it in use. It is a simple video player with a fixed collection of played videos and an interface to switch between them.
The project is located in the src-demo-app
subfolder.
The following steps assume that you have enabled developer mode on your Roku device and it is connected to your network.
Run
npm install
on the projectInstall ropm
npm i ropm -g
Install ropm packages
ropm install
Create
.env
file with environment variables in the root of this repositoryROKU_IP=192.168.100.129 ROKU_PASSWORD=XXXX
Add configuration for Snowplow collector to
src-demo-app/manifest
snowplow_collector=http://192.168.100.127:9090 snowplow_method=POST
Start the demo app using
npm run demo-app
Alternatively, you may run the demo app from Visual Studio Code as the debug configuration is already prepared. Install the BrightScript extension to Visual Studio Code and choose "Run demo app" in the debug options.
Events will be sent to the Snowplow collector as you navigate through the app.
Testing
The tracker functionality is verified using unit and integration tests. Unit tests test individual components of the tracker in isolation and do not make any external network requests. Integration tests use a Snowplow Micro instance to verify end-to-end tracking of events.
The tests are located in the tests
subfolder.
The following steps assume that you have enabled developer mode on your Roku device and it is connected to your network.
Run
npm install
on the projectInstall ropm
npm i ropm -g
Install ropm packages
ropm install
Create
.env
file with environment variables in the root of this repositoryROKU_IP=192.168.100.129 ROKU_PASSWORD=XXXX
Start Snowplow Micro on your computer
Add configuration for your Snowplow Micro (with the network IP of your computer) instance to
tests/manifest
snowplow_collector=http://192.168.100.127:9090 snowplow_method=POST
Run the tests using
npm test
Alternatively, you may run the tests from Visual Studio Code as the debug configuration is already prepared. Install the BrightScript extension to Visual Studio Code and choose "Run tests" in the debug options.
Copyright and License
The Snowplow Roku Tracker is copyright 2021 Snowplow Analytics Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.