Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Latest commit

 

History

History
195 lines (131 loc) · 11.7 KB

index_backup.md

File metadata and controls

195 lines (131 loc) · 11.7 KB
copyright lastupdated
years
2016, 2017, 2019
2019-02-17

{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen:.screen} {:codeblock:.codeblock}

Getting started tutorial

{: #gettingstartedtemplate}

{{site.data.keyword.mobileanalytics_full}} provides developers, IT administrators, and business stakeholders insight into how their mobile apps are performing and how they are being used. {{site.data.keyword.mobileanalytics_short}} enables you to:

  • Monitor performance and usage of all your applications from your desktop or tablet.
  • Quickly identify trends and anomalies, drill down to resolve issues, and trigger alerts when key metrics cross critical thresholds. {: shortdesc}

To quickly get the {{site.data.keyword.mobileanalytics_short}} service up and running, follow these steps:

  1. After you create an instance of the {{site.data.keyword.mobileanalytics_short}} service, you can access the {{site.data.keyword.mobileanalytics_short}} Console by clicking your tile in the Services section of the {{site.data.keyword.Bluemix}} Dashboard. A demo mode option is available in the {{site.data.keyword.mobileanalytics_short}} console, whereby the views and charts display demo data. Demo mode is the default mode of the console when it initially launches after the service is instantiated. When you have your own applications and analytics data populated into the service, you can toggle off the demo mode to view your applications' data in the different charts. The {{site.data.keyword.mobileanalytics_short}} console is read-only when in demo mode, therefore you will not be able to create new alert definitions.

  2. Install the {{site.data.keyword.mobileanalytics_short}} Client SDKs. You can optionally use the {{site.data.keyword.mobileanalytics_short}} REST API External link icon{:new_window}.

    • Web App Service Configuration

      For Web SDK, to configure your service instance to allows an app server, you need to provide the URL of your app server through the Service Confiuration REST API through Swagger UI. POST, GET, PUT and DELETE methods are provided for CRUD operations of the service configuration which is a list of allowed URL's. To GET and DELETE configurations of your service instance, use your API key. To create and update the service configuration, use POST and PUT methods with allowed URLs listed as body {"allowedUrls":["http://abc.com","https://www.xyz.com"]}. If you are accessing from a browser in the same system as that of the web server, provide "http://localhost" as the allowed URL.

  3. Import the Client SDKs and initialize them with the following code snippet to record usage analytics:

    • Android

      Add the following import statements to the beginning of your project file:

       import com.ibm.mobilefirstplatform.clientsdk.android.core.api.*;
       import com.ibm.mobilefirstplatform.clientsdk.android.analytics.api.*;
       import com.ibm.mobilefirstplatform.clientsdk.android.logger.api.*;
      

      {: codeblock}

    • iOS

      The Swift SDK is available for iOS and watchOS.

      Import the BMSCore and BMSAnalytics frameworks by adding the following import statements to the beginning of your AppDelegate.swift project file:

       import BMSCore
       import BMSAnalytics

      {: codeblock}

    • Cordova

      Add the Cordova plugin by running the following command from your Cordova application root directory:

       cordova plugin add bms-core

      {: codeblock}

    • Web

      Add the web plugin by either adding this script in the index.html file of web app:

       <script src="bms-clientsdk-web-analytics/bmsanalytics.js"></script>

      {: codeblock}

      Or by using module loader requirejs. The name used as reference API is same as the argument name (BMSAnalytics) used.

       require.config({
       'paths': {
           'bmsanalytics': 'bms-clientsdk-web-analytics/bmsanalytics'
       	}
       });
       	require(['bmsanalytics'], function(BMSAnalytics) {
           BMSAnalytics.send();
       }

      {: codeblock}

  4. Initialize the {{site.data.keyword.mobileanalytics_short}} Client SDK in your application code to record usage analytics and application sessions, using your API Key value.

    • Android

       BMSClient.getInstance().initialize(getApplicationContext(), BMSClient.REGION_US_SOUTH); // You can change the region
       Analytics.init(getApplication(), "your_app_name_here", "your_api_key_here", hasUserContext, collectLocation, Analytics.DeviceEvent.ALL);
      

      {: codeblock}

      The bluemixRegion parameter specifies which {{site.data.keyword.Bluemix_notm}} deployment you are using, for example, BMSClient.REGION_US_SOUTH and BMSClient.REGION_UK.

      Set the value for hasUserContext to true or false. If false (default value), each device is counted as an active user.

      Set the value for collectLocation to true or false. If true the device location data will be sent as part of the Appsession log.

    • iOS

      Initialize the Client SDK inside your application code to record usage analytics and application sessions, using your API Key value.

       BMSClient.sharedInstance.initialize(bluemixRegion: BMSClient.Region.usSouth) // You can change the region
       Analytics.initialize(appName: "your_app_name_here", apiKey: "your_api_key_here", hasUserContext: false, collectLocation: true, deviceEvents: deviceEvents: .lifecycle, .network)

      {: codeblock}

      The bluemixRegion parameter specifies which IBM Cloud deployment you are using, for example, BMSClient.Region.usSouth or BMSClient.Region.unitedKingdom.

      Set the value for hasUserContext to true or false. If false (default value), each device is counted as an active user.

      Set the value for collectLocation to true or false. If true the device location data will be sent as part of the Appsession log.

    • Cordova

      Initialize the Client SDK inside your application code to record usage analytics and application sessions, using your API Key value.

       var appName = "your_app_name_here";
       var apiKey = "your_api_key_here";
       BMSClient.initialize(BMSClient.REGION_US_SOUTH); // You can change the region
       BMSAnalytics.initialize(appName, apiKey, hasUserContext, collectLocation, [BMSAnalytics.ALL])
      

      {: codeblock}

      The bluemixRegion parameter specifies which IBM Cloud deployment you are using, for example, BMSClient.REGION_US_SOUTH or BMSClient.REGION_UK.

      Set the value for hasUserContext to true or false. If false (default value), each device is counted as an active user.

      Set the value for collectLocation to true or false. If true the device location data will be sent as part of the Appsession log.

    • Web

      Initialize the Client SDK inside your application code to record usage analytics and application sessions, using your API Key value.

       var appName = "your_app_name_here";
       var apiKey = "your_api_key_here";
       BMSAnalytics.Client.initialize(BMSAnalytics.Client.REGION_US_SOUTH);
       BMSAnalytics.initialize(appName,apiKey,hasUserContext,BMSAnalytics.DeviceEvents.ALL,instanceId);
      

      {: codeblock}

      The bluemixRegion parameter specifies which {{site.data.keyword.Bluemix_notm}} deployment you are using, for example, BMSAnalytics.Client.REGION_US_SOUTH and BMSAnalytics.Client.REGION_UK. Set the value for hasUserContext to true or false. If false (default value), each device is counted as an active user.Set the instanceId to your service instanceId, its a alphanumeric string which you get from the browser url for your service instance after the string "...mobile-analytics_Prod/" and upto "/".

      Note that the name that you select for your application (your_app_name_here) displays in the {{site.data.keyword.mobileanalytics_short}} console as the application name. The application name is used as a filter to search for application logs in the dashboard. When you use the same application name across platforms (for example, Android and iOS), you can see all logs from that application under the same name, regardless of which platform the logs were sent from.

  5. Send recorded usage analytics to the {{site.data.keyword.mobileanalytics_short}} service. A simple way to test your analytics is to run the following code when your application starts:

    • Android

      Use the Analytics.send() method to send analytics data to the server. You can place the Analytics.send() method anywhere in the onCreate method of the main activity in your Android application, or in a location that works best for your project.

      You can insert Analytics.send() anywhere.

    • iOS

      Use the Analytics.send method to send analytics data to the server. You can place the Analytics.send method anywhere in the application(_:didFinishLaunchingWithOptions:) method of your application delegate, or in a location that works best for your project.

    • Cordova

      Use the BMSAnalytics.send method to send analytics data to the server. Place the BMSAnalytics.send method in a location that works best for your project.

    • Web

      Use the BMSAnalytics.send method to send analytics data to the server. Place the BMSAnalytics.send method in a location that works best for your project.

  6. Go through the Instrumenting your application topic to learn about additional {{site.data.keyword.mobileanalytics_short}} capabilities, such as logging, network requests, location logging and crash analytics.

  7. Compile and run the application on your emulator or device.

  8. Go to the {{site.data.keyword.mobileanalytics_short}} console to see usage analytics for your application. You can also monitor your application by setting alerts and monitoring app crashes.

Related Links

{: #rellinks notoc}

SDK

{: #sdk notoc}

API Reference

{: #api notoc}