How to make sure Flurry is set up properly?

Hi,

I followed both instructions SDKBOX installer and Cocos Helper (JavaScript) and then followed the instructions to install Flurry Analytics and looked at Flurry sample but I have a question on how to use Flurry.

Where am I supposed to put all of this code:

    // Flurry Analytics
    this.session_created = false
    var self = this
        // Flurry Event Listener
    sdkbox.PluginFlurryAnalytics.setListener({
        flurrySessionDidCreateWithInfo: function (info) {
            self.session_created = true
            var jsonInfo = JSON.parse(info)
            console.log("Menu session started")
            console.log("APIKey :" + jsonInfo.apiKey + " session id :" + jsonInfo.sessionId);
            sdkbox.PluginFlurryAnalytics.logEvent("Log menu session", JSON.stringify({
                "eKey1": "eVal1",
                "eKey2": "eVal2"
            }));
        }
    });
    sdkbox.PluginFlurryAnalytics.init(); // Initialize Flurry Analytics
    sdkbox.PluginFlurryAnalytics.startSession(); // Start a Flurry session
    sdkbox.PluginFlurryAnalytics.setCrashReportingEnabled(true); // Enable crash reports by Flurry
    sdkbox.PluginFlurryAnalytics.logPageView(); // Track a page view during session

I have put it in my app.js file in the ctor: function() { is this the right spot? And am I supposed to do this for every page of my app? i.e. menu scene and again in play scene?

Thanks!

Hello @efares

You need to initialize once in your appdelegate and then set listeners for every scene.
So basically, set listener for every scene and remove the listener on moving out of current scene to some other scene, then it will be fixed.

Best,
Pabitra

1 Like

Thanks for the reply @pabitrapadhy but in my AppDelegate.cpp file I have:

#include "PluginFlurryAnalyticsJS.hpp"
#include "PluginFlurryAnalyticsJSHelper.h"

and

sc->addRegisterCallback(register_all_PluginFlurryAnalyticsJS);
sc->addRegisterCallback(register_all_PluginFlurryAnalyticsJS_helper);

Which were inserted there automatically when I used the installer from the terminal/console.

  1. Is this all that is needed to initialize?
  2. So I should start a new session in every scene right?

Just having sdkbox.PluginFlurryAnalytics.init(); only in my app.js causes the reference error of sdkbox not defined.

Hello @efares

Please check with our Flurry sample -
https://github.com/sdkbox/sdkbox-flurry-sample

Best,
Pabitra

Thanks for the link.

Can you explain to me what is happening in app.js? In terms of setting up/initializing Flurry.

Thanks.