analytics
This commit is contained in:
@@ -53,4 +53,6 @@ dependencies {
|
|||||||
compile('com.mikepenz:aboutlibraries:5.3.6@aar') {
|
compile('com.mikepenz:aboutlibraries:5.3.6@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compile 'com.google.android.gms:play-services-analytics:8.4.0'
|
||||||
}
|
}
|
||||||
|
|||||||
45
app/google-services.json
Normal file
45
app/google-services.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_id": "notificationlogger",
|
||||||
|
"project_number": "592676030769",
|
||||||
|
"name": "notificationlogger"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:592676030769:android:01536270f9b0bf2a",
|
||||||
|
"client_id": "android:net.headlezz.notificationlogger",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "net.headlezz.notificationlogger"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [],
|
||||||
|
"services": {
|
||||||
|
"analytics_service": {
|
||||||
|
"status": 2,
|
||||||
|
"analytics_property": {
|
||||||
|
"tracking_id": "UA-39570140-8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cloud_messaging_service": {
|
||||||
|
"status": 1,
|
||||||
|
"apns_config": []
|
||||||
|
},
|
||||||
|
"appinvite_service": {
|
||||||
|
"status": 1,
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
},
|
||||||
|
"google_signin_service": {
|
||||||
|
"status": 1
|
||||||
|
},
|
||||||
|
"ads_service": {
|
||||||
|
"status": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"client_info": [],
|
||||||
|
"ARTIFACT_VERSION": "1"
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
package="net.headlezz.notificationlogger">
|
package="net.headlezz.notificationlogger">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".Application"
|
android:name=".Application"
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package net.headlezz.notificationlogger;
|
||||||
|
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
|
import com.google.android.gms.analytics.HitBuilders;
|
||||||
|
import com.google.android.gms.analytics.Tracker;
|
||||||
|
|
||||||
|
public class Analytics {
|
||||||
|
|
||||||
|
public static final String ACTION_APP_INFO_OPENED = "App Info opened";
|
||||||
|
public static final String ACTION_NOTIFICATION_DETAILS_SHOWN = "Notification details shown";
|
||||||
|
public static final String ACTION_CUSTOM_NOTIFICATION_DISPATCHED = "Notification dispatched";
|
||||||
|
public static final String ACTION_CUSTOM_NOTIFICATION_SCHEDULED= "Notification scheduled";
|
||||||
|
public static final String ACTION_ABOUT= "About opened";
|
||||||
|
public static final String ACTION_DATABASE_CLEARED= "database cleared";
|
||||||
|
public static final String ACTION_EXPORTED = "Notifications exported";
|
||||||
|
|
||||||
|
private static Tracker getTracker() {
|
||||||
|
return Application.singleton.getDefaultTracker();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void trackFragment(Fragment frag) {
|
||||||
|
Tracker tracker = getTracker();
|
||||||
|
tracker.setScreenName(frag.getClass().getSimpleName());
|
||||||
|
tracker.send(new HitBuilders.ScreenViewBuilder().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void trackEvent(String action) {
|
||||||
|
Tracker tracker = getTracker();
|
||||||
|
tracker.send(new HitBuilders.EventBuilder()
|
||||||
|
.setCategory("Action")
|
||||||
|
.setAction(action)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,12 +1,35 @@
|
|||||||
package net.headlezz.notificationlogger;
|
package net.headlezz.notificationlogger;
|
||||||
|
|
||||||
|
import com.google.android.gms.analytics.GoogleAnalytics;
|
||||||
|
import com.google.android.gms.analytics.Tracker;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class Application extends android.app.Application {
|
public class Application extends android.app.Application {
|
||||||
|
|
||||||
|
public static Application singleton;
|
||||||
|
|
||||||
|
private Tracker mTracker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
singleton = this;
|
||||||
Timber.plant(new Timber.DebugTree());
|
Timber.plant(new Timber.DebugTree());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default {@link Tracker} for this {@link Application}.
|
||||||
|
* @return tracker
|
||||||
|
*/
|
||||||
|
synchronized public Tracker getDefaultTracker() {
|
||||||
|
if (mTracker == null) {
|
||||||
|
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
|
||||||
|
if(BuildConfig.DEBUG)
|
||||||
|
analytics.setDryRun(true);
|
||||||
|
// To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
|
||||||
|
mTracker = analytics.newTracker(R.xml.global_tracker);
|
||||||
|
}
|
||||||
|
return mTracker;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.google.android.gms.analytics.HitBuilders;
|
||||||
|
import com.google.android.gms.analytics.Tracker;
|
||||||
|
|
||||||
import net.headlezz.notificationlogger.createnotification.NotificationCreationFragment;
|
import net.headlezz.notificationlogger.createnotification.NotificationCreationFragment;
|
||||||
import net.headlezz.notificationlogger.logger.LoggerUtils;
|
import net.headlezz.notificationlogger.logger.LoggerUtils;
|
||||||
import net.headlezz.notificationlogger.notificationlist.NotificationListFragment;
|
import net.headlezz.notificationlogger.notificationlist.NotificationListFragment;
|
||||||
@@ -38,6 +41,7 @@ public class MainActivity extends AppCompatActivity implements SharedPreferences
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.main_activity);
|
setContentView(R.layout.main_activity);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
setSupportActionBar(mToolbar);
|
setSupportActionBar(mToolbar);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.headlezz.notificationlogger;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
@@ -48,4 +49,10 @@ public class NotificationInfoDialog extends AlertDialog implements DialogInterfa
|
|||||||
Toast.makeText(getContext(), R.string.notification_info_dialog_app_info_error, Toast.LENGTH_LONG).show();
|
Toast.makeText(getContext(), R.string.notification_info_dialog_app_info_error, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Analytics.trackEvent(Analytics.ACTION_NOTIFICATION_DETAILS_SHOWN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public class PackageUtils {
|
|||||||
intent.setData(Uri.fromParts("package", packageName, null));
|
intent.setData(Uri.fromParts("package", packageName, null));
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
Analytics.trackEvent(Analytics.ACTION_APP_INFO_OPENED);
|
||||||
return true;
|
return true;
|
||||||
} catch ( ActivityNotFoundException e ) {
|
} catch ( ActivityNotFoundException e ) {
|
||||||
Timber.e("Failed to open app info", e);
|
Timber.e("Failed to open app info", e);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import net.headlezz.notificationlogger.Analytics;
|
||||||
import net.headlezz.notificationlogger.R;
|
import net.headlezz.notificationlogger.R;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -109,6 +110,12 @@ public class NotificationCreationFragment extends Fragment implements View.OnCli
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
Analytics.trackFragment(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -147,9 +154,10 @@ public class NotificationCreationFragment extends Fragment implements View.OnCli
|
|||||||
.setCategory(categories[spCategory.getSelectedItemPosition()])
|
.setCategory(categories[spCategory.getSelectedItemPosition()])
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if(v.getId() == R.id.create_btDispatch)
|
if(v.getId() == R.id.create_btDispatch) {
|
||||||
dn.dispatch();
|
dn.dispatch();
|
||||||
else
|
Analytics.trackEvent(Analytics.ACTION_CUSTOM_NOTIFICATION_DISPATCHED);
|
||||||
|
} else
|
||||||
sheduleNotification(dn);
|
sheduleNotification(dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,8 +198,10 @@ public class NotificationCreationFragment extends Fragment implements View.OnCli
|
|||||||
@Override
|
@Override
|
||||||
public void onDismissed(Snackbar snackbar, int event) {
|
public void onDismissed(Snackbar snackbar, int event) {
|
||||||
super.onDismissed(snackbar, event);
|
super.onDismissed(snackbar, event);
|
||||||
if(dispatch)
|
if(dispatch) {
|
||||||
mNotification.shedule(mDispatchDate);
|
mNotification.shedule(mDispatchDate);
|
||||||
|
Analytics.trackEvent(Analytics.ACTION_CUSTOM_NOTIFICATION_SCHEDULED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import net.headlezz.notificationlogger.Analytics;
|
||||||
import net.headlezz.notificationlogger.DatabaseUtils;
|
import net.headlezz.notificationlogger.DatabaseUtils;
|
||||||
import net.headlezz.notificationlogger.NotificationInfoDialog;
|
import net.headlezz.notificationlogger.NotificationInfoDialog;
|
||||||
import net.headlezz.notificationlogger.R;
|
import net.headlezz.notificationlogger.R;
|
||||||
@@ -67,6 +68,12 @@ public class NotificationListFragment extends Fragment implements NotificationLi
|
|||||||
mLoaderManager.loadNotificationsUnfiltered();
|
mLoaderManager.loadNotificationsUnfiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
Analytics.trackFragment(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import net.headlezz.notificationlogger.Analytics;
|
||||||
import net.headlezz.notificationlogger.DatabaseUtils;
|
import net.headlezz.notificationlogger.DatabaseUtils;
|
||||||
import net.headlezz.notificationlogger.PackageUtils;
|
import net.headlezz.notificationlogger.PackageUtils;
|
||||||
import net.headlezz.notificationlogger.R;
|
import net.headlezz.notificationlogger.R;
|
||||||
@@ -67,6 +68,12 @@ public class BlacklistFragment extends Fragment implements LoaderManager.LoaderC
|
|||||||
getLoaderManager().initLoader(LOADER_ID, Bundle.EMPTY, this);
|
getLoaderManager().initLoader(LOADER_ID, Bundle.EMPTY, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
Analytics.trackFragment(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
Timber.d("blacklistloader created");
|
Timber.d("blacklistloader created");
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import com.mikepenz.aboutlibraries.LibsBuilder;
|
import com.mikepenz.aboutlibraries.LibsBuilder;
|
||||||
import com.mikepenz.aboutlibraries.ui.LibsSupportFragment;
|
import com.mikepenz.aboutlibraries.ui.LibsSupportFragment;
|
||||||
|
|
||||||
|
import net.headlezz.notificationlogger.Analytics;
|
||||||
import net.headlezz.notificationlogger.R;
|
import net.headlezz.notificationlogger.R;
|
||||||
|
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
@@ -46,6 +47,8 @@ public class PreferenceActivity extends AppCompatActivity implements PreferenceF
|
|||||||
.replace(R.id.fragment_holder, aboutFrag)
|
.replace(R.id.fragment_holder, aboutFrag)
|
||||||
.addToBackStack("about")
|
.addToBackStack("about")
|
||||||
.commit();
|
.commit();
|
||||||
|
|
||||||
|
Analytics.trackEvent(Analytics.ACTION_ABOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
|
|
||||||
|
import net.headlezz.notificationlogger.Analytics;
|
||||||
import net.headlezz.notificationlogger.DatabaseUtils;
|
import net.headlezz.notificationlogger.DatabaseUtils;
|
||||||
import net.headlezz.notificationlogger.R;
|
import net.headlezz.notificationlogger.R;
|
||||||
import net.headlezz.notificationlogger.logger.LoggedNotification;
|
import net.headlezz.notificationlogger.logger.LoggedNotification;
|
||||||
@@ -64,6 +65,12 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Pref
|
|||||||
setBlacklistItemCount();
|
setBlacklistItemCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
Analytics.trackFragment(this);
|
||||||
|
}
|
||||||
|
|
||||||
private void setBlacklistItemCount() {
|
private void setBlacklistItemCount() {
|
||||||
new AsyncTask<Void, Void, Integer>() {
|
new AsyncTask<Void, Void, Integer>() {
|
||||||
|
|
||||||
@@ -188,6 +195,7 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Pref
|
|||||||
snack.show();
|
snack.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Analytics.trackEvent(Analytics.ACTION_EXPORTED);
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
@@ -212,6 +220,7 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Pref
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
clearDatabase();
|
clearDatabase();
|
||||||
|
Analytics.trackEvent(Analytics.ACTION_DATABASE_CLEARED);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create().show();
|
.create().show();
|
||||||
|
|||||||
4
app/src/main/res/values/system_strings.xml
Normal file
4
app/src/main/res/values/system_strings.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="analytics_tracking_id">UA-39570140-8</string>
|
||||||
|
</resources>
|
||||||
12
app/src/main/res/xml/global_tracker.xml
Normal file
12
app/src/main/res/xml/global_tracker.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<resources>
|
||||||
|
<string name="ga_trackingId">@string/analytics_tracking_id</string>
|
||||||
|
<string name="ga_sampleFrequency">100.0</string>
|
||||||
|
<integer name="ga_sessionTimeout">1800</integer>
|
||||||
|
<bool name="ga_autoActivityTracking">true</bool>
|
||||||
|
<bool name="ga_anonymizeIp">false</bool>
|
||||||
|
<bool name="ga_reportUncaughtExceptions">true</bool>
|
||||||
|
|
||||||
|
<screenName name="net.headlezz.notificationlogger.MainActivity">Home Screen</screenName>
|
||||||
|
<screenName name="net.headlezz.notificationlogger.preferences.PreferenceActivity">Preference Screen</screenName>
|
||||||
|
</resources>
|
||||||
@@ -14,6 +14,7 @@ buildscript {
|
|||||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
classpath 'com.google.gms:google-services:1.5.0-beta2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user