Skip to content

Commit

Permalink
Add analytic events for Lookup Dictionary usage (#8283)
Browse files Browse the repository at this point in the history
* added analytic event triggers to Lookup.java fix for #8263
  • Loading branch information
ritvij14 authored Mar 24, 2021
1 parent 45ff137 commit 06d27b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions AnkiDroid/src/main/java/com/ichi2/anki/Lookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.view.View;

import com.afollestad.materialdialogs.MaterialDialog;

import com.ichi2.anki.analytics.UsageAnalytics;
import com.ichi2.libanki.Utils;

import timber.log.Timber;
Expand Down Expand Up @@ -88,6 +87,7 @@ public static boolean lookUp(String text) {
Intent aedictSearchIntent = new Intent(mDictionaryAction);
aedictSearchIntent.putExtra("kanjis", text);
mContext.startActivity(aedictSearchIntent);
UsageAnalytics.sendAnalyticsEvent(Lookup.class.getSimpleName(), UsageAnalytics.Actions.AEDICT);
return true;
case DICTIONARY_LEO_WEB:
case DICTIONARY_LEO_APP:
Expand Down Expand Up @@ -115,25 +115,30 @@ public static boolean lookUp(String text) {
mLookupText = "";
})
.build().show();
UsageAnalytics.sendAnalyticsEvent(Lookup.class.getSimpleName(), UsageAnalytics.Actions.LEO);
return true;
case DICTIONARY_COLORDICT:
Intent colordictSearchIntent = new Intent(mDictionaryAction);
colordictSearchIntent.putExtra("EXTRA_QUERY", text);
mContext.startActivity(colordictSearchIntent);
UsageAnalytics.sendAnalyticsEvent(Lookup.class.getSimpleName(), UsageAnalytics.Actions.COLORDICT);
return true;
case DICTIONARY_FORA:
Intent foraSearchIntent = new Intent(mDictionaryAction);
foraSearchIntent.putExtra("HEADWORD", text.trim());
mContext.startActivity(foraSearchIntent);
UsageAnalytics.sendAnalyticsEvent(Lookup.class.getSimpleName(), UsageAnalytics.Actions.FORA);
return true;
case DICTIONARY_NCIKU_WEB:
Intent ncikuWebIntent = new Intent(mDictionaryAction, Uri.parse("http://m.nciku.com/en/entry/?query="
+ text));
mContext.startActivity(ncikuWebIntent);
UsageAnalytics.sendAnalyticsEvent(Lookup.class.getSimpleName(), UsageAnalytics.Actions.NCIKU);
return true;
case DICTIONARY_EIJIRO_WEB:
Intent eijiroWebIntent = new Intent(mDictionaryAction, Uri.parse("http://eow.alc.co.jp/" + text));
mContext.startActivity(eijiroWebIntent);
UsageAnalytics.sendAnalyticsEvent(Lookup.class.getSimpleName(), UsageAnalytics.Actions.EIJIRO);
return true;
}
return false;
Expand Down Expand Up @@ -187,5 +192,4 @@ private static void storeLanguage(String language, int questionAnswer) {
// mCurrentCard.getCardModelId(), false).getId(), mCurrentCard.getCardModelId(), questionAnswer, language);
// }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,14 @@ public static class Actions {
public static final String OPENED_FACEBOOK = "Opened Facebook";
public static final String OPENED_TWITTER = "Opened Twitter";
public static final String EXCEPTION_REPORT = "Exception Report";

/* Analytics actions used in Lookup Dictionary */
public static final String AEDICT = "aedict";
public static final String LEO = "leo";
public static final String COLORDICT = "colordict";
public static final String FORA = "fora";
public static final String NCIKU = "nciku";
public static final String EIJIRO = "eijiro";
}

@VisibleForTesting(otherwise = VisibleForTesting.NONE) // TOOD: Make this package-protected
Expand Down

0 comments on commit 06d27b4

Please sign in to comment.