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

fix: added reusable code for wrapper SDKs #247

Merged
merged 22 commits into from
Jan 24, 2023

Conversation

Shahroz16
Copy link
Contributor

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. A bot will squash and merge the pull request for you after the label is added.

- extensions
- initializer with config params
@ami-oss-ci
Copy link

ami-oss-ci commented Jan 10, 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.0.1. 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.

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

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 Jan 10, 2023

Codecov Report

Merging #247 (45f4bbd) into develop (81a8318) will decrease coverage by 0.58%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop     #247      +/-   ##
===========================================
- Coverage    53.48%   52.90%   -0.58%     
===========================================
  Files          101      102       +1     
  Lines         1120     1533     +413     
===========================================
+ Hits           599      811     +212     
- Misses         521      722     +201     
Impacted Files Coverage Δ
Sources/Tracking/CustomerIO.swift 74.19% <ø> (ø)
Sources/Common/Service/Request/PushMetric.swift 100.00% <100.00%> (ø)
Sources/Common/Store/SdkConfig.swift 60.00% <100.00%> (-6.67%) ⬇️
Sources/Common/Type/Region.swift 100.00% <100.00%> (ø)
Sources/Common/Util/Log.swift 90.00% <100.00%> (+1.11%) ⬆️
...ngInApp/autogenerated/AutoMockable.generated.swift 67.74% <0.00%> (-4.49%) ⬇️
...PushFCM/autogenerated/AutoMockable.generated.swift 28.20% <0.00%> (-3.62%) ⬇️
...PushAPN/autogenerated/AutoMockable.generated.swift 28.94% <0.00%> (-2.88%) ⬇️
...ingPush/autogenerated/AutoMockable.generated.swift 0.00% <0.00%> (ø)
...ogenerated/AutoDependencyInjection.generated.swift 100.00% <0.00%> (ø)
... and 4 more

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

@Shahroz16 Shahroz16 requested a review from a team January 10, 2023 03:40
Sources/Common/Extensions/StringExtensions.swift Outdated Show resolved Hide resolved
Sources/Common/Store/SdkConfig.swift Outdated Show resolved Hide resolved
Sources/Tracking/CustomerIO.swift Outdated Show resolved Hide resolved
Sources/Tracking/CustomerIOInstance.swift Outdated Show resolved Hide resolved
Sources/Common/Util/CustomerIOBuilderConfigKeys.swift Outdated Show resolved Hide resolved
@levibostian
Copy link
Contributor

Could you add automated tests to this PR to cover the code that is added?

@Shahroz16
Copy link
Contributor Author

Could you add automated tests to this PR to cover the code that is added?

@levibostian I have added already the tests, can you please explain what automated tests are you referring to?

Copy link
Contributor

@levibostian levibostian left a comment

Choose a reason for hiding this comment

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

My apologies, I didn't see tests written at first. I take back my comment asking for automated tests as I see them now.


One of my biggest concerns about the changes made to SdkConfig with being able to create SdkConfig object from [String: Any] is that someone may forget to update SdkConfig.Factory.create to allow params to set that modified SdkConfig property.

Example: We add a new SdkConfig property enableInApp: Bool. We could quite easily forget to update SdkConfig.Factory.create to not include params["enableInApp"] to enable in-app with SDK wrappers.

I wasn't sure on a good solution to prevent this potential human error so I decided to play with the code to come up with a solution.

I made a commit to this branch with a suggestion. I added comments to that commit to highlight the logic behind it. To summarize, I modified the SdkConfig construction so if you ever add/remove/edit a property inside of SdkConfig object, the Swift compiler throws an error in SdkConfig.Factory.create reminding you that you need to add a params override and default value there.

