customerio / customerio-android

This is the official Customer.io SDK for Android.
MIT License
13 stars 9 forks source link

feat!: register device attributes when set #101

Closed levibostian closed 2 years ago

levibostian commented 2 years ago

Closes: https://github.com/customerio/issues/issues/7296

Why this change is being proposed

Now that we have a background queue and we can make synchronous changes in the SDK, let's make an enhancement to the SDK in regards to custom device attributes.

The SDK today behaves like this.

  1. Customer sets custom device attributes in the SDK
  2. Custom device attributes do not get sent to CIO until the next time that registerDeviceToken() is called

This could cause customer confusion where they try to add custom device attributes and wonder why they are not added to CIO.

Proposal is to change the behavior of the SDK to:

  1. Customer sets custom device attributes in the SDK
  2. If a push device has already been registered with the SDK, add a task to the background queue to register device token again with these newly set custom device attributes.

This change increases the chances that the device attributes will be sent to CIO.

Breaking change

This PR has a breaking change in the API.

Previously, to add custom device attributes in the SDK, you would call:

CustomerIO.instance().deviceAttributes.putAll(mapOf(...))

This PR changes the API to syntax that is more familiar to Kotlin developers:

CustomerIO.instance().deviceAttributes = mapOf(...)

Because this PR will be deployed to the current 2.0 release, this breaking change PR will not require a bump to the semantic version of the SDK.

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

ami-oss-ci commented 2 years ago

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 2.0.0.

To merge this pull request, add the label Ready to merge to this pull request and I'll merge it for you.

codecov[bot] commented 2 years ago

Codecov Report

Merging #101 (dcc20b1) into develop (81eea4e) will increase coverage by 0.47%. The diff coverage is 100.00%.

@@              Coverage Diff              @@
##             develop     #101      +/-   ##
=============================================
+ Coverage      56.56%   57.04%   +0.47%     
- Complexity       107      112       +5     
=============================================
  Files             58       58              
  Lines           1105     1115      +10     
  Branches         116      117       +1     
=============================================
+ Hits             625      636      +11     
+ Misses           442      440       -2     
- Partials          38       39       +1     
Impacted Files Coverage Δ
sdk/src/main/java/io/customer/sdk/CustomerIO.kt 44.87% <100.00%> (+3.53%) :arrow_up:
.../src/main/java/io/customer/sdk/CustomerIOClient.kt 93.57% <100.00%> (+0.44%) :arrow_up:
...ain/java/io/customer/sdk/di/CustomerIOComponent.kt 21.31% <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 81eea4e...dcc20b1. Read the comment docs.

github-actions[bot] commented 2 years ago

Build available to test Version: levi-register-device-attributes-when-set-SNAPSHOT Repository: https://s01.oss.sonatype.org/content/repositories/snapshots/

ami-ci commented 2 years ago

:tada: This PR is included in version 2.0.0-alpha.3 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

ami-ci commented 2 years ago

:tada: This PR is included in version 2.0.0-beta.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

ami-ci commented 2 years ago

:tada: This PR is included in version 2.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: