Thursday, June 9, 2011

Flurry Integration


Flurry Integration

Introduction


The Flurry Analytics Agent allows you to track the usage and
behavior of your application on users' phones for viewing in the Flurry Analytics system.
Note
1. Flurry SDK will only work with Xcode 3.2.5 or above. If you need an SDK for an
 older Xcode version please email support.
2. Flurry Agent does not require CoreLocation framework and will not collect GPS 
location by default. Developers who use their own
CLLocationManager can set GPS location information in the Flurry Agent 
(see Optional Features for more information).

Integration


1. In the finder, drag FlurryLib into project's file folder. (NOTE: If you are upgrading
the Flurry iPad SDK, be sure to remove any existing Flurry library folders from your
project's file folder before proceeding.)
2. Now add it to your project: Project > Add to project > FlurryLib - Choose
 'Recursively create groups for any added folders'
3. In your Application Delegate:
a. Import FlurryAPI: #import "FlurryAPI.h"
b. Inside "applicationDidFinishLaunching:" add: [FlurryAPI startSession:@"YOUR_API_KEY"];
- (void)applicationDidFinishLaunching:(UIApplication *)application {

[FlurryAPI startSession:@"YOUR_API_KEY"];
//your code


}

Features

a) Tracking user Behavior
[FlurryAPI logEvent:@"EVENT_NAME"];
Use logEvent to count the number of times certain events happen during a session of
 your application. This can be useful for measuring how often users perform various
actions, for example. Your application is currently limited to counting occurrences for
 300 different event ids (maximum length 255 characters).
[FlurryAPI logEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary];
Use this version of logEvent to count the number of times certain events happen during
a session of your application and to pass dynamic parameters to be recorded with that
event. Event parameters can be passed in as a NSDictionary object where the key and
value objects must be NSString objects. For example, you could record that a user used
your search box tool and also dynamically record which search terms the user entered.
 Your application is currently limited to counting occurrences for 300 different event ids
 (maximum length 255 characters). Maximum of 10 event parameters per
event is supported.
[FlurryAPI logEvent:@"EVENT_NAME" timed:YES];
Use this version of logEvent to start timed event.
[FlurryAPI logEvent:@"EVENT_NAME" withParameters:YOUR_NSDictionary 
timed:YES];
Use this version of logEvent to start timed event with event parameters.
[FlurryAPI endTimedEvent:@"EVENT_NAME" withParameters:
YOUR_NSDictionary];
Use endTimedEvent to end timed event before app exists, otherwise timed events
 automatically end when app exists. When ending the timed event, a new event
parameters NSDictionary object can be used to update event parameters.
To keep event parameters the same, pass in nil for the event parameters NSDictionary
 object.
[FlurryAPI logAllPageViews:navigationController];
To enable Flurry agent to automatically detect and log page view, pass in an
instance of UINavigationController or UITabBarController to countPageViews.
 Flurry agent will create a delegate on your object to detect user interactions.
Each detected user interaction will automatically be logged as a page view.
Each instance needs to only be passed to Flurry agent once. Multiple
UINavigationController or UITabBarController instances can be passed to Flurry agent.
[FlurryAPI logPageView];
In the absence of UINavigationController and UITabBarController, you can
manually detect user interactions. For each user interaction you want to manually log,
 you can use logPageView to log the page view.

b) Tracking Application Errors
[FlurryAPI logError:@"ERROR_NAME" message:@"ERROR_MESSAGE" 
exception:e];
Use this to log exceptions and/or errors that occur in your app. Flurry will report the
 first 10 errors that occur in each session.

c) Tracking Demographics
[FlurryAPI setUserID:@"USER_ID"];
Use this to log the user's assigned ID or username in your system after identifying
the user.
[FlurryAPI setAge:21];
Use this to log the user's age after identifying the user. Valid inputs are 0 or greater.
[FlurryAPI setGender:@"m"];
Use this to log the user's gender after identifying the user. Valid inputs are (male)
 or (female)

d) Tracking Location
CLLocationManager *locationManager = [[CLLocationManager alloc] init]; 
[locationManager startUpdatingLocation]
CLLocation *location = locationManager.location; [FlurryAPI setLatitude:
location.coordinate.latitude
longitude:location.coordinate.longitude horizontalAccuracy:location
.horizontalAccuracy verticalAccuracy:location.verticalAccuracy];
This allows you to set the current GPS location of the user. Flurry will keep only
the last location information. If your app does not use location services in a meaningful
way, using CLLocationManager can result in Apple rejecting the app submission.

e) Controlling Data Reporting
[FlurryAPI setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose];
This option is on by default. When enabled, Flurry will attempt to send session data
when the app is exited as well as it normally does when the app is started.
This will improve the speed at which your application analytics are updated
but can prolong the app termination process due to network latency.
 In some cases, the network latency can cause the app to crash.
[FlurryAPI setSessionReportsOnPauseEnabled:(BOOL)sendSessionReportsOnPause];
This option is on by default. When enabled, Flurry will attempt to send session
 data when the app is paused as well as it normally does when the app is started.
This will improve the speed at which your application analytics are updated
 but can prolong the app pause process due to network latency.
 In some cases, the network latency can cause the app to crash.

"EXC _BAD_ACCESS" error handling


All of us are well aware of this error .Most of us know the solution also for this, that is "Using Zombies".You get your problem fixed also using it. There are few scenarios when you get the kind of object was released but we dont get the exact line number where the problem is even after spending long time on debugging.Such a problem happened with me also & found a short simple solution for it.My this blog will through light on using zombies in your project & also how you can get the exact line number.I am sure it will be helpful for you all.

Introduction



This kind of problem is usually the result of over-releasing an object. It can be very confusing, since the failure tends to occur well after the mistake is made. The crash can also occur while the program is deep in framework code, often with none of your own code visible in the stack.

Enabling Zombies


Steps

1. Select Groups & Files > Executables

Click for full-size image
2. Select your project within Executables & press info button , following screen pops up


Click for full-size image
3. Select Arguments from top segmented control


Click for full-size image


4. Now select the botton "+" button

Click for full-size image

& add the following key value pairs
NSZombieEnabled = YES
CFZombie = 5
MallocStackLoggingNoCompact = 1

Click for full-size image


Debugging "EXC_BAD_ACESS" error


After enabling zombie & running the project you get something like


(gdb) continue
2011-06-09 11:46:08.404 test [6842:40b] *** -[_NSArrayI release]:message sent to deallocated instance 0X64a4900

in your console
Then add

(gdb) info malloc-history 0x64a4900
it will show the lines that was creating the error