Search code examples
ibm-mobilefirstworklight-analytics

Worklight Analytics, Native Java API, no messages in dashboard


Worklight 6.2.0 Native Worklight App on Samsung Galaxy S4, Android 4.4.2

WLAnalytics.enable();
WLAnalytics.log("some text", new org.json.JSONOBject() );
WLAnalytics.send();

// and also go on to successfully call an adapter

Analytics Dasboard shows the app version and adapter activity. Log Search does not show any application log messages and the dropdown for selecting applications shows "All Applications" only, no sign of my app.

Have I missed some initialisation step? Any other ideas?

** edited to add **

It has been suggested that we should use the method:

 WLAnalytics.log("some text");

In our 6.2.0.00 CLI environment there is no such Java method.


Solution

  • The answer is that there a further initialisation requirement that seems to be necessary when working with a pure Native application, these are typically build using the Worklight CLI tooling.

    This is the initialisation, note the call to Logger.setContext()

        WLAnalytics.enable();
        Logger.setContext(this);
    

    Then this works

        WLAnalytics.log("My test message2", new org.json.JSONObject());
    

    It's worth noting that the call to WLAnalytics.send() is not necessary in normal running as typically the analytic data is buffered and sent as a piggy-back on adapter calls. However while testing a call to send() does help.

    Further, if running in an environment where the Analytics WAR is on a separate machine from the Worklight Server WAR there are additional latencies. Hence testing all of this needs care.