Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused analytics #2964

Merged
merged 4 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import android.widget.Toast;

import com.google.android.gms.analytics.HitBuilders;

import org.javarosa.core.model.SelectChoice;
import org.javarosa.core.model.condition.EvaluationContext;
import org.javarosa.core.model.instance.FormInstance;
Expand Down Expand Up @@ -110,12 +108,6 @@ public static XPathFuncExpr getSearchXPathExpression(String appearance) {

Matcher matcher = SEARCH_FUNCTION_REGEX.matcher(appearance);
if (matcher.find()) {
Collect.getInstance().getDefaultTracker()
.send(new HitBuilders.EventBuilder()
.setCategory("ExternalData")
.setAction("search()")
.setLabel(Collect.getCurrentFormIdentifierHash())
.build());

String function = matcher.group(0);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;

import com.google.android.gms.analytics.HitBuilders;

import org.javarosa.core.model.condition.EvaluationContext;
import org.javarosa.xpath.expr.XPathFuncExpr;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.external.ExternalDataManager;
import org.odk.collect.android.external.ExternalDataUtil;
import org.odk.collect.android.external.ExternalSQLiteOpenHelper;
Expand Down Expand Up @@ -71,12 +68,6 @@ public boolean realTime() {

@Override
public Object eval(Object[] args, EvaluationContext ec) {
Collect.getInstance().getDefaultTracker()
.send(new HitBuilders.EventBuilder()
.setCategory("ExternalData")
.setAction("pulldata()")
.setLabel(Collect.getCurrentFormIdentifierHash())
.build());

if (args.length != 4) {
Timber.e("4 arguments are needed to evaluate the %s function", HANDLER_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.google.android.gms.analytics.HitBuilders;

import org.javarosa.core.model.CoreModelModule;
import org.javarosa.core.model.FormDef;
import org.javarosa.core.model.FormIndex;
Expand Down Expand Up @@ -49,7 +47,6 @@
import org.javarosa.xform.parse.XFormParser;
import org.javarosa.xpath.XPathParseTool;
import org.javarosa.xpath.expr.XPathExpression;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.exception.JavaRosaException;
import org.odk.collect.android.utilities.AuditEventLogger;
import org.odk.collect.android.utilities.RegexUtils;
Expand Down Expand Up @@ -1220,12 +1217,6 @@ public InstanceMetadata getSubmissionMetadata() {
// timing element...
v = e.getChildrenWithName(AUDIT);
if (v.size() == 1) {
Collect.getInstance().getDefaultTracker()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep this since it's an evolving feature. It might also be good to log when location is turned on.

.send(new HitBuilders.EventBuilder()
.setCategory("AuditLogging")
.setAction("Enabled")
.setLabel(Collect.getCurrentFormIdentifierHash())
.build());

TreeElement auditElement = v.get(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@
import android.support.annotation.Nullable;
import android.view.View;

import com.google.android.gms.analytics.HitBuilders;
import com.google.common.collect.ObjectArrays;

import org.odk.collect.android.R;
import org.odk.collect.android.activities.MainMenuActivity;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.spatial.MapHelper;
import org.odk.collect.android.utilities.FileUtils;
import org.odk.collect.android.utilities.LocaleHelper;
import org.odk.collect.android.utilities.MediaUtils;

import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.TreeMap;

Expand Down Expand Up @@ -253,17 +249,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
String sourceMediaPath = MediaUtils.getPathFromUri(getActivity(), selectedMedia,
MediaStore.Images.Media.DATA);

String sourceMediaPathHash = FileUtils.getMd5Hash(new ByteArrayInputStream(sourceMediaPath.getBytes()));

// setting image path
setSplashPath(sourceMediaPath);

Collect.getInstance().getDefaultTracker()
.send(new HitBuilders.EventBuilder()
.setCategory("PreferenceChange")
.setAction("Selected splash image")
.setLabel(sourceMediaPathHash)
.build());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@

import android.content.Context;

import com.google.android.gms.analytics.HitBuilders;

import org.javarosa.core.model.Constants;
import org.javarosa.core.model.ItemsetBinding;
import org.javarosa.core.model.QuestionDef;
import org.javarosa.form.api.FormEntryPrompt;
import org.javarosa.xpath.expr.XPathExpression;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.external.ExternalDataUtil;

import java.util.List;
import java.util.Locale;

import timber.log.Timber;
Expand Down Expand Up @@ -130,13 +123,6 @@ public static QuestionWidget createWidgetFromPrompt(FormEntryPrompt fep, Context
String query = fep.getQuestion().getAdditionalAttribute(null, "query");
if (query != null) {
questionWidget = new ItemsetWidget(context, fep, appearance.startsWith("quick"));

Collect.getInstance().getDefaultTracker()
.send(new HitBuilders.EventBuilder()
.setCategory("ExternalData")
.setAction("External itemset")
.setLabel(Collect.getCurrentFormIdentifierHash())
.build());
} else if (appearance.startsWith("printer")) {
questionWidget = new ExPrinterWidget(context, fep);
} else if (appearance.startsWith("ex:")) {
Expand Down Expand Up @@ -217,7 +203,6 @@ public static QuestionWidget createWidgetFromPrompt(FormEntryPrompt fep, Context
} else {
questionWidget = new SelectOneWidget(context, fep, appearance.contains("quick"));
}
logChoiceFilterAnalytics(fep.getQuestion());
break;
case Constants.CONTROL_SELECT_MULTI:
// search() appearance/function (not part of XForms spec) added by SurveyCTO gets
Expand Down Expand Up @@ -253,7 +238,6 @@ public static QuestionWidget createWidgetFromPrompt(FormEntryPrompt fep, Context
} else {
questionWidget = new SelectMultiWidget(context, fep);
}
logChoiceFilterAnalytics(fep.getQuestion());
break;
case Constants.CONTROL_RANK:
questionWidget = new RankingWidget(context, fep);
Expand Down Expand Up @@ -286,35 +270,4 @@ public static QuestionWidget createWidgetFromPrompt(FormEntryPrompt fep, Context

return questionWidget;
}

/**
* Log analytics event each time a question with a choice filter is accessed, identifying
* choice filters with relative expressions. This was initially introduced to inform messaging
* around a long-standing bug in JavaRosa: https://github.com/opendatakit/javarosa/issues/293
*/
private static void logChoiceFilterAnalytics(QuestionDef question) {
ItemsetBinding itemsetBinding = question.getDynamicChoices();

if (itemsetBinding != null && itemsetBinding.nodesetRef != null) {
if (itemsetBinding.nodesetRef.hasPredicates()) {
for (int level = 0; level < itemsetBinding.nodesetRef.size(); level++) {
List<XPathExpression> predicates = itemsetBinding.nodesetRef.getPredicate(level);

if (predicates != null) {
for (XPathExpression predicate : predicates) {
String actionName = predicate.toString().contains("func-expr:current") ?
"CurrentPredicate" : "NonCurrentPredicate";

Collect.getInstance().getDefaultTracker()
.send(new HitBuilders.EventBuilder()
.setCategory("Itemset")
.setAction(actionName)
.setLabel(Collect.getCurrentFormIdentifierHash())
.build());
}
}
}
}
}
}
}