-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Track referrer for INSTANCE_UPLOAD action #6474
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ public class InstanceUploaderTask extends AsyncTask<Long, Integer, InstanceUploa | |
// Custom submission URL, username and password that can be sent via intent extras by external | ||
// applications | ||
private String completeDestinationUrl; | ||
private String referrer = "org.odk.collect.android"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the back and forth, but I just caught this. Why do we set this to Just want to make sure we're only logging in cases where the custom URL is being used here and that I'm not missing something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right it was redundant. |
||
private String customUsername; | ||
private String customPassword; | ||
private InstancesRepository instancesRepository; | ||
|
@@ -108,7 +109,7 @@ public Outcome doInBackground(Long... instanceIdsToUpload) { | |
publishProgress(i + 1, instancesToUpload.size()); | ||
|
||
if (completeDestinationUrl != null) { | ||
Analytics.log(AnalyticsEvents.INSTANCE_UPLOAD_CUSTOM_SERVER); | ||
Analytics.log(AnalyticsEvents.INSTANCE_UPLOAD_CUSTOM_SERVER, "referrer", referrer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lognaturel logging like this limits us to viewing a max of 200 distinct values right? As far as I'm aware there isn't another way to log custom data though (other than a user property which isn't really appropriate). Also assuming we do want to do an event. It needs to be setup on Firebase as far as I can remember. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 200 limit is right and I'll be absolutely flabbergasted if there are more than 5-10 uniques!!
Ooh, good call. I don't remember that part at all. Would you be ok doing it when you have some time (no big rush)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a limit on how many custom parameters we have, so I think we should use the existing generic "label" here rather than add "referrer". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, that's a good call. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} | ||
|
||
try { | ||
|
@@ -202,12 +203,9 @@ public void setRepositories(InstancesRepository instancesRepository, FormsReposi | |
this.settingsProvider = settingsProvider; | ||
} | ||
|
||
public void setCompleteDestinationUrl(String completeDestinationUrl) { | ||
setCompleteDestinationUrl(completeDestinationUrl, true); | ||
} | ||
|
||
public void setCompleteDestinationUrl(String completeDestinationUrl, boolean clearPreviousConfig) { | ||
public void setCompleteDestinationUrl(String completeDestinationUrl, String referrer, boolean clearPreviousConfig) { | ||
this.completeDestinationUrl = completeDestinationUrl; | ||
this.referrer = referrer; | ||
if (clearPreviousConfig) { | ||
setTemporaryCredentials(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we definitely just want the host here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked a bit deeper into this and it looks like the referrer extra needs to be explicitly set: https://developer.android.com/reference/android/content/Intent#EXTRA_REFERRER It sounds like it's set automatically when the referrer is a web app but not when it's an Android app. We may get all nulls but I still think we should try it.
Can we just return
referrerUri.toString
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good:
-- https://developer.android.com/reference/android/app/Activity#getReferrer()
I thought I was losing my mind for a minute there, I could have sworn I saw more certainty that it would be set.
Still,
referrerUri.toString
seems like the best thing to return.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I changed it to referrerUri.toString if you prefer it.
I tested it with Collect Intents Tester and it didn't return nulls.