i’m trying to put a global object full of functions and attributes that allows the app to report videoplayer events and app events to Google Analytics, the app uses SceneGraph
i’ve tried put the object into ‘m.global’ on ‘main.brs’ file, but the scope is not global, it only works on that file.
i’ve tried to create a notification port and listen to it, but when setting ‘m.port’ on player.ObserveField(“position”,“m.port”) in another file, the ‘m.port’ property is invalid, again a scope problem.
The custom object has the following structure:
function GA() as Object
return{
init : function (init_args) as Void
//init code
end function
func_1 : function()
end function
'and many other functions to report events
}
there is one method that will receive all the notifications “handleScenegraphEvent”, notification in form of messages of node.ObserveField
i’ve tried putting the object into ‘m’ as follows in ‘main.brs’:
To access the “global Noid” from main, you have to call roSGScreen.getGlobalNode(). For consistency, it’s advisable in main() you manually assign that to m.global and continue using that m.global, as in other threads:
Hey, thanks for the quick reply, i just find out that problem with function type, my second option is setting a global port to all fields i want to observe, can i use “m.global = screen.getGlobalNode” to pass the port all over the app?
“cescamilla” wrote:
Hey, thanks for the quick reply, i just find out that problem with function type, my second option is setting a global port to all fields i want to observe, can i use “m.global = screen.getGlobalNode” to pass the port all over the app?
You mean, do roSgNode fields support roMessagePort (or more generally, Object) type? No, they do not!
A list of what is supported is here a very particular set of skills.
If you want to do what you say you want to do: report video player events to Google Analytics, then define a Task Node to do the reporting. Include the Task Node in your scene that contains the Video Node, then whenever you have an event to log, set the event details in an interface field defined on the Task Node; in the Task Node, use roUrlTransfer to send the request to Google Analytics.
ohh i see, that’s the full app cycle, i’m able to see requests been made, but not reflected in Google Analytics Dashboard, i’ll worry about that later, for now i’ll check how to integrate that functionality with the existing app.
Thanks for the failing test note. That was a preemptive test for a corner case which is unlikely to happen. I opened a github issue to track it https://github.com/veeta-tv/roku-gamp/issues/13.