Search in sources :

Example 6 with AppEventsLogger

use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.

the class BoltsMeasurementEventListener method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context);
    String eventName = BOLTS_MEASUREMENT_EVENT_PREFIX + intent.getStringExtra(MEASUREMENT_EVENT_NAME_KEY);
    Bundle eventArgs = intent.getBundleExtra(MEASUREMENT_EVENT_ARGS_KEY);
    Bundle logData = new Bundle();
    for (String key : eventArgs.keySet()) {
        String safeKey = key.replaceAll("[^0-9a-zA-Z _-]", "-").replaceAll("^[ -]*", "").replaceAll("[ -]*$", "");
        logData.putString(safeKey, (String) eventArgs.get(key));
    }
    appEventsLogger.logEvent(eventName, logData);
}
Also used : Bundle(android.os.Bundle) AppEventsLogger(com.facebook.appevents.AppEventsLogger)

Example 7 with AppEventsLogger

use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.

the class AutomaticAnalyticsLogger method logActivityTimeSpentEvent.

public static void logActivityTimeSpentEvent(String activityName, long timeSpentInSeconds) {
    final Context context = FacebookSdk.getApplicationContext();
    final String appId = FacebookSdk.getApplicationId();
    Validate.notNull(context, "context");
    final FetchedAppSettings settings = FetchedAppSettingsManager.queryAppSettings(appId, false);
    if (settings != null && settings.getAutomaticLoggingEnabled() && timeSpentInSeconds > 0) {
        AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context);
        Bundle params = new Bundle(1);
        params.putCharSequence(Constants.AA_TIME_SPENT_SCREEN_PARAMETER_NAME, activityName);
        appEventsLogger.logEvent(Constants.AA_TIME_SPENT_EVENT_NAME, timeSpentInSeconds, params);
    }
}
Also used : Context(android.content.Context) FetchedAppSettings(com.facebook.internal.FetchedAppSettings) Bundle(android.os.Bundle) AppEventsLogger(com.facebook.appevents.AppEventsLogger)

Example 8 with AppEventsLogger

use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.

the class DialogPresenter method logDialogActivity.

public static void logDialogActivity(Context context, String eventName, String outcome) {
    AppEventsLogger logger = AppEventsLogger.newLogger(context);
    Bundle parameters = new Bundle();
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    logger.logSdkEvent(eventName, null, parameters);
}
Also used : Bundle(android.os.Bundle) AppEventsLogger(com.facebook.appevents.AppEventsLogger)

Example 9 with AppEventsLogger

use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.

the class LoginMethodHandler method logWebLoginCompleted.

protected void logWebLoginCompleted(String e2e) {
    String applicationId = loginClient.getPendingRequest().getApplicationId();
    AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(loginClient.getActivity(), applicationId);
    Bundle parameters = new Bundle();
    parameters.putString(AnalyticsEvents.PARAMETER_WEB_LOGIN_E2E, e2e);
    parameters.putLong(AnalyticsEvents.PARAMETER_WEB_LOGIN_SWITCHBACK_TIME, System.currentTimeMillis());
    parameters.putString(AnalyticsEvents.PARAMETER_APP_ID, applicationId);
    appEventsLogger.logSdkEvent(AnalyticsEvents.EVENT_WEB_LOGIN_COMPLETE, null, parameters);
}
Also used : Bundle(android.os.Bundle) AppEventsLogger(com.facebook.appevents.AppEventsLogger)

Example 10 with AppEventsLogger

use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.

the class PlacePickerFragment method logAppEvents.

@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), AccessToken.getCurrentAccessToken().getToken());
    Bundle parameters = new Bundle();
    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED : AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_places_picked", (getSelection() != null) ? 1 : 0);
    logger.logSdkEvent(AnalyticsEvents.EVENT_PLACE_PICKER_USAGE, null, parameters);
}
Also used : Bundle(android.os.Bundle) AppEventsLogger(com.facebook.appevents.AppEventsLogger)

Aggregations

AppEventsLogger (com.facebook.appevents.AppEventsLogger)14 Bundle (android.os.Bundle)10 Context (android.content.Context)2 IntentFilter (android.content.IntentFilter)2 LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)2 AccessToken (com.facebook.AccessToken)2 WaitForBroadcastReceiver (com.facebook.WaitForBroadcastReceiver)2 DialogFeature (com.facebook.internal.DialogFeature)1 FetchedAppSettings (com.facebook.internal.FetchedAppSettings)1 OpenGraphActionDialogFeature (com.facebook.share.internal.OpenGraphActionDialogFeature)1 ShareDialogFeature (com.facebook.share.internal.ShareDialogFeature)1