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

refactor: push modules initialization #418

Merged
merged 68 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
2c4c02f
move interface to common
Shahroz16 Nov 14, 2023
4acb489
fix tests
Shahroz16 Nov 14, 2023
c5dd664
autogen files update
Shahroz16 Nov 14, 2023
2a6e2ed
added a separate module
Shahroz16 Nov 17, 2023
9052f6c
added global digraph
Shahroz16 Nov 20, 2023
aa51e7c
added missing autogen deps
Shahroz16 Nov 20, 2023
cd0c93f
more sourcery
Shahroz16 Nov 20, 2023
eab1a51
auto gen
Shahroz16 Nov 20, 2023
dde26d7
new annotations
Shahroz16 Nov 20, 2023
eeec59b
updated shared graph classes
Shahroz16 Nov 20, 2023
f4f59e5
updated files
Shahroz16 Nov 20, 2023
49b127e
mocking test fixed
Shahroz16 Nov 20, 2023
cc1345b
auto
Shahroz16 Nov 21, 2023
0ff2b8b
migrated customer io to common
Shahroz16 Nov 21, 2023
bd93ebf
Merge branch 'shahroz/cdp-native-refactor-customerio-class' of github…
Shahroz16 Nov 21, 2023
0528873
chore: migrated customerio to common (#411)
Shahroz16 Nov 22, 2023
db961f3
Merge branch 'shahroz/cdp-native-refactor-base' into shahroz/native-d…
Shahroz16 Nov 22, 2023
602b8d1
Merge branch 'shahroz/native-digraph' of github.com:customerio/custom…
Shahroz16 Nov 22, 2023
3f6561d
auto gen
Shahroz16 Nov 22, 2023
e1f78af
added the package
Shahroz16 Nov 26, 2023
8061535
added the wrapper methods
Shahroz16 Nov 26, 2023
1bd7e9d
Merge branch 'main-replica-for-cdp' of github.com:customerio/customer…
Shahroz16 Nov 27, 2023
5829181
merge issue
Shahroz16 Nov 27, 2023
89d9251
merge issue
Shahroz16 Nov 27, 2023
f3c56a4
converted to class
Shahroz16 Nov 27, 2023
9076356
added usage for module
Shahroz16 Nov 27, 2023
7019381
temp fixes to make SDK build
Shahroz16 Nov 27, 2023
2dcd944
updated module name
Shahroz16 Nov 27, 2023
a2a89c4
Merge branch 'shahroz/datapipeline-module' into shahroz/data-pipeline…
Shahroz16 Nov 27, 2023
47ce982
build issues fixed
Shahroz16 Nov 27, 2023
3ee1e21
name update
Shahroz16 Nov 27, 2023
ba5888b
auto gen files
mrehan27 Nov 27, 2023
647f31d
fixed imports
mrehan27 Nov 27, 2023
5d2fdf3
ModuleTopLevelObject updates
mrehan27 Nov 28, 2023
c089156
inapp updates
mrehan27 Nov 28, 2023
a71ddb0
push updates
mrehan27 Nov 28, 2023
915be66
app delegate updates
mrehan27 Nov 28, 2023
8a8273d
auto gen files
mrehan27 Nov 28, 2023
5ed85e2
format updates
mrehan27 Nov 28, 2023
60612b9
push config updates
mrehan27 Nov 28, 2023
6fcea77
push updates
mrehan27 Nov 28, 2023
05ecb10
more fixes
mrehan27 Nov 28, 2023
dee1d26
format fixes
mrehan27 Nov 28, 2023
e5d4a16
replaced if with guard
mrehan27 Nov 28, 2023
280b4a3
auto gen updates
mrehan27 Nov 28, 2023
5241a3f
json adapter fix
mrehan27 Nov 28, 2023
6bd9760
added getter
mrehan27 Nov 28, 2023
04e1ec3
fixed typo
mrehan27 Nov 28, 2023
5623766
renamed for consistency
mrehan27 Nov 28, 2023
28ff331
pr suggestion
Shahroz16 Nov 28, 2023
059e738
Merge branch 'shahroz/datapipeline-module' of github.com:customerio/c…
Shahroz16 Nov 28, 2023
1962e4d
setEventListener update
mrehan27 Nov 29, 2023
638252c
Merge branch 'main-replica-for-cdp' of github.com:customerio/customer…
Shahroz16 Nov 29, 2023
ae7be5e
updated methods
Shahroz16 Nov 29, 2023
b434bff
Merge branch 'shahroz/data-pipeline-usage' of github.com:customerio/c…
Shahroz16 Nov 29, 2023
2b25914
added comments
Shahroz16 Nov 29, 2023
d0b3fb5
Apply suggestions from code review
mrehan27 Nov 29, 2023
e562789
Merge branch 'shahroz/data-pipeline-usage' of github.com:customerio/c…
Shahroz16 Nov 29, 2023
1609a88
apn uikit fix
mrehan27 Nov 30, 2023
7dbe12a
remove configure
mrehan27 Nov 30, 2023
ef888e3
updated init methods
mrehan27 Nov 30, 2023
fde02bd
removed auto-init for push
mrehan27 Dec 1, 2023
3cbb468
added DIGraphShared to UnitTest
mrehan27 Dec 1, 2023
7a76b44
fixed tests
mrehan27 Dec 1, 2023
4dfc6de
Merge branch 'main-replica-for-cdp' into rehan/cdp-push-module
mrehan27 Dec 1, 2023
4cee256
post merge conflicts
mrehan27 Dec 1, 2023
24454a4
auto gen fix
mrehan27 Dec 1, 2023
96aa58f
post merge conflicts
mrehan27 Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Apps/APN-UIKit/APN UIKit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

// Add event listeners for in-app. This is not to initialise in-app but event listeners for in-app.
MessagingInApp.initialize(eventListener: self)
MessagingInApp
.initialize(siteId: siteId, region: .US)
.setEventListener(self)
MessagingPushAPN.initialize { config in
config.autoFetchDeviceToken = true
}
Expand Down
4 changes: 3 additions & 1 deletion Apps/CocoaPods-FCM/src/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class AppDelegate: NSObject, UIApplicationDelegate {
// This line of code is internal to Customer.io for testing purposes. Do not add this code to your app.
appSetSettings?.configureCioSdk(config: &config)
}
MessagingInApp.initialize(eventListener: self)
MessagingInApp
.initialize(siteId: siteId, region: .US)
.setEventListener(self)

// Now that the Firebase and Customer.io SDK's are initialized, follow the rest of the required steps for the FCM push setup.
UNUserNotificationCenter.current().delegate = self
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let package = Package(
path: "Tests/Common"),
// Tracking
.target(name: "CioTracking",
dependencies: ["CioInternalCommon"],
dependencies: ["CioInternalCommon", "CioDataPipelines"],
path: "Sources/Tracking"),
.testTarget(name: "TrackingTests",
dependencies: ["CioTracking", "SharedTests"],
Expand Down
40 changes: 28 additions & 12 deletions Sources/Common/Module/ModuleTopLevelObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,49 @@ import Foundation
// Top-level class meaning it contains public facing SDK functions called by customers.
// There isn't a constructor populated via dependency injection. It's at the top node
// of dependencies.
// TODO: [CDP] Remove class if no longer needed
open class ModuleTopLevelObject<ImplementationClass> {
private(set) var alreadyCreatedImplementation: ImplementationClass?
public var implementation: ImplementationClass? {
alreadyCreatedImplementation ?? createAndSetImplementationInstance()
let instance = alreadyCreatedImplementation ?? createAndSetImplementationInstance()
if instance == nil {
logger.info("Module \(moduleName) is not yet initialized. All requests made to module \(moduleName) will be ignored until it is initialized. See docs for help.")
}
return instance
}

// for writing tests
public init(implementation: ImplementationClass?) {
self.alreadyCreatedImplementation = implementation
// To identify the module in top-level objects and within log messages
public let moduleName: String
open var logger: Logger {
DIGraphShared.shared.logger
}

// singleton constructor
public init() {}
// optionally accepts implementation instance for facilitating testing, allowing injection
// of a mock or stub implementation.
public init(moduleName: String, implementation: ImplementationClass? = nil) {
self.moduleName = moduleName
self.alreadyCreatedImplementation = implementation
}

private func createAndSetImplementationInstance() -> ImplementationClass? {
let newInstance = getImplementationInstance()
let newInstance = createImplementationInstance()
alreadyCreatedImplementation = newInstance
return newInstance
}

// We want each top level module to have an initialize function so that features get setup as early as possible
open func inititlizeModule() {
fatalError("forgot to override in subclass")
open func setImplementationInstance(implementation: ImplementationClass?) {
alreadyCreatedImplementation = implementation
}

open func getImplementationInstance() -> ImplementationClass? {
alreadyCreatedImplementation
}

open func getImplementationInstance() -> ImplementationClass {
fatalError("forgot to override in subclass")
// Feature modules (e.g. push) which support auto-initialization without client configuration can
// provide its instance here to ensure early initialization upon the first call
// Feature modules (e.g. in-app) that require user input for initialization may not override this
// method or can return `nil`.
open func createImplementationInstance() -> ImplementationClass? {
nil
}
}
1 change: 1 addition & 0 deletions Sources/Common/Util/JsonAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Foundation
```
*/
// sourcery: InjectRegister = "JsonAdapter"
// sourcery: InjectRegisterShared = "JsonAdapter"
public class JsonAdapter {
var decoder: JSONDecoder {
let decoder = JSONDecoder()
Expand Down
Loading