BlackBerry Analytics

Get Started with BlackBerry Analytics

Get Started with BlackBerry Analytics SDK

Add BlackBerry Analytics to a BlackBerry Dynamics app.

Before you begin: BlackBerry Analytics can only be integrated with BlackBerry Dynamics apps. For more information on BlackBerry Dynamics apps , see Getting Started with BlackBerry Dynamics SDK.

  1. Go to the downloads page to download the BlackBerry Analytics SDK for Android or iOS.
  2. Complete the following steps to verify that you are entitled to the BlackBerry Analytics app:

    1.  Log in to the BlackBerry UEM management console.
    2. Click Apps.
    3. Search for BlackBerry Analytics.

If you are entitled to use BlackBerry Analytics, the BlackBerry Analytics app appears in the app list. If you do not see the BlackBerry Analytics app in the app list, you must contact your BlackBerry representative to request entitlement.

1. In the UEM management console, click Users and select the user.

 

2. In the Apps section, click the plus icon.

3. Search for and select the BlackBerry Analytics entitlement.

 

4. Click Next.

5. In the Disposition drop-down list, select Required.

6. Click Assign.

 

  1. Unzip the BlackBerry Analytics framework.
  2. Under the Build Phases of the application target, add BAFBlackberryAnalytics.framework to the Link Binary with Libraries phase.
  3. Under the Other Linker Flags build setting of the project, add -lstdc++ -lz –ObjC.
  4. In AppDelegate, import Analytics.

    Obj-C

    #import <BAFBlackberryAnalytics/BAFBlackberryAnalytics.h

    Swift

    import BAFBlackberryAnalytics
  5. Initialize the SDK in the didfinishlaunchingwithoptions method.

    Obj-C

    [BAFBlackberryAnalytics setStage];

    Swift

    BAFBlackberryAnalytics.setStage();

     

  6. Relay BlackBerry Dynamics events to the BlackBerry Analytics engine by adding this code to the handleEvent method.

  7. Obj-C

     

    [BAFBlackberryAnalytics sendGDAppEvent:anEvent];

    Swift

    BAFBlackberryAnalytics.sendGDAppEvent(anEvent)
  1. Extract the downloaded BlackBerry Analytics SDK.
  2. Copy BlackBerryAnalytics-release.aar to the libs directory.
  3. Add the following dependency in the module gradle file:
    compile(name:'BlackberryAnalytics-release', ext:'aar')
  4. Declare the libs directory as a repository in the project gradle file.
    flatDir { dirs 'libs' }
  5. Create a new class which has a superclass android.app.Application.

 

6. Change the android.name property of the application in the manifest file to the new class create in the last step.

7. Import BlackBerry Analytics SDK package in the new class.

  import com.blackberry.analytics.analyticsengine.BlackberryAnalytics

8. Override the onCreate() method to initialize the BlackBerry Analytics.

  BlackberryAnalytics.setStage(this.getApplication());

It takes 24 hours for the data to be updated on the BlackBerry Analytics Dashboard.

The BlackBerry Analytics Library introduces two APIs to track custom events in apps.

The following events are provided to use with APIs to track metrics.

  • Paired Events(Feature Active/Inactive) : These events provide the time slices to track the start/open or end/close events of specific task/feature.
  • Single Events (Adoption Event): This event uniquely represents a specific event/task that should be tracked in the portal.

Feature Active and Feature Inactive events are confined to the visible life cycle of the app. When the app moves to the background, the BlackBerry Analytics SDK marks all of the current active features as inactive features. Features that were active prior to the app going to the background will no longer be tracked as active features after the app moves to the foreground. The app will have to mark a feature as active when it is in the foreground again. Also, apps may need to call the trackFeatureEvent API to record Feature Inactive events when the apps view/screen is switched to different view/screen.

If the app calls the trackFeatureEvent API to record a Feature Inactive event after the app enters background, the BAFFeaturetNotFound response is returned.

 

Event Type

iOS

(BAFAnalyticsEvent)

 

Description

FeatureActive

BAFFeatureActive

To record feature active event

FeatureInactive

BAFFeatureInactive

To record feature inactive event

AdoptionEvent

BAFAdoptionEvent

To record adoption event.

 

 

 

 

 

 

 

 

These events can be done with the following code.

Obj-C

[BAFBlackberryAnalytics trackFeatureEvent:BAFFeatureActive
withFeatureName:@"EventName" completion:^(NSError *error) {
        NSLog(@"%@",[error localizedDescription]);
    }];
[BAFBlackberryAnalytics trackFeatureEvent:BAFFeatureInactive
withFeatureName:@"EventName" completion:^(NSError *error) {
        NSLog(@"%@",[error localizedDescription]);
    }];
[BAFBlackberryAnalytics trackApplicationEvent:BAFAdoptionEvent withValue:@"Value"
forKey:@"Key" completion:^(NSError *error) {
        NSLog(@"%@",[error localizedDescription]);    }];

 

Swift

 

BAFBlackberryAnalytics.trackApplicationEvent(.adoptionEvent, withValue: "Value", forKey:
"Key", completion: { (error) in
           
    })
       
    BAFBlackberryAnalytics.trackFeatureEvent(.featureActive, withFeatureName:
"EventName", completion: { (error) in
       
    })
       
    BAFBlackberryAnalytics.trackFeatureEvent(.featureInactive, withFeatureName:
"EventName", completion: { (error) in
       
    })

 

Event Type

Android

(AnalyticsEvent)

 

Description

FeatureActive

FEATURE_ACTIVE

To record feature active event

FeatureInactive

FEATURE_INACTIVE

To record feature inactive event

AdoptionEvent

ADOPTION_EVENT

To record adoption event.

 

 

 

 

 

 

 

AnalyticsResponse response =
BlackberryAnalytics.trackFeatureEvent(AnalyticsEvent.FEATURE_ACTIVE, "EventName");

AnalyticsResponse response = BlackberryAnalytics.trackFeatureEvent(AnalyticsEvent.FEATURE_INACTIVE, "EventName");

AnalyticsResponse response = BlackberryAnalytics.trackApplicationEvent(AnalyticsEvent.ADOPTION_EVENT, "eventValue", "
eventKey");

You can see custom events under Feature Tracking tab when you select your app under Apps on the left navigation bar.

 

Congratulations on adding BlackBerry Analytics to your secure app! You can check out other BlackBerry Products here