Sunday, October 28, 2012

Flurry in android



FlurryAgent.onStartSession(Context, String):
 Insert a call to FlurryAgent.onStartSession(Context, String), passing it a reference to a Context object (such as an Activity or Service), and your application’s API key. We recommend using the onStart method of each Activity in your application, and passing the Activity (or Service) itself as the Context object – passing the global Application context is not recommended.

    public void onStart()
    {
    super.onStart();
    FlurryAgent.onStartSession(this, "your flurry id");
    // your code
    }

 
FlurryAgent.onEndSession(Context):
Insert a call to FlurryAgent.onEndSession(Context) when a session is complete. We recommend using the onStop method of each Activity in your application. Make sure to match up a call to onEndSession for each call of onStartSession, passing in the same Context object that was used to call onStartSession

    public void onStop()
    {
    super.onStop();
    FlurryAgent.onEndSession(this);
    // your code
    }

So long as there is any Context that has called onStartSession but not onEndSession, the session will be continued. Also, if a new Context calls onStartSession within 10 seconds of the last Context calling onEndSession, then the session will be resumed, instead of a new session being created. Session length, usage frequency, events and errors will continue to be tracked as part of the same session. This ensures that as a user transitions from one Activity to another in your application that they will not have a separate session tracked for each Activity, but will have a single session that spans many Activity’s.

If you want to track Activity usage, we recommend using onEvent, described below. If you wish to change the window during which a session can be resumed, call FlurryAgent.setContinueSessionMillis(long milliseconds) before the first call to FlurryAgent.onStartSession.

You can use the following methods to report additional data:

FlurryAgent.onEvent(String eventId, Map<String, String> parameters) Use onEvent to track user events that happen during a session. You can track how many times each event occurs, what order events happen in, as well as what the most common parameters are for each event.

This can be useful for measuring how often users take various actions, or what sequences of actions they usually perform.

Each application supports a maximum of 100 events, and each event id, parameter key, and parameter value must be no more than 255 characters in length. Each event can have no more than 10 parameters. The parameter argument is optional, and may be null.

FlurryAgent.onError(String errorId, String message, String errorClass) Use onError to report application errors. Flurry will report the first 10 errors to occur in each session. The FlurryAgent will also notify you of uncaught exceptions in the same way. If you would like to disable this behavior, call setCaptureUncaughtExceptions(false) before onStartSession.

    To disable FlurryAgent logging call FlurryAgent.setLogEnabled(false).

No comments:

Post a Comment