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

feat: in app click tracking #187

Merged
merged 2 commits into from
Apr 19, 2023
Merged

feat: in app click tracking #187

merged 2 commits into from
Apr 19, 2023

Conversation

Shahroz16
Copy link
Contributor

@Shahroz16 Shahroz16 commented Apr 12, 2023

closes: https://github.com/customerio/issues/issues/8657

Complete each step to get your pull request merged in. Learn more about the workflow this project uses.

  • Assign members of your team to review the pull request.
  • Wait for pull request status checks to complete. If there are problems, fix them until you see that all status checks are passing.
  • Wait until the pull request has been reviewed and approved by a teammate
  • After pull request is approved, and you determine it's ready add the label "Ready to merge" to the pull request and it will automatically be merged.

@github-actions
Copy link

github-actions bot commented Apr 12, 2023

Pull request title looks good 👍!

If this pull request gets merged, it will cause a new release of the software. Example: If this project's latest release version is 1.0.0. If this pull request gets merged in, the next release of this project will be 1.1.0. This pull request is not a breaking change.

All merged pull requests will eventually get deployed. But some types of pull requests will trigger a deployment (such as features and bug fixes) while some pull requests will wait to get deployed until a later time.

This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...

This project uses a special format for pull requests titles. Don't worry, it's easy!

This pull request title should be in this format:

<type>: short description of change being made

If your pull request introduces breaking changes to the code, use this format:

<type>!: short description of breaking change

where <type> is one of the following:

  • feat: - A feature is being added or modified by this pull request. Use this if you made any changes to any of the features of the project.

  • fix: - A bug is being fixed by this pull request. Use this if you made any fixes to bugs in the project.

  • docs: - This pull request is making documentation changes, only.

  • refactor: - A change was made that doesn't fix a bug or add a feature.

  • test: - Adds missing tests or fixes broken tests.

  • style: - Changes that do not effect the code (whitespace, linting, formatting, semi-colons, etc)

  • perf: - Changes improve performance of the code.

  • build: - Changes to the build system (maven, npm, gulp, etc)

  • ci: - Changes to the CI build system (Travis, GitHub Actions, Circle, etc)

  • chore: - Other changes to project that don't modify source code or test files.

  • revert: - Reverts a previous commit that was made.

Examples:

feat: edit profile photo
refactor!: remove deprecated v1 endpoints
build: update npm dependencies
style: run formatter 

Need more examples? Want to learn more about this format? Check out the official docs.

Note: If your pull request does multiple things such as adding a feature and makes changes to the CI server and fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests.

@github-actions
Copy link

github-actions bot commented Apr 12, 2023

Hey, there @Shahroz16 👋🤖. I'm a bot here to help you.

⚠️ Pull requests into the branch main typically only allows changes with the types: fix. From the pull request title, the type of change this pull request is trying to complete is: feat. ⚠️

This pull request might still be allowed to be merged. However, you might want to consider make this pull request merge into a different branch other then main.

This project uses a special format for pull requests titles. Expand this section to learn more (expand by clicking the ᐅ symbol on the left side of this sentence)...

This project uses a special format for pull requests titles. Don't worry, it's easy!

This pull request title should be in this format:

<type>: short description of change being made

If your pull request introduces breaking changes to the code, use this format:

<type>!: short description of breaking change

where <type> is one of the following:

  • feat: - A feature is being added or modified by this pull request. Use this if you made any changes to any of the features of the project.

  • fix: - A bug is being fixed by this pull request. Use this if you made any fixes to bugs in the project.

  • docs: - This pull request is making documentation changes, only.

  • refactor: - A change was made that doesn't fix a bug or add a feature.

  • test: - Adds missing tests or fixes broken tests.

  • style: - Changes that do not effect the code (whitespace, linting, formatting, semi-colons, etc)

  • perf: - Changes improve performance of the code.

  • build: - Changes to the build system (maven, npm, gulp, etc)

  • ci: - Changes to the CI build system (Travis, GitHub Actions, Circle, etc)

  • chore: - Other changes to project that don't modify source code or test files.

  • revert: - Reverts a previous commit that was made.

Examples:

feat: edit profile photo
refactor!: remove deprecated v1 endpoints
build: update npm dependencies
style: run formatter 

Need more examples? Want to learn more about this format? Check out the official docs.

Note: If your pull request does multiple things such as adding a feature and makes changes to the CI server and fixes some bugs then you might want to consider splitting this pull request up into multiple smaller pull requests.

@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Merging #187 (55a1836) into main (a410e6d) will decrease coverage by 0.15%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##               main     #187      +/-   ##
============================================
- Coverage     63.52%   63.38%   -0.15%     
  Complexity      218      218              
============================================
  Files            91       91              
  Lines          2051     2059       +8     
  Branches        263      263              
============================================
+ Hits           1303     1305       +2     
- Misses          646      654       +8     
+ Partials        102      100       -2     
Impacted Files Coverage Δ
...io/customer/messaginginapp/ModuleMessagingInApp.kt 59.32% <0.00%> (-1.03%) ⬇️
...java/io/customer/sdk/data/request/DeliveryEvent.kt 0.00% <0.00%> (ø)
sdk/src/main/java/io/customer/sdk/queue/Queue.kt 81.73% <0.00%> (-0.80%) ⬇️
...java/io/customer/sdk/repository/TrackRepository.kt 57.57% <0.00%> (-10.29%) ⬇️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link

