Skip to content

Commit 1f60b08

Browse files
committed
[nit] Clean up logging, remove hardcoded prints
1 parent 0d9c62d commit 1f60b08

File tree

10 files changed

+68
-93
lines changed

10 files changed

+68
-93
lines changed

iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ - (IBAction)inAppMessagingSegmentedControlValueChanged:(UISegmentedControl *)sen
197197
- (IBAction)loginExternalUserId:(UIButton *)sender {
198198
NSString* externalUserId = self.externalUserIdTextField.text;
199199
NSString* token = self.tokenTextField.text;
200-
NSLog(@"Dev App: Logging in to external user ID %@ and token %@", externalUserId, token);
200+
NSLog(@"Dev App: Logging in to external user ID %@ and token %@", externalUserId, token);
201201
[OneSignal login:externalUserId withToken:token];
202202
}
203203

204204
- (IBAction)updateJwt:(id)sender {
205205
NSString* externalUserId = self.externalUserIdTextField.text;
206206
NSString* token = self.tokenTextField.text;
207-
NSLog(@"Dev App: updating JWT for external user ID %@ and token %@", externalUserId, token);
207+
NSLog(@"Dev App: updating JWT for external user ID %@ and token %@", externalUserId, token);
208208
[OneSignal updateUserJwt:externalUserId withToken:token];
209209
}
210210

iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,6 @@ - (void)onPushSubscriptionDidChangeWithState:(OSPushSubscriptionChangedState * _
11541154

11551155
#pragma mark OSUserStateObserver Methods
11561156
- (void)onUserStateDidChangeWithState:(OSUserChangedState * _Nonnull)state {
1157-
NSLog(@"❌ OSMessagingController onUserStateDidChangeWithState: %@", [state jsonRepresentation]);
11581157
if (state.current.onesignalId && shouldRetryGetInAppMessagesOnUserChange) {
11591158
shouldRetryGetInAppMessagesOnUserChange = false;
11601159
[self getInAppMessagesFromServer];
@@ -1167,7 +1166,6 @@ - (void)onRequiresUserAuthChangedFrom:(enum OSRequiresUserAuth)from to:(enum OSR
11671166
}
11681167

11691168
- (void)onJwtUpdatedWithExternalId:(NSString *)externalId token:(NSString *)token {
1170-
NSLog(@"❌ OSMessagingController onJwtUpdatedWithExternalId: %@ token: %@", externalId, token);
11711169
if (![token isEqual: OS_JWT_TOKEN_INVALID] && shouldRetryGetInAppMessagesOnJwtUpdated) {
11721170
shouldRetryGetInAppMessagesOnJwtUpdated = false;
11731171
[self getInAppMessagesFromServer];

iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/Jwt/OSUserJwtConfig.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ public class OSUserJwtConfig {
6464
return
6565
}
6666

67-
print("❌ OSUserJwtConfig.requiresUserAuth: changing from \(oldValue) to \(requiresUserAuth), firing \(changeNotifier)")
68-
67+
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "OSUserJwtConfig.requiresUserAuth: changing from \(oldValue) to \(requiresUserAuth), firing listeners")
6968
// Persist new value
7069
OneSignalUserDefaults.initShared().saveInteger(forKey: OSUD_USE_IDENTITY_VERIFICATION, withValue: requiresUserAuth.rawValue)
7170

@@ -93,9 +92,6 @@ public class OSUserJwtConfig {
9392

9493
public init() {
9594
let rawValue = OneSignalUserDefaults.initShared().getSavedInteger(forKey: OSUD_USE_IDENTITY_VERIFICATION, defaultValue: OSRequiresUserAuth.unknown.rawValue)
96-
97-
print("❌ OSUserJwtConfig init(): \(String(describing: OSRequiresUserAuth(rawValue: rawValue))))")
98-
9995
requiresUserAuth = OSRequiresUserAuth(rawValue: rawValue) ?? OSRequiresUserAuth.unknown
10096
}
10197

@@ -104,7 +100,7 @@ public class OSUserJwtConfig {
104100
}
105101

106102
public func onJwtTokenChanged(externalId: String, token: String?) {
107-
print("OSUserJwtConfig.onJwtTokenChanged \(externalId): \(token)")
103+
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "OSUserJwtConfig.onJwtTokenChanged for \(externalId) with token \(token ?? "nil"), firing listeners")
108104
changeNotifier.fire { listener in
109105
listener.onJwtUpdated(externalId: externalId, token: token)
110106
}

iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationRepo.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public class OSOperationRepo {
5454
public init(jwtConfig: OSUserJwtConfig) {
5555
self.jwtConfig = jwtConfig
5656
self.jwtConfig.subscribe(self, key: OS_OPERATION_REPO)
57-
print("❌ OSOperationRepo init(\(String(describing: jwtConfig.isRequired))) called")
58-
5957
// Read the Deltas from cache, if any...
6058
guard let deltaQueue = OneSignalUserDefaults.initShared().getSavedCodeableData(forKey: OS_OPERATION_REPO_DELTA_QUEUE_KEY, defaultValue: []) as? [OSDelta] else {
6159
OneSignalLog.onesignalLog(.LL_ERROR, message: "OSOperationRepo is unable to uncache the OSDelta queue.")
@@ -73,7 +71,7 @@ public class OSOperationRepo {
7371
}
7472

7573
guard jwtConfig.isRequired != nil else {
76-
print("OSOperationRepo.start() returning early due to unknown Identity Verification status.")
74+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSOperationRepo.start() returning early due to unknown Identity Verification status")
7775
return
7876
}
7977

@@ -185,7 +183,6 @@ public class OSOperationRepo {
185183

186184
extension OSOperationRepo: OSUserJwtConfigListener {
187185
public func onRequiresUserAuthChanged(from: OSRequiresUserAuth, to: OSRequiresUserAuth) {
188-
print("❌ OSOperationRepo onRequiresUserAuthChanged from \(String(describing: from)) to \(String(describing: to))")
189186
// If auth changed from false or unknown to true, process deltas
190187
if to == .on {
191188
removeInvalidDeltas()
@@ -194,7 +191,7 @@ extension OSOperationRepo: OSUserJwtConfigListener {
194191
}
195192

196193
public func onJwtUpdated(externalId: String, token: String?) {
197-
print("❌ OSOperationRepo onJwtUpdated for \(externalId) to \(String(describing: token))")
194+
// Not used for now
198195
}
199196

200197
/**
@@ -203,14 +200,19 @@ extension OSOperationRepo: OSUserJwtConfigListener {
203200
Executors will handle this.
204201
*/
205202
func removeInvalidDeltas() {
206-
print("❌ OSOperationRepo removeInvalidDeltas TODO!")
203+
// Not used for now
207204
}
208205
}
209206

210207
extension OSOperationRepo: OSLoggable {
211208
public func logSelf() {
212-
print("💛 Operation Repo: deltaQueue: \(self.deltaQueue )")
213-
print("💛 Operation Repo: executors that are subscribed:")
209+
OneSignalLog.onesignalLog(.LL_VERBOSE, message:
210+
"""
211+
Operation Repo: deltaQueue: \(self.deltaQueue)
212+
213+
Operation Repo: executors that are subscribed:
214+
"""
215+
)
214216
for executor in self.executors {
215217
executor.logSelf()
216218
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
4545
self.newRecordsState = newRecordsState
4646
self.jwtConfig = jwtConfig
4747
self.jwtConfig.subscribe(self, key: OS_IDENTITY_EXECUTOR)
48-
print("❌ OSIdentityOperationExecutor init(\(jwtConfig.isRequired))")
4948
// Read unfinished deltas and requests from cache, if any...
5049
uncacheDeltas()
5150
uncacheRequests()
@@ -206,7 +205,7 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
206205

207206
// If JWT is on but the external ID does not exist, drop this Delta
208207
if self.jwtConfig.isRequired == true, model.externalId == nil {
209-
print("\(delta) is Invalid with JWT, being dropped")
208+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSIdentityOperationExecutor.processDeltaQueue dropped \(delta)")
210209
}
211210

212211
switch delta.name {
@@ -401,15 +400,13 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
401400

402401
extension OSIdentityOperationExecutor: OSUserJwtConfigListener {
403402
func onRequiresUserAuthChanged(from: OSRequiresUserAuth, to: OSRequiresUserAuth) {
404-
print("❌ OSIdentityOperationExecutor onUserAuthChanged from \(String(describing: from)) to \(String(describing: to))")
405403
// If auth changed from false or unknown to true, process requests
406404
if to == .on {
407405
removeInvalidDeltasAndRequests()
408406
}
409407
}
410408

411409
func onJwtUpdated(externalId: String, token: String?) {
412-
print("❌ OSIdentityOperationExecutor onJwtUpdated for \(externalId) to \(String(describing: token))")
413410
reQueuePendingRequestsForExternalId(externalId: externalId)
414411
}
415412

@@ -435,26 +432,25 @@ extension OSIdentityOperationExecutor: OSUserJwtConfigListener {
435432

436433
private func removeInvalidDeltasAndRequests() {
437434
self.dispatchQueue.async {
438-
print("❌ OSIdentityOperationExecutor.removeInvalidDeltasAndRequests called")
439435
for (index, delta) in self.deltaQueue.enumerated().reversed() {
440436
if (delta.model as? OSIdentityModel)?.externalId == nil {
441-
print(" \(delta) is Invalid, being removed")
437+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSIdentityOperationExecutor.removeInvalidDeltasAndRequests dropped \(delta)")
442438
self.deltaQueue.remove(at: index)
443439
}
444440
}
445441
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_DELTA_QUEUE_KEY, withValue: self.deltaQueue)
446442

447443
for (index, request) in self.addRequestQueue.enumerated().reversed() {
448444
if request.identityModel.externalId == nil {
449-
print(" \(request) is Invalid, being removed")
445+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSIdentityOperationExecutor.removeInvalidDeltasAndRequests dropped \(request)")
450446
self.addRequestQueue.remove(at: index)
451447
}
452448
}
453449
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: self.addRequestQueue)
454450

455451
for (index, request) in self.removeRequestQueue.enumerated().reversed() {
456452
if request.identityModel.externalId == nil {
457-
print(" \(request) is Invalid, being removed")
453+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSIdentityOperationExecutor.removeInvalidDeltasAndRequests dropped \(request)")
458454
self.removeRequestQueue.remove(at: index)
459455
}
460456
}
@@ -465,13 +461,14 @@ extension OSIdentityOperationExecutor: OSUserJwtConfigListener {
465461

466462
extension OSIdentityOperationExecutor: OSLoggable {
467463
func logSelf() {
468-
print(
464+
OneSignalLog.onesignalLog(.LL_VERBOSE, message:
469465
"""
470-
💛 OSIdentityOperationExecutor has the following queues:
466+
OSIdentityOperationExecutor has the following queues:
471467
addRequestQueue: \(self.addRequestQueue)
472468
removeRequestQueue: \(self.removeRequestQueue)
473469
deltaQueue: \(self.deltaQueue)
474470
pendingAuthRequests: \(self.pendingAuthRequests)
471+
475472
"""
476473
)
477474
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,13 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
7575
self.newRecordsState = newRecordsState
7676
self.jwtConfig = jwtConfig
7777
self.jwtConfig.subscribe(self, key: OS_PROPERTIES_EXECUTOR)
78-
print("❌ OSPropertyOperationExecutor init(\(String(describing: jwtConfig.isRequired)))")
79-
8078
// Read unfinished deltas and requests from cache, if any...
8179
// Note that we should only have deltas for the current user as old ones are flushed..
8280
uncacheDeltas()
8381
uncacheUpdateRequests()
8482
}
8583

8684
private func uncacheDeltas() {
87-
print("❌ OSPropertyOperationExecutor uncacheDeltas called")
88-
8985
if var deltaQueue = OneSignalUserDefaults.initShared().getSavedCodeableData(forKey: OS_PROPERTIES_EXECUTOR_DELTA_QUEUE_KEY, defaultValue: []) as? [OSDelta] {
9086
for (index, delta) in deltaQueue.enumerated().reversed() {
9187
guard let model = OneSignalUserManagerImpl.sharedInstance.getIdentityModel(delta.identityModelId) else {
@@ -97,7 +93,7 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
9793

9894
// If JWT is on but the external ID does not exist, drop this Delta
9995
if jwtConfig.isRequired == true, model.externalId == nil {
100-
print("❌ removing \(delta)")
96+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSPropertyOperationExecutor.uncacheDeltas dropped \(delta)")
10197
deltaQueue.remove(at: index)
10298
}
10399
}
@@ -106,7 +102,6 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
106102
} else {
107103
OneSignalLog.onesignalLog(.LL_ERROR, message: "OSPropertyOperationExecutor error encountered reading from cache for \(OS_PROPERTIES_EXECUTOR_DELTA_QUEUE_KEY)")
108104
}
109-
print("❌ OSPropertyOperationExecutor uncacheDeltas done, \(self.deltaQueue)")
110105
}
111106

112107
private func uncacheUpdateRequests() {
@@ -117,15 +112,13 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
117112
}
118113

119114
if let pendingRequests = OneSignalUserDefaults.initShared().getSavedCodeableData(forKey: OS_PROPERTIES_EXECUTOR_PENDING_QUEUE_KEY, defaultValue: [:]) as? [String: [OSRequestUpdateProperties]] {
120-
print("❌ prop executor uncached pending \(pendingRequests)")
121-
122115
for requests in pendingRequests.values {
123116
for request in requests {
124117
updateRequestQueue.append(request)
125118
}
126119
}
127120
}
128-
print("❌ prop executor uncached requests \(updateRequestQueue)")
121+
129122
// Hook each uncached Request to the model in the store
130123
for (index, request) in updateRequestQueue.enumerated().reversed() {
131124
if jwtConfig.isRequired == true,
@@ -172,7 +165,7 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
172165
*/
173166
func processDeltaQueue(inBackground: Bool) {
174167
guard jwtConfig.isRequired != nil else {
175-
print("OSPropertyOperationExecutor processDeltaQueue returning early due to requiresAuth: \(String(describing: jwtConfig.isRequired))")
168+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSPropertyOperationExecutor processDeltaQueue returning early due to requiresAuth: \(String(describing: jwtConfig.isRequired))")
176169
return
177170
}
178171

@@ -198,7 +191,7 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
198191

199192
// If JWT is on but the external ID does not exist, drop this Delta
200193
if self.jwtConfig.isRequired == true, identityModel.externalId == nil {
201-
print("\(delta) is Invalid with JWT, being dropped")
194+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSPropertyOperationExecutor.processDeltaQueue dropped \(delta)")
202195
}
203196

204197
let combinedSoFar: OSCombinedProperties? = combinedProperties[identityModel.modelId]
@@ -317,7 +310,6 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
317310
return
318311
}
319312

320-
print("ECM executing properties request: %@", request.identityModel.externalId)
321313
request.sentToClient = true
322314

323315
let backgroundTaskIdentifier = PROPERTIES_EXECUTOR_BACKGROUND_TASK + UUID().uuidString
@@ -375,15 +367,13 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
375367

376368
extension OSPropertyOperationExecutor: OSUserJwtConfigListener {
377369
func onRequiresUserAuthChanged(from: OSRequiresUserAuth, to: OSRequiresUserAuth) {
378-
print("❌ OSPropertyOperationExecutor onUserAuthChanged from \(String(describing: from)) to \(String(describing: to))")
379370
// If auth changed from false or unknown to true, process requests
380371
if to == .on {
381372
removeInvalidDeltasAndRequests()
382373
}
383374
}
384375

385376
func onJwtUpdated(externalId: String, token: String?) {
386-
print("❌ OSPropertyOperationExecutor onJwtUpdated for \(externalId) to \(String(describing: token))")
387377
reQueuePendingRequestsForExternalId(externalId: externalId)
388378
}
389379

@@ -404,21 +394,19 @@ extension OSPropertyOperationExecutor: OSUserJwtConfigListener {
404394

405395
private func removeInvalidDeltasAndRequests() {
406396
self.dispatchQueue.async {
407-
print("❌ OSPropertyOperationExecutor.removeInvalidDeltasAndRequests called")
408-
409397
for (index, delta) in self.deltaQueue.enumerated().reversed() {
410398
if let identityModel = OneSignalUserManagerImpl.sharedInstance.getIdentityModel(delta.identityModelId),
411399
identityModel.externalId == nil
412400
{
413-
print(" \(delta) is Invalid, being removed")
401+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSPropertyOperationExecutor.removeInvalidDeltasAndRequests dropped \(delta)")
414402
self.deltaQueue.remove(at: index)
415403
}
416404
}
417405
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_PROPERTIES_EXECUTOR_DELTA_QUEUE_KEY, withValue: self.deltaQueue)
418406

419407
for (index, request) in self.updateRequestQueue.enumerated().reversed() {
420408
if request.identityModel.externalId == nil {
421-
print(" \(request) is Invalid, being removed")
409+
OneSignalLog.onesignalLog(.LL_DEBUG, message: "Invalid with JWT: OSPropertyOperationExecutor.removeInvalidDeltasAndRequests dropped \(request)")
422410
self.updateRequestQueue.remove(at: index)
423411
}
424412
}
@@ -429,12 +417,13 @@ extension OSPropertyOperationExecutor: OSUserJwtConfigListener {
429417

430418
extension OSPropertyOperationExecutor: OSLoggable {
431419
func logSelf() {
432-
print(
420+
OneSignalLog.onesignalLog(.LL_VERBOSE, message:
433421
"""
434-
💛 OSPropertyOperationExecutor has the following queues:
422+
OSPropertyOperationExecutor has the following queues:
435423
updateRequestQueue: \(self.updateRequestQueue)
436424
deltaQueue: \(self.deltaQueue)
437425
pendingAuthRequests: \(self.pendingAuthRequests)
426+
438427
"""
439428
)
440429
}

0 commit comments

Comments
 (0)