use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.
the class AppEventsLoggerTests method testExplicitCallWithNoAppSettings.
public void testExplicitCallWithNoAppSettings() throws InterruptedException {
AppEventsLogger.setFlushBehavior(AppEventsLogger.FlushBehavior.EXPLICIT_ONLY);
AccessToken accessToken1 = getFakeAccessToken();
FacebookSdk.setApplicationId("234");
AppEventsLogger logger1 = AppEventsLogger.newLogger(getActivity(), accessToken1);
final WaitForBroadcastReceiver waitForBroadcastReceiver = new WaitForBroadcastReceiver();
waitForBroadcastReceiver.incrementExpectCount();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Need to get notifications on another thread so we can wait for them.
runOnBlockerThread(new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(waitForBroadcastReceiver, new IntentFilter(AppEventsLogger.ACTION_APP_EVENTS_FLUSHED));
}
}, true);
logger1.logEvent("an_event");
logger1.flush();
waitForBroadcastReceiver.waitForExpectedCalls();
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(waitForBroadcastReceiver);
}
}
use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.
the class AppEventsLoggerTests method testSimpleCall.
public void testSimpleCall() throws InterruptedException {
AppEventsLogger.setFlushBehavior(AppEventsLogger.FlushBehavior.EXPLICIT_ONLY);
AccessToken accessToken1 = getAccessTokenForSharedUser();
AccessToken accessToken2 = getAccessTokenForSharedUser(SECOND_TEST_USER_TAG);
AppEventsLogger logger1 = AppEventsLogger.newLogger(getActivity(), accessToken1);
AppEventsLogger logger2 = AppEventsLogger.newLogger(getActivity(), accessToken2);
final WaitForBroadcastReceiver waitForBroadcastReceiver = new WaitForBroadcastReceiver();
waitForBroadcastReceiver.incrementExpectCount();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Need to get notifications on another thread so we can wait for them.
runOnBlockerThread(new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(waitForBroadcastReceiver, new IntentFilter(AppEventsLogger.ACTION_APP_EVENTS_FLUSHED));
}
}, true);
logger1.logEvent("an_event");
logger2.logEvent("another_event");
// test illegal event name and event key, should not crash in non-debug environment.
logger1.logEvent("$illegal_event_name");
Bundle params = new Bundle();
params.putString("illegal%key", "good_value");
logger1.logEvent("legal_event_name", params);
char[] val = { 'b', 'a', 'd' };
params.putCharArray("legal_key", val);
logger1.logEvent("legal_event", params);
logger1.flush();
waitForBroadcastReceiver.waitForExpectedCalls();
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(waitForBroadcastReceiver);
}
}
use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.
the class ShareInternalUtility method logShareResult.
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);
}
use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.
the class FacebookButtonBase method logButtonCreated.
private void logButtonCreated(final Context context) {
AppEventsLogger logger = AppEventsLogger.newLogger(context);
logger.logSdkEvent(analyticsButtonCreatedEventName, null, null);
}
use of com.facebook.appevents.AppEventsLogger in project facebook-android-sdk by facebook.
the class SessionLogger method logActivateApp.
public static void logActivateApp(Context applicationContext, String activityName, SourceApplicationInfo sourceApplicationInfo, String appId) {
String sourAppInfoStr = sourceApplicationInfo != null ? sourceApplicationInfo.toString() : "Unclassified";
Bundle eventParams = new Bundle();
eventParams.putString(AppEventsConstants.EVENT_PARAM_SOURCE_APPLICATION, sourAppInfoStr);
AppEventsLogger logger = new InternalAppEventsLogger(activityName, appId, null);
logger.logEvent(AppEventsConstants.EVENT_NAME_ACTIVATED_APP, eventParams);
if (logger.getFlushBehavior() != AppEventsLogger.FlushBehavior.EXPLICIT_ONLY) {
logger.flush();
}
}
Aggregations