Java Code Examples for com.facebook.appevents.AppEventsLogger#logSdkEvent()

The following examples show how to use com.facebook.appevents.AppEventsLogger#logSdkEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShareInternalUtility.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
private static void logShareResult(String shareOutcome, String errorMessage) {
    Context context = FacebookSdk.getApplicationContext();
    AppEventsLogger logger = AppEventsLogger.newLogger(context);
    Bundle parameters = new Bundle();
    parameters.putString(
            AnalyticsEvents.PARAMETER_SHARE_OUTCOME,
            shareOutcome
    );

    if (errorMessage != null) {
        parameters.putString(AnalyticsEvents.PARAMETER_SHARE_ERROR_MESSAGE, errorMessage);
    }
    logger.logSdkEvent(AnalyticsEvents.EVENT_SHARE_RESULT, null, parameters);
}
 
Example 2
Source File: LoginMethodHandler.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: DialogPresenter.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: FacebookButtonBase.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
private void logButtonCreated(final Context context) {
    AppEventsLogger logger = AppEventsLogger.newLogger(context);
    logger.logSdkEvent(analyticsButtonCreatedEventName, null, null);
}
 
Example 5
Source File: FacebookButtonBase.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
private void logButtonTapped(final Context context) {
    AppEventsLogger logger = AppEventsLogger.newLogger(context);
    logger.logSdkEvent(analyticsButtonTappedEventName, null, null);
}
 
Example 6
Source File: ShareDialog.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
private void logDialogShare(Context context, ShareContent content, Mode mode) {
    String displayType;
    if (isAutomaticMode) {
        mode = Mode.AUTOMATIC;
    }

    switch (mode) {
        case AUTOMATIC:
            displayType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_SHOW_AUTOMATIC;
            break;
        case WEB:
            displayType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_SHOW_WEB;
            break;
        case NATIVE:
            displayType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_SHOW_NATIVE;
            break;
        default:
            displayType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_SHOW_UNKNOWN;
            break;
    }

    String contentType;
    DialogFeature dialogFeature = getFeature(content.getClass());
    if (dialogFeature == ShareDialogFeature.SHARE_DIALOG) {
        contentType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_STATUS;
    } else if (dialogFeature == ShareDialogFeature.PHOTOS) {
        contentType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_PHOTO;
    } else if (dialogFeature == ShareDialogFeature.VIDEO) {
        contentType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_VIDEO;
    } else if (dialogFeature == OpenGraphActionDialogFeature.OG_ACTION_DIALOG) {
        contentType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_OPENGRAPH;
    } else {
        contentType = AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_UNKNOWN;
    }

    AppEventsLogger logger = AppEventsLogger.newLogger(context);
    Bundle parameters = new Bundle();
    parameters.putString(
            AnalyticsEvents.PARAMETER_SHARE_DIALOG_SHOW,
            displayType
    );
    parameters.putString(
            AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_TYPE,
            contentType
    );
    logger.logSdkEvent(AnalyticsEvents.EVENT_SHARE_DIALOG_SHOW, null, parameters);
}
 
Example 7
Source File: LoginButton.java    From kognitivo with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    callExternalOnClickListener(v);

    Context context = getContext();

    AccessToken accessToken = AccessToken.getCurrentAccessToken();

    if (accessToken != null) {
        // Log out
        if (confirmLogout) {
            // Create a confirmation dialog
            String logout = getResources().getString(
                    R.string.com_facebook_loginview_log_out_action);
            String cancel = getResources().getString(
                    R.string.com_facebook_loginview_cancel_action);
            String message;
            Profile profile = Profile.getCurrentProfile();
            if (profile != null && profile.getName() != null) {
                message = String.format(
                        getResources().getString(
                                R.string.com_facebook_loginview_logged_in_as),
                        profile.getName());
            } else {
                message = getResources().getString(
                        R.string.com_facebook_loginview_logged_in_using_facebook);
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message)
                    .setCancelable(true)
                    .setPositiveButton(logout, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            getLoginManager().logOut();
                        }
                    })
                    .setNegativeButton(cancel, null);
            builder.create().show();
        } else {
            getLoginManager().logOut();
        }
    } else {
        LoginManager loginManager = getLoginManager();
        loginManager.setDefaultAudience(getDefaultAudience());
        loginManager.setLoginBehavior(getLoginBehavior());

        if (LoginAuthorizationType.PUBLISH.equals(properties.authorizationType)) {
            if (LoginButton.this.getFragment() != null) {
                loginManager.logInWithPublishPermissions(
                        LoginButton.this.getFragment(),
                        properties.permissions);
            } else {
                loginManager.logInWithPublishPermissions(
                        LoginButton.this.getActivity(),
                        properties.permissions);
            }
        } else {
            if (LoginButton.this.getFragment() != null) {
                loginManager.logInWithReadPermissions(
                        LoginButton.this.getFragment(),
                        properties.permissions);
            } else {
                loginManager.logInWithReadPermissions(
                        LoginButton.this.getActivity(),
                        properties.permissions);
            }
        }
    }

    AppEventsLogger logger = AppEventsLogger.newLogger(getContext());

    Bundle parameters = new Bundle();
    parameters.putInt("logging_in", (accessToken != null) ? 0 : 1);

    logger.logSdkEvent(loginLogoutEventName, null, parameters);
}