Sources/Common/Store/SdkConfig.swift Outdated Show resolved Hide resolved
Sources/Tracking/CustomerIO.swift Outdated Show resolved Hide resolved
Tests/Common/Extensions/CIOExtensionsTest.swift Outdated Show resolved Hide resolved
Comment on lines 7 to 17
func test_region_givenString_expectRegion() {
let givenUSRegion = Region.US
let expectedUSRegion = Region.getRegion(from: "us")

XCTAssertEqual(givenUSRegion, expectedUSRegion)

let givenEURegion = Region.EU
let expectedEURegion = Region.getRegion(from: "EU")

XCTAssertEqual(givenEURegion, expectedEURegion)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how this function is testing both uppercase and lowercase. I think that's good to test. To help us make sure that we continue updating this edge case, I suggest we break apart into 2 test functions that are named to suggest the edge case we are trying to test.

Suggested change
func test_region_givenString_expectRegion() {
let givenUSRegion = Region.US
let expectedUSRegion = Region.getRegion(from: "us")
XCTAssertEqual(givenUSRegion, expectedUSRegion)
let givenEURegion = Region.EU
let expectedEURegion = Region.getRegion(from: "EU")
XCTAssertEqual(givenEURegion, expectedEURegion)
}
func test_from_givenUppercaseString_expectGetRegion() {
let given = Region.getRegion(from: "US")
let expected = Region.US
XCTAssertEqual(given, expected
}
func test_from_givenLowercaseString_expectGetRegion() {
let given = Region.getRegion(from: "us")
let expected = Region.US
XCTAssertEqual(given, expected
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Since Region.getRegion(from)'s implementation is using the rawValue of Region, I think that this would be a good test function to add:

Suggested change
func test_region_givenString_expectRegion() {
let givenUSRegion = Region.US
let expectedUSRegion = Region.getRegion(from: "us")
XCTAssertEqual(givenUSRegion, expectedUSRegion)
let givenEURegion = Region.EU
let expectedEURegion = Region.getRegion(from: "EU")
XCTAssertEqual(givenEURegion, expectedEURegion)
}
func test_from_expectConvertToAndFromRegion() {
let expected = Region.US
let actual = Region.getRegion(from: Region.US.rawValue)
XCTAssertEqual(expected, actual)
}

Tests/Common/Extensions/CIOExtensionsTest.swift Outdated Show resolved Hide resolved
Sources/Tracking/CustomerIO.swift Outdated Show resolved Hide resolved
@ami-oss-ci
Copy link

ami-oss-ci commented Jan 19, 2023

Warnings
⚠️

I noticed file Tests/Tracking/APITest.swift was modified. That could mean that this pull request is introducing a breaking change to the SDK.

If this pull request does introduce a breaking change, make sure the pull request title is in the format:

<type>!: description of breaking change 
// Example:
refactor!: remove onComplete callback from async functions 

Generated by 🚫 dangerJS against 45f4bbd

@levibostian
Copy link
Contributor

I am sorry Shahroz if me pushing a commit to the branch caused confusion or frustration compared to an alternative action such as typing a suggestion in a comment in the PR.

Sometimes I am most productive by digging into the code instead of giving up a concept. Commits can always be modified and reverted anyway 😉.

I see that I broke tests by my push. I didn't consider that happening and I made a commit to attempt to fix them.

Trying to make this PR a collaborative experience. We're learning on how best to do that.

@levibostian
Copy link
Contributor

Tests should be passing now.

From the tests I wrote I found a couple bugs 👍!

@Shahroz16
Copy link
Contributor Author

@levibostian thanks for the suggestions and the commit, the only confusion it causes was the implementation was a bit different than one of the suggested comments, for example, the Keys enum structure, the commit removed the enum completely.

The only pending comment seems to be regarding the initialization, so I'll update that, but it would also affect the changes you did it commit. So once you have time to review new changes, we can revisit it.

Tests/Tracking/APITest.swift Outdated Show resolved Hide resolved
Tests/Tracking/APITest.swift Outdated Show resolved Hide resolved
Tests/Tracking/APITest.swift Show resolved Hide resolved
Tests/Common/Util/LogTest.swift Outdated Show resolved Hide resolved
Sources/Common/Util/Log.swift Outdated Show resolved Hide resolved
Sources/Tracking/CustomerIO.swift Outdated Show resolved Hide resolved
Sources/Common/Store/SdkConfig.swift Outdated Show resolved Hide resolved
Tests/Tracking/APITest.swift Outdated Show resolved Hide resolved
@Shahroz16 Shahroz16 merged commit 36adf15 into develop Jan 24, 2023
@Shahroz16 Shahroz16 deleted the shahroz/initialization-with-config branch January 24, 2023 20:45
github-actions bot pushed a commit that referenced this pull request Feb 7, 2023
## [2.1.0-beta.1](2.0.4...2.1.0-beta.1) (2023-02-07)

### Features

* add in-app event listener ([#211](#211)) ([737d43b](737d43b))
* in-app feature no longer requires orgId ([#252](#252)) ([acd12da](acd12da))

### Bug Fixes

* added reusable code for wrapper SDKs ([#247](#247)) ([36adf15](36adf15))
* in-app missing event ([#259](#259)) ([43b3e97](43b3e97))
* modify in-app event listener action parameters to new name ([#255](#255)) ([b46528a](b46528a))
* region visibility modifier to be used by wrappers ([#260](#260)) ([f0edfbc](f0edfbc))
* update the gist version in podspec ([#256](#256)) ([5451488](5451488))
github-actions bot pushed a commit that referenced this pull request Feb 22, 2023
## [2.1.0](2.0.6...2.1.0) (2023-02-22)

### Features

* add in-app event listener ([#211](#211)) ([737d43b](737d43b))
* in-app feature no longer requires orgId ([#252](#252)) ([acd12da](acd12da))

### Bug Fixes

* access modifier for metric ([#263](#263)) ([e641982](e641982))
* added reusable code for wrapper SDKs ([#247](#247)) ([36adf15](36adf15))
* in-app missing event ([#259](#259)) ([43b3e97](43b3e97))
* modify in-app event listener action parameters to new name ([#255](#255)) ([b46528a](b46528a))
* region visibility modifier to be used by wrappers ([#260](#260)) ([f0edfbc](f0edfbc))
* update the gist version in podspec ([#256](#256)) ([5451488](5451488))
@github-actions
Copy link

🎉 This PR is included in version 2.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to nagyist/customerio-ios that referenced this pull request Feb 23, 2023
## [2.0.0](1.2.4...2.0.0) (2023-02-23)

### ⚠ BREAKING CHANGES

* make delivered push metric more reliable
* remove FCM dependency from cocoapods (customerio#210)
* singleton API only way to use SDK now (customerio#209)

### Features

* add in-app event listener ([customerio#211](https://github.com/nagyist/customerio-ios/issues/211)) ([737d43b](737d43b))
* in-app feature no longer requires orgId ([customerio#252](https://github.com/nagyist/customerio-ios/issues/252)) ([acd12da](acd12da))

### Bug Fixes

* access modifier for metric ([customerio#263](https://github.com/nagyist/customerio-ios/issues/263)) ([e641982](e641982))
* add sdkwrapperconfig to rich push SDK config ([customerio#226](https://github.com/nagyist/customerio-ios/issues/226)) ([e43b4cf](e43b4cf))
* added reusable code for wrapper SDKs ([customerio#247](https://github.com/nagyist/customerio-ios/issues/247)) ([36adf15](36adf15))
* async running BQ operations in loop ([customerio#250](https://github.com/nagyist/customerio-ios/issues/250)) ([f0a3d9c](f0a3d9c))
* device attributes shows sdk version instead of wrapper version ([e2462b9](e2462b9))
* do not modify custom attributes casing ([customerio#234](https://github.com/nagyist/customerio-ios/issues/234)) ([8160fdf](8160fdf))
* download rich push images from CDN ([customerio#237](https://github.com/nagyist/customerio-ios/issues/237)) ([b30cf02](b30cf02))
* fix compile time errors notification service extensions ([customerio#214](https://github.com/nagyist/customerio-ios/issues/214)) ([bd5911b](bd5911b))
* fix compile time errors notification service extensions ([customerio#216](https://github.com/nagyist/customerio-ios/issues/216)) ([6e8484a](6e8484a))
* in-app missing event ([customerio#259](https://github.com/nagyist/customerio-ios/issues/259)) ([43b3e97](43b3e97))
* make delivered push metric more reliable ([0478e52](0478e52))
* modify in-app event listener action parameters to new name ([customerio#255](https://github.com/nagyist/customerio-ios/issues/255)) ([b46528a](b46528a))
* prevent stackoverflow while executing background queue with lots of tasks in it ([customerio#245](https://github.com/nagyist/customerio-ios/issues/245)) ([ef0c428](ef0c428))
* push images and processing simple push ([customerio#230](https://github.com/nagyist/customerio-ios/issues/230)) ([f109f04](f109f04))
* region visibility modifier to be used by wrappers ([customerio#260](https://github.com/nagyist/customerio-ios/issues/260)) ([f0edfbc](f0edfbc))
* revert 2.0.2 as it was found unstable ([customerio#249](https://github.com/nagyist/customerio-ios/issues/249)) ([51b5831](51b5831))
* sdk not able to compile in ios app ([customerio#225](https://github.com/nagyist/customerio-ios/issues/225)) ([e4d1b3f](e4d1b3f))
* universal links deep links open host app ([customerio#268](https://github.com/nagyist/customerio-ios/issues/268)) ([29c95b5](29c95b5))
* universal links when touch a push notification open host app ([customerio#265](https://github.com/nagyist/customerio-ios/issues/265)) ([7dcaf73](7dcaf73))
* update the gist version in podspec ([customerio#256](https://github.com/nagyist/customerio-ios/issues/256)) ([5451488](5451488))

### Code Refactoring

* remove FCM dependency from cocoapods ([customerio#210](https://github.com/nagyist/customerio-ios/issues/210)) ([3547076](3547076))
* singleton API only way to use SDK now ([customerio#209](https://github.com/nagyist/customerio-ios/issues/209)) ([72b7477](72b7477))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants