Java 类com.facebook.appevents.AppEventsConstants 实例源码

项目:SecretBrand    文件:DataUtils.java   
public static String getFormattedDate(String date, boolean leadingZero) {
    Calendar c = getDateAsCalendar(date);
    String out = String.format("%te %tb", new Object[]{c, c}).toUpperCase();
    if (leadingZero) {
        try {
            if (out.length() > 1) {
                String first = out.substring(0, 1);
                String second = out.substring(1, 2);
                if (isNumeric(first) && !isNumeric(second) && Integer.parseInt(first) < 10) {
                    out = AppEventsConstants.EVENT_PARAM_VALUE_NO + out;
                }
            }
        } catch (Exception e) {
        }
    }
    return out;
}
项目:openshop.io-android    文件:Analytics.java   
/**
 * Method sends product view event to defined Analytics.
 *
 * @param remoteId remote id of the viewed product.
 * @param name     name of the viewed product.
 */
public static void logProductView(long remoteId, String name) {
    // FB event log
    Bundle parameters = new Bundle();
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, PRODUCT);
    parameters.putLong(AppEventsConstants.EVENT_PARAM_CONTENT_ID, remoteId);
    parameters.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, name);
    logFbEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT, null, parameters);

    // GA event log
    Map<String, String> event = new HitBuilders.EventBuilder()
            .setCategory(PRODUCT)
            .setAction("view")
            .setLabel("product with id: " + remoteId + ", name: " + name)
            .build();
    sendEventToAppTrackers(event);
}
项目:openshop.io-android    文件:Analytics.java   
/**
 * Method sends "product add to cart" event to defined Analytics.
 *
 * @param remoteId       remote id of the viewed product.
 * @param name           name of the viewed product.
 * @param discountPrice product price.
 */
public static void logAddProductToCart(long remoteId, String name, double discountPrice) {
    // FB facebookLogger
    Bundle parameters = new Bundle();
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, PRODUCT);
    parameters.putLong(AppEventsConstants.EVENT_PARAM_CONTENT_ID, remoteId);
    parameters.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, name);
    logFbEvent(AppEventsConstants.EVENT_NAME_ADDED_TO_CART, discountPrice, parameters);

    // Ga
    Map<String, String> event = new HitBuilders.EventBuilder()
            .setCategory("ADDED_TO_CART")
            .setAction("ADDED_TO_CART")
            .setLabel("ADDED TO CART" + " product id: " + remoteId + " product name: " + name + " price: " + discountPrice)
            .build();
    sendEventToAppTrackers(event);
}
项目:openshop.io-android    文件:Analytics.java   
/**
 * Method sends "user changed shop" event to defined Analytics.
 *
 * @param actualNonNullShop active shop before change.
 * @param newShopSelected   active shop after change.
 */
public static void logShopChange(Shop actualNonNullShop, Shop newShopSelected) {
    if (actualNonNullShop != null && newShopSelected != null) {
        String description = "From (id=" + actualNonNullShop.getId() + ",name=" + actualNonNullShop.getName() +
                ") to (id=" + newShopSelected.getId() + ",name=" + newShopSelected.getId() + ")";
        // FB facebookLogger
        Bundle parameters = new Bundle();
        parameters.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, description);
        logFbEvent(AppEventsConstants.EVENT_NAME_UNLOCKED_ACHIEVEMENT, null, parameters);

        // Ga
        Map<String, String> event = new HitBuilders.EventBuilder()
                .setCategory("CHANGE_SHOP")
                .setAction("CHANGE_SHOP")
                .setLabel(description)
                .build();
        sendEventToAppTrackers(event);
    } else {
        Timber.e(new RuntimeException(), "Try log shop change with null parameters");
    }
}
项目:openshop.io-android    文件:Analytics.java   
/**
 * Method sends "category view" event to Google Analytics.
 *
 * @param categoryId   id category for logging.
 * @param categoryName category name for logging.
 * @param isSearch     determine if normal category or search category.
 */
public static void logCategoryView(long categoryId, String categoryName, boolean isSearch) {
    Bundle parameters = new Bundle();
    parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "category");

    if (categoryId == 0) {
        Timber.e("Is categoryId = 0.");
    } else {
        parameters.putLong(AppEventsConstants.EVENT_PARAM_CONTENT_ID, categoryId);
        parameters.putString(AppEventsConstants.EVENT_PARAM_DESCRIPTION, categoryName);
        logFbEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT, null, parameters);

        Map<String, String> event = new HitBuilders.EventBuilder()
                .setCategory("VIEW_CATEGORY")
                .setAction(isSearch ? "SEARCH" : "VIEW_CATEGORY")
                .setLabel(isSearch ? "Search: " + categoryName : "CategoryId: " + categoryId + ". CategoryName: " + categoryName)
                .build();

        sendEventToAppTrackers(event);
    }
}
项目:kognitivo    文件:LoginClient.java   
boolean tryCurrentHandler() {
    LoginMethodHandler handler = getCurrentHandler();
    if (handler.needsInternetPermission() && !checkInternetPermission()) {
        addLoggingExtra(
            LoginLogger.EVENT_EXTRAS_MISSING_INTERNET_PERMISSION,
            AppEventsConstants.EVENT_PARAM_VALUE_YES,
            false
        );
        return false;
    }

    boolean tried = handler.tryAuthorize(pendingRequest);
    if (tried) {
        getLogger().logAuthorizationMethodStart(pendingRequest.getAuthId(),
                handler.getNameForLogging());
    } else {
        // We didn't try it, so we don't get any other completion
        // notification -- log that we skipped it.
        addLoggingExtra(
            LoginLogger.EVENT_EXTRAS_NOT_TRIED,
                handler.getNameForLogging(),
            true
        );
    }

    return tried;
}
项目:kognitivo    文件:LoginManager.java   
private void logCompleteLogin(
        Context context,
        LoginClient.Result.Code result,
        Map<String, String> resultExtras,
        Exception exception,
        boolean wasLoginActivityTried,
        LoginClient.Request request) {
    LoginLogger loginLogger = LoginLoggerHolder.getLogger(context);
    if (loginLogger == null) {
        return;
    }
    if (request == null) {
        // We don't expect this to happen, but if it does, log an event for diagnostic purposes.
        loginLogger.logUnexpectedError(
                LoginLogger.EVENT_NAME_LOGIN_COMPLETE,
                "Unexpected call to logCompleteLogin with null pendingAuthorizationRequest."
        );
    } else {
        HashMap<String, String> pendingLoggingExtras = new HashMap<>();
        pendingLoggingExtras.put(
                LoginLogger.EVENT_EXTRAS_TRY_LOGIN_ACTIVITY,
                wasLoginActivityTried ?
                        AppEventsConstants.EVENT_PARAM_VALUE_YES :
                        AppEventsConstants.EVENT_PARAM_VALUE_NO
        );
        loginLogger.logCompleteLogin(
                request.getAuthId(),
                pendingLoggingExtras,
                result,
                resultExtras,
                exception);
    }
}
项目:MADBike    文件:AnalyticsManager.java   
public void trackLoginResult(boolean loginSuccess) {
    Bundle bundle = new Bundle();
    if (loginSuccess) {
        bundle.putString(AppEventsConstants.EVENT_PARAM_VALUE_YES, String.valueOf(loginSuccess));
    } else {
        bundle.putString(AppEventsConstants.EVENT_PARAM_VALUE_NO, String.valueOf(loginSuccess));
    }
    logger.logEvent(LOGIN_EVENT, bundle);
    answers.logLogin(new LoginEvent().putMethod("Digits").putSuccess(loginSuccess));
}
项目:Move-Alarm_ORCA    文件:LoginClient.java   
boolean tryCurrentHandler() {
    LoginMethodHandler handler = getCurrentHandler();
    if (handler.needsInternetPermission() && !checkInternetPermission()) {
        addLoggingExtra(
            LoginLogger.EVENT_EXTRAS_MISSING_INTERNET_PERMISSION,
            AppEventsConstants.EVENT_PARAM_VALUE_YES,
            false
        );
        return false;
    }

    boolean tried = handler.tryAuthorize(pendingRequest);
    if (tried) {
        getLogger().logAuthorizationMethodStart(pendingRequest.getAuthId(),
                handler.getNameForLogging());
    } else {
        // We didn't try it, so we don't get any other completion
        // notification -- log that we skipped it.
        addLoggingExtra(
            LoginLogger.EVENT_EXTRAS_NOT_TRIED,
                handler.getNameForLogging(),
            true
        );
    }

    return tried;
}
项目:Move-Alarm_ORCA    文件:LoginManager.java   
private void startLogin(
        StartActivityDelegate startActivityDelegate,
        LoginClient.Request request
) throws FacebookException {

    this.pendingLoginRequest = request;
    this.pendingLoggingExtras = new HashMap<>();
    this.context = startActivityDelegate.getActivityContext();

    logStartLogin();

    // Make sure the static handler for login is registered if there isn't an explicit callback
    CallbackManagerImpl.registerStaticCallback(
            CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return LoginManager.this.onActivityResult(resultCode, data);
                }
            }
    );

    boolean started = tryLoginActivity(startActivityDelegate, request);

    pendingLoggingExtras.put(
            LoginLogger.EVENT_EXTRAS_TRY_LOGIN_ACTIVITY,
            started ?
            AppEventsConstants.EVENT_PARAM_VALUE_YES : AppEventsConstants.EVENT_PARAM_VALUE_NO
    );

    if (!started) {
        FacebookException exception = new FacebookException(
                "Log in attempt failed: LoginActivity could not be started");
        logCompleteLogin(LoginClient.Result.Code.ERROR, null, exception);
        this.pendingLoginRequest = null;
        throw exception;
    }
}
项目:SocioBlood    文件:LoginClient.java   
boolean tryCurrentHandler() {
    LoginMethodHandler handler = getCurrentHandler();
    if (handler.needsInternetPermission() && !checkInternetPermission()) {
        addLoggingExtra(
            LoginLogger.EVENT_EXTRAS_MISSING_INTERNET_PERMISSION,
            AppEventsConstants.EVENT_PARAM_VALUE_YES,
            false
        );
        return false;
    }

    boolean tried = handler.tryAuthorize(pendingRequest);
    if (tried) {
        getLogger().logAuthorizationMethodStart(pendingRequest.getAuthId(),
                handler.getNameForLogging());
    } else {
        // We didn't try it, so we don't get any other completion
        // notification -- log that we skipped it.
        addLoggingExtra(
            LoginLogger.EVENT_EXTRAS_NOT_TRIED,
                handler.getNameForLogging(),
            true
        );
    }

    return tried;
}
项目:SocioBlood    文件:LoginManager.java   
private void startLogin(
        StartActivityDelegate startActivityDelegate,
        LoginClient.Request request
) throws FacebookException {

    this.pendingLoginRequest = request;
    this.pendingLoggingExtras = new HashMap<>();
    this.context = startActivityDelegate.getActivityContext();

    logStartLogin();

    // Make sure the static handler for login is registered if there isn't an explicit callback
    CallbackManagerImpl.registerStaticCallback(
            CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return LoginManager.this.onActivityResult(resultCode, data);
                }
            }
    );

    boolean started = tryFacebookActivity(startActivityDelegate, request);

    pendingLoggingExtras.put(
            LoginLogger.EVENT_EXTRAS_TRY_LOGIN_ACTIVITY,
            started ?
            AppEventsConstants.EVENT_PARAM_VALUE_YES : AppEventsConstants.EVENT_PARAM_VALUE_NO
    );

    if (!started) {
        FacebookException exception = new FacebookException(
                "Log in attempt failed: FacebookActivity could not be started." +
                        " Please make sure you added FacebookActivity to the AndroidManifest.");
        logCompleteLogin(LoginClient.Result.Code.ERROR, null, exception);
        this.pendingLoginRequest = null;
        throw exception;
    }
}
项目:kognitivo    文件:WebViewLoginMethodHandler.java   
@Override
boolean tryAuthorize(final LoginClient.Request request) {
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
        String scope = TextUtils.join(",", request.getPermissions());
        parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
        addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
    }

    DefaultAudience audience = request.getDefaultAudience();
    parameters.putString(
            ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    AccessToken previousToken = AccessToken.getCurrentAccessToken();
    String previousTokenString = previousToken != null ? previousToken.getToken() : null;
    if (previousTokenString != null
            && (previousTokenString.equals(loadCookieToken()))) {
        parameters.putString(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                previousTokenString);
        // Don't log the actual access token, just its presence or absence.
        addLoggingExtra(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                AppEventsConstants.EVENT_PARAM_VALUE_YES);
    } else {
        // The call to clear cookies will create the first instance of CookieSyncManager if
        // necessary
        Utility.clearFacebookCookies(loginClient.getActivity());
        addLoggingExtra(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                AppEventsConstants.EVENT_PARAM_VALUE_NO);
    }

    WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
        @Override
        public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
        }
    };

    e2e = LoginClient.getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    FragmentActivity fragmentActivity = loginClient.getActivity();
    WebDialog.Builder builder = new AuthDialogBuilder(
            fragmentActivity,
            request.getApplicationId(),
            parameters)
            .setE2E(e2e)
            .setIsRerequest(request.isRerequest())
            .setOnCompleteListener(listener)
            .setTheme(FacebookSdk.getWebDialogTheme());
    loginDialog = builder.build();

    FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
    dialogFragment.setRetainInstance(true);
    dialogFragment.setDialog(loginDialog);
    dialogFragment.show(fragmentActivity.getSupportFragmentManager(),
            FacebookDialogFragment.TAG);

    return true;
}
项目:openshop.io-android    文件:Analytics.java   
/**
 * Method sends "order created" event to Google Analytics.
 *
 * @param orderCart        ordered cart content.
 * @param orderRemoteId    remote order id.
 * @param orderTotalPrice  total order price.
 * @param selectedShipping selected shipping to log its price.
 */
public static void logOrderCreatedEvent(Cart orderCart, String orderRemoteId, Double orderTotalPrice, Shipping selectedShipping) {
    //GA
    Map<String, String> eventPostOrder = new HitBuilders.EventBuilder()
            .setCategory(POST_ORDER)
            .setAction(POST_ORDER)
            .setLabel(POST_ORDER)
            .build();
    sendEventToAppTrackers(eventPostOrder);

    // Send GA whole cart
    Map<String, String> event = new HitBuilders.TransactionBuilder()
            .setTransactionId(orderRemoteId)
            .setAffiliation(SettingsMy.getActualNonNullShop(null).getName())
            .setRevenue(orderTotalPrice)
            .setTax(0.0)
            .setShipping(selectedShipping.getPrice())
            .setCurrencyCode(orderCart.getCurrency())
            .build();
    sendEventToAppTrackers(event);

    // Fb event whole cart
    Bundle parametersCheckout = new Bundle();
    parametersCheckout.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "cart");
    parametersCheckout.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, orderRemoteId);
    parametersCheckout.putInt(AppEventsConstants.EVENT_PARAM_NUM_ITEMS, orderCart.getItems().size());  // Unique products/events
    parametersCheckout.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, orderCart.getCurrency());
    logFbEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, orderTotalPrice, parametersCheckout);

    // Fb event shipping
    Bundle parametersShip = new Bundle();
    parametersShip.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "shipping");
    parametersShip.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, orderRemoteId);
    parametersShip.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, orderCart.getCurrency());
    logFbEvent(AppEventsConstants.EVENT_NAME_PURCHASED, (double) selectedShipping.getPrice(), parametersShip);

    // Send single products in cart to GA and FB
    for (int i = 0; i < orderCart.getItems().size(); i++) {
        CartProductItem item = orderCart.getItems().get(i);

        Double price = item.getVariant().getPrice();
        if (item.getVariant().getDiscountPrice() > 0) {
            price = item.getVariant().getDiscountPrice();
        }
        Map<String, String> eventSingle = new HitBuilders.ItemBuilder()
                .setTransactionId(orderRemoteId)
                .setName(item.getVariant().getName())
                .setSku("Product id: " + item.getVariant().getRemoteId())
                .setCategory("Category id: " + item.getVariant().getCategory())
                .setPrice(price)
                .setQuantity(item.getQuantity())
                .setCurrencyCode(orderCart.getCurrency())
                .build();
        sendEventToAppTrackers(eventSingle);

        // Fb events purchased
        Bundle parameters = new Bundle();
        parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, PRODUCT);
        parameters.putLong(AppEventsConstants.EVENT_PARAM_CONTENT_ID, item.getVariant().getRemoteId());
        parameters.putInt(AppEventsConstants.EVENT_PARAM_NUM_ITEMS, item.getQuantity());
        parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, orderCart.getCurrency());
        logFbEvent(AppEventsConstants.EVENT_NAME_PURCHASED, price * item.getQuantity(), parameters);
    }
}
项目:Move-Alarm_ORCA    文件:WebViewLoginMethodHandler.java   
@Override
boolean tryAuthorize(final LoginClient.Request request) {
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
        String scope = TextUtils.join(",", request.getPermissions());
        parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
        addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
    }

    DefaultAudience audience = request.getDefaultAudience();
    parameters.putString(
            ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    AccessToken previousToken = AccessToken.getCurrentAccessToken();
    String previousTokenString = previousToken != null ? previousToken.getToken() : null;
    if (previousTokenString != null
            && (previousTokenString.equals(loadCookieToken()))) {
        parameters.putString(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                previousTokenString);
        // Don't log the actual access token, just its presence or absence.
        addLoggingExtra(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                AppEventsConstants.EVENT_PARAM_VALUE_YES);
    } else {
        // The call to clear cookies will create the first instance of CookieSyncManager if
        // necessary
        Utility.clearFacebookCookies(loginClient.getActivity());
        addLoggingExtra(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                AppEventsConstants.EVENT_PARAM_VALUE_NO);
    }

    WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
        @Override
        public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
        }
    };

    e2e = LoginClient.getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    FragmentActivity fragmentActivity = loginClient.getActivity();
    WebDialog.Builder builder = new AuthDialogBuilder(
            fragmentActivity,
            request.getApplicationId(),
            parameters)
            .setE2E(e2e)
            .setIsRerequest(request.isRerequest())
            .setOnCompleteListener(listener);
    loginDialog = builder.build();

    FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
    dialogFragment.setRetainInstance(true);
    dialogFragment.setDialog(loginDialog);
    dialogFragment.show(fragmentActivity.getSupportFragmentManager(),
            FacebookDialogFragment.TAG);

    return true;
}
项目:SocioBlood    文件:WebViewLoginMethodHandler.java   
@Override
boolean tryAuthorize(final LoginClient.Request request) {
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
        String scope = TextUtils.join(",", request.getPermissions());
        parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
        addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
    }

    DefaultAudience audience = request.getDefaultAudience();
    parameters.putString(
            ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    AccessToken previousToken = AccessToken.getCurrentAccessToken();
    String previousTokenString = previousToken != null ? previousToken.getToken() : null;
    if (previousTokenString != null
            && (previousTokenString.equals(loadCookieToken()))) {
        parameters.putString(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                previousTokenString);
        // Don't log the actual access token, just its presence or absence.
        addLoggingExtra(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                AppEventsConstants.EVENT_PARAM_VALUE_YES);
    } else {
        // The call to clear cookies will create the first instance of CookieSyncManager if
        // necessary
        Utility.clearFacebookCookies(loginClient.getActivity());
        addLoggingExtra(
                ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN,
                AppEventsConstants.EVENT_PARAM_VALUE_NO);
    }

    WebDialog.OnCompleteListener listener = new WebDialog.OnCompleteListener() {
        @Override
        public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
        }
    };

    e2e = LoginClient.getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    FragmentActivity fragmentActivity = loginClient.getActivity();
    WebDialog.Builder builder = new AuthDialogBuilder(
            fragmentActivity,
            request.getApplicationId(),
            parameters)
            .setE2E(e2e)
            .setIsRerequest(request.isRerequest())
            .setOnCompleteListener(listener);
    loginDialog = builder.build();

    FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
    dialogFragment.setRetainInstance(true);
    dialogFragment.setDialog(loginDialog);
    dialogFragment.show(fragmentActivity.getSupportFragmentManager(),
            FacebookDialogFragment.TAG);

    return true;
}