veeta-tv / roku-gamp

Google Analytics Measurement Protocol for Roku
MIT License
13 stars 4 forks source link

Any objection for me working on making calls async #5

Closed doapp-ryanp closed 7 years ago

doapp-ryanp commented 7 years ago

Wondering if you have any reason for me not to put work into making this lib do async HTTP calls to GA servers vs the current sync calls. If not I will do the work and send along a PR

silentpickle commented 7 years ago

Totally worthwhile, IMHO.

I did this for my former job's GA, and I really wanted to do it better and generalize it a bit...but, well... time hasn't been kind to me around the holidays, ever.

Generally -

requests = GetGlobalAA().requests 'cycle through any requests resolved as 200 to clean them up. for each request in requests if(type(request) = "roUrlTransfer") port = request.GetMessagePort() msg = port.GetMessage() ' yadda yadda yadda

request = postasync() requests.push(request)

cdthompson commented 7 years ago

Making those async would be great. Depending on how much time you want to invest, I see 2 approaches.

1) Use AsyncPost...() to make calls to multiple tracking ids in parallel, though the sendHit() is still synchronous until they all finish. 2) Use the globalAA as silentpickle suggested in order to make sendHit() async itself.

doapp-ryanp commented 7 years ago

Thanks for the quick response and suggestions. I have a xmas deliverable and I'm a brs noob so I'll see what I can sneak in with the time I got leftover when I'm done developing my channel. Be in touch soon...

doapp-ryanp commented 7 years ago

This is a bit un-related but its driving me nuts. According to sdk docs:

Functions declared with the FUNCTION statement are at global scope, unless they are anonymous, in which case they are local scope.

But this is not what I'm seeing. I have the following logging function that I'd like to put in source/common/utils.brs:

Function getLogTs() as String
    d = createObject("roDateTime")
    return "m"+d.GetMinutes().ToStr()+"s"+d.GetSeconds().ToStr()+" "
End Function

However I can not call this function from any of my component .brs files. Furthermore, a FUNCTION I define in one component .brs file is not call'albe (not defined) from another component .brs file.

Any idea wtf this is? Can you point me to some docs?

I am passing metric data from the render threads to the main thread just fine (via port) but like stupid utility functions that have nothing to do with threading, I want to put in a common utils.brs file.

silentpickle commented 7 years ago

I honestly didn't know anonymous functions were an option in brightscript.

That should totally work.

A couple things to watch out for -

doapp-ryanp commented 7 years ago

I know the function works because if I include the function definition in the components .brs file it works fine. If I then move the function definition to source/common/utils.brs it says cant find function. Yea I've seen that quirk with the eclipse plugin as well, the file is indeed included. I have also defining the function in main.brs and I still get function not found error.

NBD figured you may know off the top of your head.

silentpickle commented 7 years ago

FYI: that eclipse plugin occasionally goofs and starts spacing things very weirdly. If that happens, stop typing immediately and exit. Don't save.

doapp-ryanp commented 7 years ago

thanks for heads up. haven't had that luckily in this 1st week i've been working with it. It does forget my deploy to ip about every 10 deploys which is really fn annoying.

cdthompson commented 7 years ago

@doapp-ryanp if you need functions defined in files other than the .brs file you reference in the Githubissues.

  • Githubissues is a development platform for aggregating issues.