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 domain models #41

Merged
merged 17 commits into from
Mar 24, 2021
Merged

Remove domain models #41

merged 17 commits into from
Mar 24, 2021

Conversation

dimamo5
Copy link
Collaborator

@dimamo5 dimamo5 commented Mar 18, 2021

Depends on #40

Removes domain models from SDK. This changes the event argument in the tracking API to accept a JSON string or JSONObject.

@dimamo5 dimamo5 requested a review from thyandrecardoso March 18, 2021 11:08
@dimamo5 dimamo5 self-assigned this Mar 18, 2021
@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

Merging #41 (ab582f8) into master (444fed6) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master     #41   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           6       6           
  Lines         117     144   +27     
  Branches       19      27    +8     
======================================
- Misses        117     144   +27     
Impacted Files Coverage Δ
velocidi-sdk/src/main/kotlin/com/velocidi/Util.kt 0.00% <0.00%> (ø)
...ocidi-sdk/src/main/kotlin/com/velocidi/Velocidi.kt 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 444fed6...ab582f8. Read the comment docs.

@dimamo5 dimamo5 marked this pull request as ready for review March 18, 2021 19:58
@@ -1 +1 @@
version=0.4.2
version=0.5.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With all the breaking changes introduced in this PR and #39, I thought it was better to bump the minor version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, makes sense, I was thinking that was targetting a different thing. Ignore me.

val k = if (path.isEmpty()) idx else "[$idx]"
toQueryParamsAux(elem.opt(idx), qs, path + k)
}
is Boolean, is Int, is Byte, is Char, is String, is Double, is Float, is Long, is Short ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this when block exhaustive? If not, can't we just have a else or default case here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not. Unmatched types, like Null will not be serialized. In any case, I added an "else case" in 76c5c12 to make this behavior more explicit

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of something like this:

            when (elem) {
                JSONObject.NULL, null ->
                    {}
                is JSONObject ->
                    for (key in elem.keys()) {
                        val pathKey = if (path.isEmpty()) key else "[$key]"
                        toQueryParamsAux(elem[key], qs, path + pathKey)
                    }
                is JSONArray ->
                    for (idx in 0..elem.length()) {
                        toQueryParamsAux(elem.opt(idx), qs, "$path[$idx]")
                    }
                else ->
                    qs[path] = elem.toString()
            }
        }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That change will make us serialize non-primitive types and we might get some weird results. I added an example in 15d19b8 to make this clearer. Using the implementation above Foo would be serialized into foo=Foo(bar=bar), which is not a valid structure for the CDP.


assertThat(event).isEqualTo(eventObj.toQueryParams())
assertThat(event).containsAllEntriesOf(eventObj.toQueryParams())
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean, that the first map may contain more entries than the second? If so, shouldn't we be using a more strict matcher throughout the file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch. The first map could, potentially, contain more elements than the second. AssertJ (assert library used) doesn't provide a matcher that does what we want so I changed this spec to use a custom matcher everywhere. Check 51ec0d7

Copy link
Contributor

Choose a reason for hiding this comment

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

I find it strange we don't have that matcher in the core library. We have containsExactlyEntriesOf which considers order though... I guess this will do.

README.md Outdated

Velocidi.getInstance().track(CustomTrackingEventFactory.buildFromJSON(event))
//Using a JSONObject
Velocidi.getInstance().track(UserId("<Advertising ID>", "gaid"), JSONObject(eventJson))
Copy link
Contributor

Choose a reason for hiding this comment

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

As in the sample app, I would prefer to use the JSONObject as a dictionary, instead of relying on the string parsing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Improved in 413f796

Copy link
Contributor

@thyandrecardoso thyandrecardoso left a comment

Choose a reason for hiding this comment

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

Please update the changelog as well. I think we are missing some entries there, from previous PRs

@dimamo5 dimamo5 requested a review from thyandrecardoso March 23, 2021 12:32
@dimamo5 dimamo5 requested a review from thyandrecardoso March 24, 2021 11:05
@thyandrecardoso thyandrecardoso merged commit 7e60da4 into master Mar 24, 2021
@thyandrecardoso thyandrecardoso deleted the remove-domain-models branch March 24, 2021 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants