Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #12 from twitterdev/custom_events
Browse files Browse the repository at this point in the history
Implementing Custom events triggers
  • Loading branch information
lfcipriani committed May 12, 2015
2 parents 16d565f + 629cf21 commit 7c5bf3e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.digits.sdk.android.Digits;
import com.twitter.sdk.android.Twitter;

Expand Down Expand Up @@ -53,6 +54,7 @@ public void onClick(View v) {
Twitter.getSessionManager().clearActiveSession();
Digits.getSessionManager().clearActiveSession();
SessionRecorder.recordSessionInactive("About: accounts deactivated");
Answers.getInstance().logEvent("signed out");

Toast.makeText(getApplicationContext(), "All accounts are cleared",
Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.digits.sdk.android.AuthCallback;
import com.digits.sdk.android.DigitsAuthButton;
import com.digits.sdk.android.DigitsException;
Expand Down Expand Up @@ -61,11 +62,13 @@ private void setUpTwitterButton() {
@Override
public void success(Result<TwitterSession> result) {
SessionRecorder.recordSessionActive("Login: twitter account active", result.data);
Answers.getInstance().logEvent("login:twitter:success");
startThemeChooser();
}

@Override
public void failure(TwitterException exception) {
Answers.getInstance().logEvent("login:twitter:failure");
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_twitter_signin_fail),
Toast.LENGTH_SHORT).show();
Expand All @@ -81,11 +84,13 @@ private void setUpDigitsButton() {
@Override
public void success(DigitsSession digitsSession, String phoneNumber) {
SessionRecorder.recordSessionActive("Login: digits account active", digitsSession);
Answers.getInstance().logEvent("login:digits:success");
startThemeChooser();
}

@Override
public void failure(DigitsException e) {
Answers.getInstance().logEvent("login:digits:failure");
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_twitter_digits_fail),
Toast.LENGTH_SHORT).show();
Expand All @@ -101,6 +106,7 @@ private void setUpSkip() {
@Override
public void onClick(View v) {
Crashlytics.log("Login: skipped login");
Answers.getInstance().logEvent("skipped login");
startThemeChooser();
overridePendingTransition(R.anim.slide_down, R.anim.slide_up);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.EventAttributes;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -117,6 +119,7 @@ private void setUpShuffle() {
@Override
public void onClick(View v) {
shuffleWords();
Answers.getInstance().logEvent("shuffled words");
}
});
}
Expand Down Expand Up @@ -163,6 +166,7 @@ private void setUpCountDown() {
@Override
public void onBackPressed() {
Crashlytics.log("PoemBuilder: getting back, user cancelled the poem creation");
Answers.getInstance().logEvent("gave up building a poem");
super.onBackPressed();
countDown.cancel();
}
Expand All @@ -176,6 +180,12 @@ private void createPoem() {
Crashlytics.setString(App.CRASHLYTICS_KEY_POEM_TEXT, poemText);
Crashlytics.setInt(App.CRASHLYTICS_KEY_POEM_IMAGE, poemImage);

Answers.getInstance().logEvent("clicked save poem",
new EventAttributes()
.put("poem size", poemText.length())
.put("poem image", poemImage)
.put("poem theme", poemTheme.getDisplayName()));

AppService.createPoem(getApplicationContext(),
poemText,
poemImage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.mopub.nativeads.MoPubAdAdapter;
import com.mopub.nativeads.MoPubNativeAdRenderer;
import com.mopub.nativeads.ViewBinder;
Expand Down Expand Up @@ -207,6 +208,7 @@ class OnShareClickListener implements View.OnClickListener {
@Override
public void onClick(View v) {
Crashlytics.log("PoemHistory: clicked to share poem with id: " + v.getTag());
Answers.getInstance().logEvent("shared poem");

final RelativeLayout originalPoem = (RelativeLayout) v.getParent();

Expand Down Expand Up @@ -257,6 +259,7 @@ class OnDeleteClickListener implements View.OnClickListener {
@Override
public void onClick(View v) {
Crashlytics.log("PoemHistory: clicked to delete poem with id: " + v.getTag());
Answers.getInstance().logEvent("removed poem");
AppService.deletePoem(getApplicationContext(), (Integer) v.getTag());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.EventAttributes;
import com.twitter.sdk.android.Twitter;

import io.fabric.samples.cannonball.App;
Expand Down Expand Up @@ -56,6 +58,7 @@ private void setUpIcon() {
@Override
public void onClick(View v) {
Crashlytics.log("ThemeChooser: clicked About button");
Answers.getInstance().logEvent("clicked about");
final Intent intent = new Intent(ThemeChooserActivity.this, AboutActivity.class);
startActivity(intent);
}
Expand All @@ -68,6 +71,7 @@ private void setUpPopular() {
@Override
public void onClick(View v) {
Crashlytics.log("ThemeChooser: clicked Popular button");
Answers.getInstance().logEvent("clicked popular");
Intent intent = new Intent(ThemeChooserActivity.this, PoemPopularActivity.class);
startActivity(intent);
}
Expand All @@ -80,6 +84,7 @@ private void setUpHistory() {
@Override
public void onClick(View v) {
Crashlytics.log("ThemeChooser: clicked History button");
Answers.getInstance().logEvent("clicked history");
final Intent intent = new Intent(ThemeChooserActivity.this,
PoemHistoryActivity.class);
intent.putExtra(IS_NEW_POEM, false);
Expand All @@ -97,6 +102,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
final Theme theme = Theme.values()[position];
Crashlytics.log("ThemeChooser: clicked on Theme: " + theme.getDisplayName());
Crashlytics.setString(App.CRASHLYTICS_KEY_THEME, theme.getDisplayName());
Answers.getInstance().logEvent("clicked build poem", new EventAttributes().put("theme", theme.getDisplayName()));
final Intent intent = new Intent(getBaseContext(), PoemBuilderActivity.class);
intent.putExtra(PoemBuilderActivity.KEY_THEME, theme);
startActivity(intent);
Expand Down

0 comments on commit 7c5bf3e

Please sign in to comment.