-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support redirects #7
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7 +/- ##
===========================================
+ Coverage 69.17% 69.48% +0.3%
Complexity 1 1
===========================================
Files 8 8
Lines 146 154 +8
Branches 19 21 +2
===========================================
+ Hits 101 107 +6
- Misses 37 38 +1
- Partials 8 9 +1
Continue to review full report at Codecov.
|
ddc92a8
to
b1524cc
Compare
b1524cc
to
4f9e808
Compare
|
||
/** | ||
* Http Client based on Android Volley | ||
* | ||
*/ | ||
internal class HttpClient { | ||
private val cache = DiskBasedCache(File(Constants.CACHE_DIR), 1024 * 1024) // 1MB cap |
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.
This CACHE_DIR
constant is no longer required it seems.
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.
Removed in 211a8b1
|
||
companion object { | ||
|
||
val JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8") | ||
|
||
val defaultListener = object : ResponseListener { |
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.
Can this be made private
?
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.
Improved in 211a8b1
@@ -75,17 +74,12 @@ object Util { | |||
* @return URL with the new parameters | |||
*/ | |||
@Throws(URISyntaxException::class) |
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.
Does it still throw this type?
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.
Now, this function doesn't throw. Removed in e34a461
start() | ||
} | ||
internal class HttpClient { | ||
var client = |
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.
Can't this be a val?
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.
It can. Changed in fdfa6fe
@@ -16,10 +12,39 @@ abstract class TrackingEvent( | |||
/** | |||
* Serializes the current data model to JSON | |||
*/ | |||
open fun serialize(): String { | |||
open fun toJson(): String { |
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.
Why do we still need this?
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.
In my opinion, this method gives more flexibility to SDK users. E.g., they can create a pageView, convert it to JSON and add custom properties and convert it back to a CustomTrackingEvent
.
I don't have a strong opinion about this. If you think it's best to be stricter on this matter, I'll remove it.
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.
If that is the use case, can't we just provide a method to append custom properties directly from a CustomTrackingEvent
?
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.
@Rule | ||
@JvmField | ||
val globalTimeout = Timeout.seconds(10) // 10 seconds max per method tested | ||
// @Rule |
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.
Are these supposed to be left 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.
Readded in fdfa6fe
ad1423f
to
e34a461
Compare
From what I understood from here the Did you entertain the possibility of changing our server behavior to reply with |
932e100
to
f929a22
Compare
That's right.
As discussed offline, |
@@ -14,6 +14,9 @@ class CustomTrackingEvent( | |||
@Transient | |||
override val gson = defaultGson | |||
|
|||
fun appendProperty(key: String, value: String) = |
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.
Shouldn't the value
be of type Object
?
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.
Improved in 32f7209.
@@ -11,10 +11,14 @@ class CustomTrackingEvent( | |||
val extraAttributes: JSONObject = JSONObject() |
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.
I know this is not from this PR, but if we don't have a concrete use case, I would prefer not to include the functionality to get a CustomTrackingEvent
from JSON. Also, I think the exceptions thrown should be custom (like if a given field cannot be extracted from the input JSON) and are, at this moment, generic JSON exceptions.
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.
I think we can iterate on this later. I'll create an issue with this.
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.
👍 Please leave that issue link 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.
This PR deprecates Volley in favor of OkHttp.
With this new HTTP client, we can handle redirects just by setting
.followRedirects(true)
and.followSslRedirects(true)
. I also noticed that only GET/HEAD requests follow the redirect with the same method. Any request with a different method is changed to a GET request. square/okhttp#2262To avoid running into some problems in the future, I changed the way we make tracking requests. Previously, the track request was a POST with the event in the body, now the request is a GET and the event is serialized to query parameters (similar to JS tag).
I also updated the changelog with some entries from previous PRs.