@Override public void sendEvent(String category, String action, String label, Long value) { try { EventBuilder builder = new HitBuilders.EventBuilder(category, action); if (label != null) { builder.setLabel(label); } if (value != null) { builder.setValue(value); } mTracker.send(builder.build()); } catch (Throwable t) { if (AndroidUtils.DEBUG) { Log.e(TAG, "sendEvent", t); } } }
@Override public void onClick(final View v) { switch (v.getId()) { case R.id.button_reset_password: { if (isInputValid()) { GoogleAnalyticsManager .getInstance() .sendEvent( new EventBuilder(Categories.CONVERSION, Actions.SIGN_IN_ATTEMPT) .set(ParamKeys.TYPE, ParamValues.RESET) ); callPasswordReset(mTokenEditText.getText().toString(), mNewPasswordEditText.getText().toString(), mEmailId); } break; } } }
/** * Send a specific event. * * @param category The event category. * @param action The action. * @param label The label. * @param value An associated value. */ public static void sendEvent(final Category category, final String action, final String label, final Long value) { getDefaultTracker(); EventBuilder eventBuilder = new EventBuilder(); eventBuilder.setCategory(category.toString()); if (action != null) { eventBuilder.setAction(action); } if (label == null) { eventBuilder.setLabel(action); } else { eventBuilder.setLabel(action + " - " + label); } if (value != null) { eventBuilder.setValue(value); } mTracker.send(eventBuilder.build()); }
public static void sendHitNewGame() { if (Statistics.tracker != null) { Thread threadGameMode = new Thread(new Runnable() { @Override public void run() { EventBuilder builder = new HitBuilders.EventBuilder(); builder.setCategory(Statistics.CATEGORY_GAME); builder.setAction(Statistics.EVENT_NEW_GAME); Statistics.tracker.send(builder.build()); } }); threadGameMode.start(); } }
public static void sendHitCollision(final CollisionType collisionType) { if (Statistics.tracker != null) { Thread threadGameMode = new Thread(new Runnable() { @Override public void run() { EventBuilder builder = new HitBuilders.EventBuilder(); builder.setCategory(Statistics.CATEGORY_COLLISION); builder.setAction(collisionType.toString()); Statistics.tracker.send(builder.build()); } }); threadGameMode.start(); } }
public synchronized void sendAppLaunched() { threadPool.submit(new Runnable() { @Override public void run() { tracker.setScreenName("App Launched"); tracker.send(new HitBuilders.ScreenViewBuilder().build()); } }); threadPool.submit(new Runnable() { @Override public void run() { Date date = new Date(); Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(date); int hour = calendar.get(Calendar.HOUR_OF_DAY); EventBuilder eventBuilder = new HitBuilders.EventBuilder(); eventBuilder.setCategory("TIME_APP_OPEN"); eventBuilder.setAction(String.valueOf(hour)); tracker.send(eventBuilder.build()); } }); }
public synchronized void addedCartItem(final CartItem cartItem) { threadPool.submit(new Runnable() { @Override public void run() { EventBuilder eventBuilder = new HitBuilders.EventBuilder(); eventBuilder.setCategory("ADDED_PRODUCT_TO_CART"); eventBuilder.setAction(cartItem.getCategory().getName()); tracker.send(eventBuilder.build()); } }); }
/** * Track event. * * @param context * @param category of event, see CAT_XX constants * @param action action of event * @param label of event * @param value of event */ public static void sendEvent(Context context, String category, String action, String label, Long value) { if (!GHConstants.DEBUG) { Tracker t = getTracker(context); if (t != null) { EventBuilder eb = new HitBuilders.EventBuilder(); eb.setCategory(category).setAction(action).setLabel(label); if (value != null) { eb.setValue(value); } t.send(eb.build()); } } }
@Override public void onReceive(Context context, Intent intent) { if (mSlidingLayout.isExpanded()) { GoogleAnalyticsManager .getInstance() .sendEvent(new EventBuilder(Categories.USAGE, Actions.CHAT_INITIALIZATION) .set(ParamKeys.TYPE, ParamValues.PROFILE)); } else { GoogleAnalyticsManager .getInstance() .sendEvent(new EventBuilder(Categories.USAGE, Actions.CHAT_INITIALIZATION) .set(ParamKeys.TYPE, ParamValues.BOOK)); } }
@Override public void onDialogClick(final DialogInterface dialog, final int which) { if ((mAddBookDialogFragment != null) && mAddBookDialogFragment.getDialog().equals(dialog)) { if (which == 0) { // scan book startActivityForResult(new Intent(getActivity(), ScanIsbnActivity.class), RequestCodes.SCAN_ISBN); GoogleAnalyticsManager .getInstance() .sendEvent(new EventBuilder(Categories.USAGE, Actions.ADD_BOOK) .set(ParamKeys.TYPE, ParamValues.SCAN)); } else if (which == 1) { // add book manually loadAddOrEditBookFragment(null); GoogleAnalyticsManager .getInstance() .sendEvent(new EventBuilder(Categories.USAGE, Actions.ADD_BOOK) .set(ParamKeys.TYPE, ParamValues.MANUAL)); } } else if ((mEnableLocationDialogFragment != null) && mEnableLocationDialogFragment.getDialog() .equals(dialog)) { if (which == DialogInterface.BUTTON_POSITIVE) { // enable location Intent locationOptionsIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(locationOptionsIntent); } else if (which == DialogInterface.BUTTON_NEGATIVE) { // cancel dialog.cancel(); } } else { super.onDialogClick(dialog, which); } }
@Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { if (parent.getId() == R.id.grid_profile_books) { if (!mUserId.equals(UserInfo.INSTANCE.getId())) { GoogleAnalyticsManager.getInstance().sendEvent( new EventBuilder(Categories.USAGE, Actions.BOOK_PROFILE_CLICK)); } final Cursor cursor = (Cursor) mProfileBooksAdapter .getItem(position); final String bookId = cursor.getString(cursor.getColumnIndex(DatabaseColumns.ID)); final Intent bookDetailIntent = new Intent(getActivity(), BookDetailActivity.class); bookDetailIntent.putExtra(Keys.ID, bookId); startActivity(bookDetailIntent); /*final Bundle showBooksArgs = Utils.cursorToBundle(cursor); loadFragment(R.id.frame_content, (AbstractBarterLiFragment) Fragment .instantiate(getActivity(), BookDetailFragment.class .getName(), showBooksArgs), FragmentTags.USER_BOOK_FROM_PROFILE, true, FragmentTags.BS_EDIT_PROFILE );*/ } }
/** * Inform an event to Google Analytics * * @param builder */ public void sendEvent(EventBuilder builder) { builder.set(ParamKeys.LOGGED_IN, TextUtils.isEmpty(UserInfo.INSTANCE .getId()) ? ParamValues.NO : ParamValues.YES); mApplicationTracker.send(builder.build()); }
/** * Sends to Google Analytics an event. * * @param tracker The analytics tracker to use when sending the * event. * @param eventCategory Category of the event * @param eventAction Action of the event * @param eventlabel label of the event */ public static void analytics_sendEvent (Tracker tracker, String eventCategory, String eventAction, String eventlabel, Long eventValue) { EventBuilder eBuilder = new HitBuilders.EventBuilder(); eBuilder.setCategory(eventCategory) .setAction(eventAction) .setLabel(eventlabel); if(eventValue!=null) { eBuilder.setValue(eventValue); } tracker.send(eBuilder.build()); }
@Override public void onClick(final View v) { switch (v.getId()) { case R.id.button_facebook_login: { GoogleAnalyticsManager .getInstance() .sendEvent(new EventBuilder(Categories.CONVERSION, Actions.SIGN_IN_ATTEMPT) .set(ParamKeys.TYPE, ParamValues.FACEBOOK)); final Session session = Session.getActiveSession(); if (!session.isOpened() && !session.isClosed()) { session.openForRead(new Session.OpenRequest(this) .setPermissions(Arrays .asList(AppConstants .FBPERMISSIONS)) .setCallback(this)); } else { Session.openActiveSession(getActivity(), this, true, this); } break; } case R.id.button_google_login: { GoogleAnalyticsManager .getInstance() .sendEvent(new EventBuilder(Categories.CONVERSION, Actions.SIGN_IN_ATTEMPT) .set(ParamKeys.TYPE, ParamValues.GOOGLE)); ((AuthActivity) getActivity()).getPlusManager().login(); break; } case R.id.button_submit: { if (isInputValid()) { GoogleAnalyticsManager .getInstance() .sendEvent( new EventBuilder(Categories.CONVERSION, Actions.SIGN_IN_ATTEMPT) .set(ParamKeys.TYPE, ParamValues.EMAIL) ); login(mEmailEditText.getText().toString(), mPasswordEditText .getText().toString()); } break; } case R.id.forgot_password: { showForgotPasswordDialog(); } } }