Search code examples
swiftibm-mobilefirstxcode7mobilefirst-analytics

MobileFirst Platform Operational Analytics in Native iOS Swift applications


I'm developing a native iOS MobileFirst application in XCode 7 (Swift) and MobileFirst 7.0.

I want to use MobileFirst Operational Analytics and I'm following this guidelines:

[https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/moving-production/operational-analytics/][1]

I have some questions:

  • The sessions should be automatically recorded but it is not being the case of the application. I just see the data for 1 device as connected when more devices have connected the last 24 hours. How can I enable this feature? or it should be automatic with the equivalent of WL.Connect() in native iOS?

  • The adapter calls should be automatic too but can be just be visualized under the tab: Network->Adapters Overview-> Adapter Request & Network->Adapters Overview-> Adapter Request but I can't see the pie charts generated: Calls Per Application Procedure Calls, Calls Per Server. They only show as http requests. How can this charts be generated too?

  • I will like to do custom charts and make use of the WL.Analytics.log(), WL.Analytics.send(), etc. How are this calls translated to swift? I only see this fro Hybrid apps, is there any documentation about this?


Solution

  • Answering 1)

    I realized that I wasn't connecting successfully to the MobileFirst server. Once I successfully connect the sessions were recorded automatically by the the MobileFirst Operatinal Analytics tool. The code is:

    let connectListener = MyConnectListener()
    WLClient.sharedInstance().wlConnectWithDelegate(connectListener)
    

    Answering 2)

    When invoking the adapters in this way, the Mobilefirst Operational Analytics does not collect the information for the pie charts, it registers this calls as http calls:

    let request = WLResourceRequest(URL: NSURL!, method: String!)
    

    You have to invoke the adapters like this so that the pie charts are automatically generated:

    let myInvocationData = WLProcedureInvocationData(adapterName: String!, procedureName: String!)  
    

    Answering 3)

    Using the following code in swift analytics were successfully send to the server.

    let doAnaylitics = WLAnalytics.sharedInstance()
    doAnaylitics.enable()
    doAnaylitics.log("type", withMetadata:["location":location])
    doAnaylitics.send()
    doAnaylitics.disable();