Build available to test
Version: shahroz-in-app-click-tracking-SNAPSHOT
Repository: https://s01.oss.sonatype.org/content/repositories/snapshots/

@Shahroz16 Shahroz16 marked this pull request as ready for review April 12, 2023 12:41
@Shahroz16 Shahroz16 requested a review from a team April 12, 2023 12:41
@Shahroz16 Shahroz16 self-assigned this Apr 12, 2023
@@ -13,7 +13,8 @@ internal enum class DeliveryType {
internal data class DeliveryPayload(
@field:Json(name = "delivery_id") val deliveryID: String,
val event: MetricEvent,
val timestamp: Date
val timestamp: Date,
@field:Json(name = "metadata") val metaData: Map<String, String>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@field:Json(name = "metadata") val metaData: Map<String, String>
val metadata: Map<String, String>

I think metadata is spelled as one word. having it as one word could make this code more simple, too.

Copy link
Member

Choose a reason for hiding this comment

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

Separately, from the ticket, the metadata payload is defined currently. I would prefer instead of using Map<String, String>, we have a data class with action_name and action_value inside of it.

Copy link
Contributor Author

@Shahroz16 Shahroz16 Apr 12, 2023

Choose a reason for hiding this comment

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

I think metadata is spelled as one word

I usually see it as meta-data, in android.content.pm Android class, they use the variable public Bundle metaData;

The metadata payload is defined currently in ticket

I don't think that is the case, that was for illustration purposes only. In Web SDK it's not a class either but a dictionary.

Copy link
Member

Choose a reason for hiding this comment

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

I think metadata is spelled as one word

Huh. That is the first time I have seen metaData. In this PR, I see metaData and metadata both being used and I would prefer consistency being used in the codebase. Especially with a @Json annotation of metadata. I am not going to block this PR based on this, however.

The metadata payload is defined currently in ticket

If the SDK sends a pre-determined data set like this PR currently does (we send 2 properties, and the keys are hard-coded), then I would strongly prefer we stick with a strongly typed data set. However, such as the feature of profile/device attributes where we allow customers to send an undetermined data set with undetermined keys, that's where I see a Map being helpful. This is the piece of the PR that currently holds me back from approval of the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the SDK sends a pre-determined data set

I think that's our assumption that BE would always require these 2 values because the meta-data could be more than that. We only need these two variables, but in the future, we might need more. I don't think it's fixed it's always going to be only these 2 variables forever.

So that is why I am more comfortable, with Map, I think the product shared the same idea as this is also a Map in the web SDK as mentioned earlier. So I would like to stick with the Map, if you feel more strongly about it, we can check with the broader team for you.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that Map is a great solution when the backend accepts a not pre-determined data set. I also agree that the backend today accepts a pre-determined data set and could change that requirement.

The backend may never make a requirement change. It might make a requirement change to a different endpoint, not this one.

In my code review, I am suggesting to the team that when a payload is pre-determined in the API today, we use a data class. When the payload is not pre-determiend in the API today, we use a Map. When the backend makes a change to it's requirements, we make a modification to the SDKs to conform to that change.

Since we cannot predict the future and the backend may never make a requirements change, I would rather use strongly typed data classes when possible to make our code easier to maintain.

Copy link
Contributor Author

@Shahroz16 Shahroz16 Apr 14, 2023

Choose a reason for hiding this comment

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

Thanks for the insights, I agree on the backend may or may not require changes, but metadata for me makes sense as a Map, as it is supposed to not be pre-defined in nature even if it has pre-defined keys. Like the Android class, I mentioned earlier has meta-data as a Bundle which could hold any key and value.

I don't want to add another class that we need to keep and maintain for this use case. It's the same thing as using Pair or any other data structure provided for convenience, all of them could be replaced by a static data class.

I think it comes down to personal preference, and I see Rehan has approved it already, web is also using Map so a lot of members of the team aren't married to the idea of replacing Map with a static class in this case.

So I would like to stick with it as well, I don't feel like it's a blocker because it's not customer-facing nor is its performance related but rather preference.

Copy link
Member

Choose a reason for hiding this comment

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

To try and make communication easier on this thread, I played with the code and made a refactor for this branch illustrating what I was referring to in my comments above.

I do have a personal preference to use strongly-typed data classes when possible. However, I am open to not use a strong data type for this use case if the rest of the team prefers not to.

To prevent this PR from being a blocker, I'll approve this PR and leave it up to the rest of the team to decide if this PR gets deployed as-is or include the refactor.

Thanks for the work on the PR and the PR review conversations 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Appreciate the PR Levi, it helps unblock and make sure that even if the work refactoring doesn't get merged in this round it can get merged in the second one. Refactor looks good, but I might not be able to test out if the json structuring is coming out correctly and test it manually with RH to see if all cases are working.

If you can do that and confirm, I'll happily merge otherwise, If I manage to test it out myself I'll merge it otherwise I'll go with the current implementation which was tested by me. 👍

@Shahroz16 Shahroz16 merged commit 4ad1f35 into main Apr 19, 2023
24 checks passed
@Shahroz16 Shahroz16 deleted the shahroz/in-app-click-tracking branch April 19, 2023 12:30
github-actions bot pushed a commit that referenced this pull request Apr 19, 2023
## [3.4.0](3.3.2...3.4.0) (2023-04-19)

### Features

* in app click tracking ([#187](#187)) ([4ad1f35](4ad1f35))
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.

None yet

3 participants