Commit 77b144ab authored by Mudar Noufal's avatar Mudar Noufal

Added metrics

using crashlytics/fabric answers
parent 3068af9c
......@@ -170,6 +170,19 @@ public class Const {
String DIALOG_OD_CREDITS = "dialog_od_credits";
}
public interface MetricsContentTypes {
String MAP = "Map";
String SETTINGS = "Settings";
String ABOUT = "About";
}
public interface MetricsContentNames {
String SETTINGS = "SettingsActivity";
String ABOUT = "AboutActivity";
String ABOUT_LIBS = "AboutLibsActivity";
String EULA = "EulaActivity";
}
/**
* Other constants
*/
......
/*
Montréal Just in Case
Copyright (C) 2011 Mudar Noufal <mn@mudar.ca>
Geographic locations of public safety services. A Montréal Open Data
project.
This file is part of Montréal Just in Case.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.mudar.mtlaucasou.model;
import android.support.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import ca.mudar.mtlaucasou.Const;
@Retention(RetentionPolicy.SOURCE)
@StringDef({
Const.MapTypes.FIRE_HALLS,
Const.MapTypes.SPVM_STATIONS,
Const.MapTypes.HEAT_WAVE,
Const.MapTypes.EMERGENCY_HOSTELS,
Const.MapTypes.HEALTH,
Const.MetricsContentNames.SETTINGS,
Const.MetricsContentNames.ABOUT,
Const.MetricsContentNames.ABOUT_LIBS,
Const.MetricsContentNames.EULA,
})
public @interface MetricsContentName {
}
\ No newline at end of file
/*
Montréal Just in Case
Copyright (C) 2011 Mudar Noufal <mn@mudar.ca>
Geographic locations of public safety services. A Montréal Open Data
project.
This file is part of Montréal Just in Case.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.mudar.mtlaucasou.model;
import android.support.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import ca.mudar.mtlaucasou.Const;
@Retention(RetentionPolicy.SOURCE)
@StringDef({
Const.MetricsContentTypes.MAP,
Const.MetricsContentTypes.SETTINGS,
Const.MetricsContentTypes.ABOUT})
public @interface MetricsContentType {
}
\ No newline at end of file
......@@ -33,6 +33,7 @@ import ca.mudar.mtlaucasou.Const;
import ca.mudar.mtlaucasou.R;
import ca.mudar.mtlaucasou.ui.dialog.OpenDataCreditsDialog;
import ca.mudar.mtlaucasou.util.IntentUtils;
import ca.mudar.mtlaucasou.util.MetricsUtils;
public class AboutActivity extends BaseActivity implements
View.OnClickListener {
......@@ -47,6 +48,8 @@ public class AboutActivity extends BaseActivity implements
// setTitle(R.string.title_activity_about);
setContentView(R.layout.activity_about);
MetricsUtils.logAboutView(Const.MetricsContentNames.ABOUT);
}
@Override
......
......@@ -44,6 +44,7 @@ import ca.mudar.mtlaucasou.util.IntentUtils;
import ca.mudar.mtlaucasou.util.LangUtils;
import ca.mudar.mtlaucasou.util.LogUtils;
import ca.mudar.mtlaucasou.util.MapUtils;
import ca.mudar.mtlaucasou.util.MetricsUtils;
import uk.co.samuelwall.materialtaptargetprompt.MaterialTapTargetPrompt;
import static ca.mudar.mtlaucasou.util.LogUtils.makeLogTag;
......@@ -169,6 +170,8 @@ public abstract class BaseActivity extends AppCompatActivity implements
"AndroidIconics", "fastadapter", "okio", "support_v4"
)
.start(getApplicationContext());
MetricsUtils.logAboutView(Const.MetricsContentNames.ABOUT_LIBS);
}
/**
......
......@@ -36,6 +36,7 @@ import android.webkit.WebViewClient;
import ca.mudar.mtlaucasou.Const;
import ca.mudar.mtlaucasou.R;
import ca.mudar.mtlaucasou.data.UserPrefs;
import ca.mudar.mtlaucasou.util.MetricsUtils;
public class EulaActivity extends BaseActivity implements View.OnClickListener {
private static final String ASSETS_URI = "file:///android_asset/";
......@@ -64,6 +65,10 @@ public class EulaActivity extends BaseActivity implements View.OnClickListener {
loadWebView((WebView) findViewById(R.id.webview));
findViewById(R.id.btn_accept_eula).setOnClickListener(this);
if (hasAcceptedEula) {
MetricsUtils.logAboutView(Const.MetricsContentNames.EULA);
}
}
@Override
......
......@@ -67,6 +67,7 @@ import ca.mudar.mtlaucasou.ui.view.PlacemarksSearchView;
import ca.mudar.mtlaucasou.util.EulaUtils;
import ca.mudar.mtlaucasou.util.LogUtils;
import ca.mudar.mtlaucasou.util.MapUtils;
import ca.mudar.mtlaucasou.util.MetricsUtils;
import ca.mudar.mtlaucasou.util.NavigUtils;
import ca.mudar.mtlaucasou.util.PermissionUtils;
import io.realm.Realm;
......@@ -350,6 +351,8 @@ public class MainActivity extends BaseActivity implements
}
}, delay);
}
MetricsUtils.logMapView(type);
}
/**
......
......@@ -33,6 +33,7 @@ import ca.mudar.mtlaucasou.Const;
import ca.mudar.mtlaucasou.R;
import ca.mudar.mtlaucasou.ui.fragment.SettingsFragment;
import ca.mudar.mtlaucasou.util.LangUtils;
import ca.mudar.mtlaucasou.util.MetricsUtils;
public class SettingsActivity extends AppCompatActivity implements
SettingsFragment.OnConfigChangeListener {
......@@ -52,6 +53,8 @@ public class SettingsActivity extends AppCompatActivity implements
.replace(android.R.id.content, fragment, Const.FragmentTags.SETTINGS)
.commit();
}
MetricsUtils.logSettingsView();
}
/**
......
/*
Montréal Just in Case
Copyright (C) 2011 Mudar Noufal <mn@mudar.ca>
Geographic locations of public safety services. A Montréal Open Data
project.
This file is part of Montréal Just in Case.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ca.mudar.mtlaucasou.util;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.ContentViewEvent;
import ca.mudar.mtlaucasou.BuildConfig;
import ca.mudar.mtlaucasou.Const;
import ca.mudar.mtlaucasou.Const.MetricsContentTypes;
import ca.mudar.mtlaucasou.model.MetricsContentName;
import ca.mudar.mtlaucasou.model.MetricsContentType;
public class MetricsUtils {
public static void logMapView(@MetricsContentName String mapType) {
logView(mapType, MetricsContentTypes.MAP);
}
public static void logSettingsView() {
logView(Const.MetricsContentNames.SETTINGS, MetricsContentTypes.SETTINGS);
}
public static void logAboutView(@MetricsContentName String name) {
logView(name, MetricsContentTypes.ABOUT);
}
private static void logView(@MetricsContentName String contentName, @MetricsContentType String contentType) {
if (BuildConfig.USE_CRASHLYTICS) {
Answers.getInstance().logContentView(new ContentViewEvent()
.putContentName(contentName)
.putContentType(contentType));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment