Flurry and Storyboard

Hi,

I’m using Flurry in an app which uses storyboard. So far Flurry registers events without a problem but I’m wondering if the way I’ve implemented the code was correct.

I have this code In my main.lua file:

analytics = require( "analytics" ) analytics.init( "THE\_API\_KEY" )

And then, in every single scene I log an event once we enter the scene:

function scene:enterScene( event ) --Some code here --Log event analytics.logEvent("SOME\_INFO\_HERE") end

Is this the correct implementation? I mean, declare “analytics” as a global variable

Should I declare it as a local variable and initialize it in every single scene?

Thanks for your help.

Paolo G

Did you ever get an answer on this?

You could do what you suggested (use analytics a a global), but ideally you should make it a local variable.

Even as a global variable, you dont need to run analytics.init() every single time you need it… you can just do:

local analytics = require(“analytics”)

analytics.logEvent(“SOME_INFO_HERE”)

as long as you have initialized it beforehand (eg. in your main.lua)

In Lua after you load a module for the first time, it stays in memory until it’s un-required.   The reason you do local somemodule = require(“somemodule”) is so that your scene has a local reference to the module instead of a global reference.  This improves performance and helps prevent global stomping of objects.

Rob

Use composers

Did you ever get an answer on this?

You could do what you suggested (use analytics a a global), but ideally you should make it a local variable.

Even as a global variable, you dont need to run analytics.init() every single time you need it… you can just do:

local analytics = require(“analytics”)

analytics.logEvent(“SOME_INFO_HERE”)

as long as you have initialized it beforehand (eg. in your main.lua)

In Lua after you load a module for the first time, it stays in memory until it’s un-required.   The reason you do local somemodule = require(“somemodule”) is so that your scene has a local reference to the module instead of a global reference.  This improves performance and helps prevent global stomping of objects.

Rob

Use composers

Hey guys!

Sorry for the late response, I’ve been very unplugged from the forums. Thanks for your advices. I’ll definitely check the docs to migrate from storyboard to composer.

Best regards,

Paolo

Anytime bro

Hey guys!

Sorry for the late response, I’ve been very unplugged from the forums. Thanks for your advices. I’ll definitely check the docs to migrate from storyboard to composer.

Best regards,

Paolo

Anytime bro