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

chore: migrate classes to common #409

Merged
merged 8 commits into from
Nov 27, 2023

Conversation

Shahroz16
Copy link
Contributor

@Shahroz16 Shahroz16 commented Nov 20, 2023

First draft PR for [CDP] iOS Refactor: Base module#11645

What it does is move CustomerIOInstance to common.

PR to follow next is what moves the CustomerIO object to common.

Copy link

github-actions bot commented Nov 20, 2023

Sample app builds 📱

Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request.


  • CocoaPods-FCM: Build failed. See CI job logs to determine the issue and try re-building.
  • APN-UIKit: Build failed. See CI job logs to determine the issue and try re-building.

@@ -1,3 +1,4 @@
@testable import CioInternalCommon
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@testable import CioInternalCommon

I do understand why this import was added. Because CustomerIOInstance was moved into a different module, some parts of the codebase as well as customer's apps will be expected to find CustomerIOInstance and CustomerIOInstanceMock in Track module but will not be able to anymore.

It's not ideal for a customer to need to have to import internal modules into their code base so to get around that, we have these public aliases. I anticipate you will need to add CustomerIOInstance and CustomerIOInstanceMock to that file, too.

Copy link
Contributor Author

@Shahroz16 Shahroz16 Nov 21, 2023

Choose a reason for hiding this comment

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

some parts of the codebase as well as customer's apps will be expected to find CustomerIOInstance and CustomerIOInstanceMock in the Track module but will not be able to anymore.

I tried to cover it in this comment

Why would a customer be using CustomerIOInstance?

  • We don't use it in our sample apps
  • It's not part of our documentation
  • None of the sample snippets ever shared with us include CustomerIOInstance
  • It's not a general practice to use interface interface CustomerIOInstance instead of CustomerIO while adding an implementation.

The only usage that we currently have is testing as well, so that makes me think, that maybe we are worrying about something customers aren't even possibly using. What are your thoughts on it?

When we move the CustomerIO class to common, that's when we can have possible issues but I found this workaround that can probably be a good workaround for it

@_exported import CioInternalCommon

Comment on lines +8 to +64
func identify(
identifier: String,
body: [String: Any]
)

// sourcery:Name=identifyEncodable
// sourcery:DuplicateMethod=identify
func identify<RequestBody: Encodable>(
identifier: String,
// sourcery:Type=AnyEncodable
// sourcery:TypeCast="AnyEncodable(body)"
body: RequestBody
)

var registeredDeviceToken: String? { get }

func clearIdentify()

func track(
name: String,
data: [String: Any]
)

// sourcery:Name=trackEncodable
// sourcery:DuplicateMethod=track
func track<RequestBody: Encodable>(
name: String,
// sourcery:Type=AnyEncodable
// sourcery:TypeCast="AnyEncodable(data)"
data: RequestBody?
)

func screen(
name: String,
data: [String: Any]
)

// sourcery:Name=screenEncodable
// sourcery:DuplicateMethod=screen
func screen<RequestBody: Encodable>(
name: String,
// sourcery:Type=AnyEncodable
// sourcery:TypeCast="AnyEncodable(data)"
data: RequestBody?
)

var profileAttributes: [String: Any] { get set }
var deviceAttributes: [String: Any] { get set }

func registerDeviceToken(_ deviceToken: String)

func deleteDeviceToken()

func trackMetric(
deliveryID: String,
event: Metric,
deviceToken: String
Copy link
Contributor

@levibostian levibostian Nov 20, 2023

Choose a reason for hiding this comment

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

🤔 I had an idea?

The reason for moving this interface into the Common module is for the CDP module to be able to add new public functions this interface (and I think CustomerIO class?).

These functions highlighted here I think are functions that are directly tied to the Track module, right?

Would it be worth having the CustomerIOInstance in the Common module be almost empty and then have the Track module add all of these functions via Track module?

This might be scope creep so I am not sure if it's worth doing now. This idea came to me because I do prefer where a design decision in the code is used throughout all of the code rather then little parts of the code here and there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a very good point, this interface does have indeed things that are tracking module only and they would indeed need to be moved into implementation by tracking modules.

I'll think a bit more about this to make sure, we are not adding redundancy while also adding the data pipeline specific extension. But i do see alot of value in keeping it bare minimum and letting track then add more specific implementation.

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main-replica-for-cdp@f68661c). Click here to learn what that means.

❗ Current head 624312f differs from pull request most recent head 90d8302. Consider uploading reports for the commit 90d8302 to get more accurate results

Additional details and impacted files
@@                   Coverage Diff                   @@
##             main-replica-for-cdp     #409   +/-   ##
=======================================================
  Coverage                        ?   58.17%           
=======================================================
  Files                           ?      123           
  Lines                           ?     4727           
  Branches                        ?        0           
=======================================================
  Hits                            ?     2750           
  Misses                          ?     1977           
  Partials                        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Nov 26, 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 90d8302

@Shahroz16 Shahroz16 changed the base branch from main to main-replica-for-cdp November 27, 2023 11:10
@Shahroz16 Shahroz16 marked this pull request as ready for review November 27, 2023 11:53
@Shahroz16 Shahroz16 merged commit 4ff4893 into main-replica-for-cdp Nov 27, 2023
4 of 7 checks passed
@Shahroz16 Shahroz16 deleted the shahroz/cdp-native-refactor-base branch November 27, 2023 11:55
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