From ec12d97f2e17273470917206299cfff115f29177 Mon Sep 17 00:00:00 2001 From: "soumen.rautray" <96281209+SoumenRautray@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:43:25 +0530 Subject: [PATCH 1/9] chore : Implement dark background through CustomJson (RMCCX-7328) --- CHANGELOG.md | 1 + RInAppMessaging.xcodeproj/project.pbxproj | 4 + .../Models/Responses/CampaignDataModels.swift | 43 ++-- Sources/RInAppMessaging/Views/FullView.swift | 11 +- Tests/Tests/CampaignDataModelSpec.swift | 211 ++++++++++++++++++ Tests/Tests/Helpers/TestHelpers.swift | 18 +- Tests/Tests/ViewSpec.swift | 51 +++++ 7 files changed, 322 insertions(+), 17 deletions(-) create mode 100644 Tests/Tests/CampaignDataModelSpec.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f28f810..90bc10cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Unreleased - Features: - Implement clickable image through CustomJson [RMCCX-7233] + - Implement dark background through CustomJson [RMCCX-7328] - Fixes: - Fix clickable image behaviour for invalid url [RMCCX-7351] diff --git a/RInAppMessaging.xcodeproj/project.pbxproj b/RInAppMessaging.xcodeproj/project.pbxproj index cd6d3ed1..0973d4a4 100644 --- a/RInAppMessaging.xcodeproj/project.pbxproj +++ b/RInAppMessaging.xcodeproj/project.pbxproj @@ -99,6 +99,7 @@ D92D1F262224A269008EA748 /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92D1F242224A265008EA748 /* TestHelpers.swift */; }; E686BF522A2692CD00D4E3E9 /* TooltipViewSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = E686BF512A2692CD00D4E3E9 /* TooltipViewSpec.swift */; }; E686BF562A2692DD00D4E3E9 /* tooltip-data.json in Resources */ = {isa = PBXBuildFile; fileRef = E686BF532A2692DD00D4E3E9 /* tooltip-data.json */; }; + E6D762532CA2A87F00FE62D2 /* CampaignDataModelSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D762522CA2A87A00FE62D2 /* CampaignDataModelSpec.swift */; }; FC1872382A49B7C0005EB10B /* UserInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC1872372A49B7C0005EB10B /* UserInfoView.swift */; }; FC18723A2A49B7D3005EB10B /* UserInfoHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC1872392A49B7D3005EB10B /* UserInfoHelper.swift */; }; FC18723C2A4E97A6005EB10B /* ConstantSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC18723B2A4E97A6005EB10B /* ConstantSpec.swift */; }; @@ -252,6 +253,7 @@ D9F418282110FD9F00E2158F /* ConfigurationSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationSpec.swift; sourceTree = ""; }; E686BF512A2692CD00D4E3E9 /* TooltipViewSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TooltipViewSpec.swift; sourceTree = ""; }; E686BF532A2692DD00D4E3E9 /* tooltip-data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "tooltip-data.json"; sourceTree = ""; }; + E6D762522CA2A87A00FE62D2 /* CampaignDataModelSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignDataModelSpec.swift; sourceTree = ""; }; FC1872372A49B7C0005EB10B /* UserInfoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInfoView.swift; sourceTree = ""; }; FC1872392A49B7D3005EB10B /* UserInfoHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInfoHelper.swift; sourceTree = ""; }; FC18723B2A4E97A6005EB10B /* ConstantSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstantSpec.swift; sourceTree = ""; }; @@ -460,6 +462,7 @@ 45B572F625AE2163005A80F7 /* Helpers */, 45357AE32457EB49007D8FDC /* Payloads */, 4557A8B0257E544C00C9D241 /* AccountRepositorySpec.swift */, + E6D762522CA2A87A00FE62D2 /* CampaignDataModelSpec.swift */, C9827557262C423C00476505 /* BackoffSpec.swift */, 45B3CC8327871C01005BA3F7 /* BundleSpec.swift */, 45563B0624064D78004EAFD3 /* CampaignRepositorySpec.swift */, @@ -859,6 +862,7 @@ files = ( D24CF280294BE3FA007C6C85 /* UITabBarExtensionSpec.swift in Sources */, 45ADA542247D206B00A9E2A3 /* RouterSpec.swift in Sources */, + E6D762532CA2A87F00FE62D2 /* CampaignDataModelSpec.swift in Sources */, 456FE1E72428513200304872 /* ErrorReportableSpec.swift in Sources */, 4538BCF6262AE8FA009952BE /* UserDataCacheSpec.swift in Sources */, 45BDFD052421EE7B004DEA0C /* SharedMocks.swift in Sources */, diff --git a/Sources/RInAppMessaging/Models/Responses/CampaignDataModels.swift b/Sources/RInAppMessaging/Models/Responses/CampaignDataModels.swift index d9788df2..1d9124fa 100644 --- a/Sources/RInAppMessaging/Models/Responses/CampaignDataModels.swift +++ b/Sources/RInAppMessaging/Models/Responses/CampaignDataModels.swift @@ -73,25 +73,29 @@ internal struct ButtonBehavior: Codable { internal struct CustomJson: Codable { let pushPrimer: PrimerButton? let clickableImage: ClickableImage? + let background: BackgroundColor? enum CodingKeys: String, CodingKey { case pushPrimer case clickableImage + case background } - init(pushPrimer: PrimerButton? = nil, clickableImage: ClickableImage? = nil) { + init(pushPrimer: PrimerButton? = nil, clickableImage: ClickableImage? = nil, background: BackgroundColor? = nil) { self.pushPrimer = pushPrimer self.clickableImage = clickableImage + self.background = background } init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - pushPrimer = try container.decodeIfPresent(PrimerButton.self, forKey: .pushPrimer) - clickableImage = try container.decodeIfPresent(ClickableImage.self, forKey: .clickableImage) + pushPrimer = try? container.decodeIfPresent(PrimerButton.self, forKey: .pushPrimer) + clickableImage = try? container.decodeIfPresent(ClickableImage.self, forKey: .clickableImage) + background = try? container.decodeIfPresent(BackgroundColor.self, forKey: .background) } } -internal struct PrimerButton: Codable { +internal struct PrimerButton: Codable, Equatable { let button: Int? enum CodingKeys: String, CodingKey { @@ -104,15 +108,11 @@ internal struct PrimerButton: Codable { init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - if let button = try? container.decode(Int.self, forKey: .button) { - self.button = button - } else { - self.button = nil - } + self.button = try? container.decodeIfPresent(Int.self, forKey: .button) } } -internal struct ClickableImage: Codable { +internal struct ClickableImage: Codable, Equatable{ let url: String? enum CodingKeys: String, CodingKey { @@ -125,10 +125,23 @@ internal struct ClickableImage: Codable { init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - if let url = try? container.decode(String.self, forKey: .url) { - self.url = url - } else { - self.url = nil - } + self.url = try? container.decodeIfPresent(String.self, forKey: .url) + } +} + +internal struct BackgroundColor: Codable, Equatable { + let opacity: Double? + + enum CodingKeys: String, CodingKey { + case opacity + } + + init(opacity: Double? = nil) { + self.opacity = opacity + } + + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.opacity = try? container.decodeIfPresent(Double.self, forKey: .opacity) } } diff --git a/Sources/RInAppMessaging/Views/FullView.swift b/Sources/RInAppMessaging/Views/FullView.swift index 7a4c73e3..debdc74f 100644 --- a/Sources/RInAppMessaging/Views/FullView.swift +++ b/Sources/RInAppMessaging/Views/FullView.swift @@ -86,6 +86,7 @@ internal class FullView: UIView, FullViewType, RichContentBrowsable { } } private var isClickableImage = false + var backgroundViewColor: UIColor? = .clear init(presenter: FullViewPresenterType) { self.presenter = presenter @@ -150,8 +151,16 @@ internal class FullView: UIView, FullViewType, RichContentBrowsable { layoutContentView(viewModel: viewModel) layoutUIComponents(viewModel: viewModel) createMessageBody(viewModel: viewModel) + if RInAppMessaging.isRMCEnvironment, + let opacity = viewModel.customJson?.background?.opacity, + (0...1).contains(opacity) { + backgroundViewColor = .black.withAlphaComponent(opacity) + } + else { + backgroundViewColor = uiConstants.backgroundColor ?? viewModel.backgroundColor + } - backgroundView.backgroundColor = uiConstants.backgroundColor ?? viewModel.backgroundColor + backgroundView.backgroundColor = backgroundViewColor optOutView.useBrightColors = !viewModel.backgroundColor.isBright exitButton.invertedColors = viewModel.backgroundColor.isBright diff --git a/Tests/Tests/CampaignDataModelSpec.swift b/Tests/Tests/CampaignDataModelSpec.swift new file mode 100644 index 00000000..51367c39 --- /dev/null +++ b/Tests/Tests/CampaignDataModelSpec.swift @@ -0,0 +1,211 @@ +import Quick +import Nimble +@testable import RInAppMessaging + +class CustomJsonSpec: QuickSpec { + override func spec() { + describe("CustomJson") { + context("when initialized with all properties") { + let primerButton = PrimerButton(button: 1) + let clickableImage = ClickableImage(url: "http://example.com/image.png") + let backgroundColor = BackgroundColor(opacity: 0.5) + + let customJson = CustomJson(pushPrimer: primerButton, clickableImage: clickableImage, background: backgroundColor) + + it("should have the correct properties") { + expect(customJson.pushPrimer).to(equal(primerButton)) + expect(customJson.clickableImage).to(equal(clickableImage)) + expect(customJson.background).to(equal(backgroundColor)) + } + } + + context("when initialized with nil properties") { + let customJson = CustomJson() + + it("should have nil properties") { + expect(customJson.pushPrimer).to(beNil()) + expect(customJson.clickableImage).to(beNil()) + expect(customJson.background).to(beNil()) + } + } + + context("when decoding from valid JSON") { + it("should decode correctly") { + let jsonString = """ + { + "pushPrimer": {"button": 1}, + "clickableImage": {"url": "http://example.com/image.png"}, + "background": {"opacity": 0.5} + } + """ + let jsonData = jsonString.data(using: .utf8)! + let decoder = JSONDecoder() + let decodedJson = try? decoder.decode(CustomJson.self, from: jsonData) + + expect(decodedJson).toNot(beNil()) + expect(decodedJson?.pushPrimer?.button).to(equal(1)) + expect(decodedJson?.clickableImage?.url).to(equal("http://example.com/image.png")) + expect(decodedJson?.background?.opacity).to(equal(0.5)) + } + } + + context("when decoding from invalid JSON") { + it("should return nil for missing required fields") { + let jsonString = """ + { + "pushPrimer": {"button": 1}, + "clickableImage": {} + } + """ + let jsonData = jsonString.data(using: .utf8)! + let decoder = JSONDecoder() + let decodedJson = try? decoder.decode(CustomJson.self, from: jsonData) + + expect(decodedJson).toNot(beNil()) + expect(decodedJson?.pushPrimer?.button).to(equal(1)) + expect(decodedJson?.clickableImage?.url).to(beNil()) + expect(decodedJson?.background).to(beNil()) + } + + it("should fail decoding due to incorrect data types") { + let jsonString = """ + { + "pushPrimer": {"button": "notAnInteger"}, + "clickableImage": {"url": 12345}, + "background": {"opacity": "notADouble"} + } + """ + let jsonData = jsonString.data(using: .utf8)! + let decoder = JSONDecoder() + let decodedJson = try? decoder.decode(CustomJson.self, from: jsonData) + + expect(decodedJson).toNot(beNil()) + expect(decodedJson?.pushPrimer?.button).to(beNil()) + expect(decodedJson?.clickableImage?.url).to(beNil()) + expect(decodedJson?.background?.opacity).to(beNil()) + } + + it("should fail decoding when fields are strings instead of objects") { + let jsonString = """ + { + "pushPrimer": "string", + "clickableImage": "string", + "background": "string" + } + """ + let jsonData = jsonString.data(using: .utf8)! + + let decoder = JSONDecoder() + let decodedJson = try? decoder.decode(CustomJson.self, from: jsonData) + + expect(decodedJson).toNot(beNil()) + expect(decodedJson?.pushPrimer).to(beNil()) + expect(decodedJson?.clickableImage).to(beNil()) + expect(decodedJson?.background).to(beNil()) + } + } + } + + describe("PrimerButton") { + context("when decoding from valid JSON") { + it("should decode correctly") { + let jsonString = """ + { + "button": 1 + } + """ + let jsonData = jsonString.data(using: .utf8)! + + let decoder = JSONDecoder() + let decodedButton = try? decoder.decode(PrimerButton.self, from: jsonData) + + expect(decodedButton).toNot(beNil()) + expect(decodedButton?.button).to(equal(1)) + } + } + + context("when decoding from invalid JSON") { + it("should return nil for invalid data type") { + let jsonString = """ + { + "button": "notAnInteger" + } + """ + let jsonData = jsonString.data(using: .utf8)! + + let decoder = JSONDecoder() + let decodedButton = try? decoder.decode(PrimerButton.self, from: jsonData) + + expect(decodedButton?.button).to(beNil()) + } + } + } + + describe("ClickableImage") { + context("when decoding from valid JSON") { + it("should decode correctly") { + let jsonString = """ + { + "url": "http://example.com/image.png" + } + """ + let jsonData = jsonString.data(using: .utf8)! + let decoder = JSONDecoder() + let decodedImage = try? decoder.decode(ClickableImage.self, from: jsonData) + expect(decodedImage).toNot(beNil()) + expect(decodedImage?.url).to(equal("http://example.com/image.png")) + } + } + + context("when decoding from invalid JSON") { + it("should return nil for invalid data type") { + let jsonString = """ + { + "url": 12345 + } + """ + let jsonData = jsonString.data(using: .utf8)! + + let decoder = JSONDecoder() + let decodedImage = try? decoder.decode(ClickableImage.self, from: jsonData) + + expect(decodedImage?.url).to(beNil()) + } + } + } + + describe("BackgroundColor") { + context("when decoding from valid JSON") { + it("should decode correctly") { + let jsonString = """ + { + "opacity": 0.5 + } + """ + let jsonData = jsonString.data(using: .utf8)! + let decoder = JSONDecoder() + let decodedBackground = try? decoder.decode(BackgroundColor.self, from: jsonData) + + expect(decodedBackground).toNot(beNil()) + expect(decodedBackground?.opacity).to(equal(0.5)) + } + } + + context("when decoding from invalid JSON") { + it("should return nil for invalid data type") { + let jsonString = """ + { + "opacity": "notADouble" + } + """ + let jsonData = jsonString.data(using: .utf8)! + + let decoder = JSONDecoder() + let decodedBackground = try? decoder.decode(BackgroundColor.self, from: jsonData) + + expect(decodedBackground?.opacity).to(beNil()) + } + } + } + } +} diff --git a/Tests/Tests/Helpers/TestHelpers.swift b/Tests/Tests/Helpers/TestHelpers.swift index ae521c2e..7d0b5a5c 100644 --- a/Tests/Tests/Helpers/TestHelpers.swift +++ b/Tests/Tests/Helpers/TestHelpers.swift @@ -1,5 +1,5 @@ import Foundation -import class UIKit.UIColor +import UIKit @testable import RInAppMessaging class ValidatorHandler { @@ -128,6 +128,22 @@ struct TestHelpers { ) } + static func generateFullViewModel(customJson: CustomJson? = nil) -> FullViewModel { + return FullViewModel.init(image: UIImage(named: "test-image"), + backgroundColor: .black, + title: "Test", + messageBody: "test campaign", + header: "testing", + titleColor: .black, + headerColor: .black, + messageBodyColor: .black, + isHTML: false, + showOptOut: true, + showButtons: true, + isDismissable: true, + customJson: customJson) + } + enum MockResponse { static func withGeneratedCampaigns(count: Int, test: Bool, diff --git a/Tests/Tests/ViewSpec.swift b/Tests/Tests/ViewSpec.swift index fa4c2cae..ab9cb511 100644 --- a/Tests/Tests/ViewSpec.swift +++ b/Tests/Tests/ViewSpec.swift @@ -174,6 +174,57 @@ class ViewSpec: QuickSpec { } } + describe("ModalView with CustomJson") { + var view: ModalView! + var presenter: FullViewPresenterMock! + + beforeEach { + BundleInfoMocked.bundleMock = BundleMock() + RInAppMessaging.bundleInfo = BundleInfoMocked.self + RInAppMessaging.deinitializeModule() + + presenter = FullViewPresenterMock() + view = ModalView(presenter: presenter) + presenter.view = view + } + + afterEach { + RInAppMessaging.bundleInfo = BundleInfo.self + } + + it("will have dark background color if CustomJson has valid value") { + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: CustomJson(background: BackgroundColor(opacity: 0.6)))) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(0.6))) + + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: CustomJson(background: BackgroundColor(opacity: 0)))) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(0))) + + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: CustomJson(background: BackgroundColor(opacity: 1)))) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(1))) + } + + it("will have default background color if CustomJson has invalid value") { + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: CustomJson(background: BackgroundColor(opacity: 1.2)))) + expect(view.backgroundViewColor).toNot(equal(.black.withAlphaComponent(1.2))) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(0.14))) + + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: CustomJson(background: BackgroundColor(opacity: -1)))) + expect(view.backgroundViewColor).toNot(equal(.black.withAlphaComponent(-1))) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(0.14))) + } + + it("will have default background color if CustomJson has nil value for any parameters") { + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: CustomJson(background: nil))) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(0.14))) + + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: CustomJson(background: BackgroundColor(opacity: nil)))) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(0.14))) + + view.setup(viewModel: TestHelpers.generateFullViewModel(customJson: nil)) + expect(view.backgroundViewColor).to(equal(.black.withAlphaComponent(0.14))) + } + } + describe("FullScreenView") { var view: FullScreenView! var presenter: FullViewPresenterMock! From ff1caaedeed4fc0e2f99db451f84a26621c2c356 Mon Sep 17 00:00:00 2001 From: "soumen.rautray" <96281209+SoumenRautray@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:31:43 +0530 Subject: [PATCH 2/9] chore: enable dark background only for Modal Campaign (RMCCX-7328) --- Sources/RInAppMessaging/Views/FullView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/RInAppMessaging/Views/FullView.swift b/Sources/RInAppMessaging/Views/FullView.swift index debdc74f..2c7d99a4 100644 --- a/Sources/RInAppMessaging/Views/FullView.swift +++ b/Sources/RInAppMessaging/Views/FullView.swift @@ -152,11 +152,11 @@ internal class FullView: UIView, FullViewType, RichContentBrowsable { layoutUIComponents(viewModel: viewModel) createMessageBody(viewModel: viewModel) if RInAppMessaging.isRMCEnvironment, + case .modal = mode, let opacity = viewModel.customJson?.background?.opacity, (0...1).contains(opacity) { backgroundViewColor = .black.withAlphaComponent(opacity) - } - else { + } else { backgroundViewColor = uiConstants.backgroundColor ?? viewModel.backgroundColor } From f03158e5c37526494a6cd4f4ede3ddadab9929de Mon Sep 17 00:00:00 2001 From: "soumen.rautray" <96281209+SoumenRautray@users.noreply.github.com> Date: Sun, 29 Sep 2024 12:03:56 +0530 Subject: [PATCH 3/9] chore: update minimum support version to iOS 14 (RMCCX-7398) --- Package.swift | 2 +- README.md | 2 +- RInAppMessaging.podspec | 2 +- RInAppMessaging.xcodeproj/project.pbxproj | 6 +++--- Sample/AppStarterViewController.swift | 4 ++-- Sample/Shared/Helpers/View+Extension.swift | 2 +- Sample/SwiftUI/CustomEventView.swift | 4 ++-- Sample/SwiftUI/MainView.swift | 4 ++-- Sample/SwiftUI/SecondView.swift | 4 ++-- Sample/SwiftUI/TabBarView.swift | 6 +++--- Sample/SwiftUI/UserInfoView.swift | 4 ++-- SampleSPM/SampleSPM.xcodeproj/project.pbxproj | 14 +++++++------- .../Extensions/UIApplication+IAM.swift | 4 ++-- Sources/RInAppMessaging/Extensions/View+IAM.swift | 2 +- Tests/Tests/RouterSpec.swift | 2 +- Tests/Tests/UIApplicationExtensionSpec.swift | 4 ++-- Tests/Tests/ViewPresenterSpec.swift | 2 +- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Package.swift b/Package.swift index 1e1d82a1..7ff32660 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ let package = Package( name: "RInAppMessaging", defaultLocalization: "en", platforms: [ - .iOS(.v12) + .iOS(.v14) ], products: [ .library( diff --git a/README.md b/README.md index 0a166e8c..088c4faf 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ In-App Messaging (IAM) module allows app developers to easily configure and display notifications within their app. -This module supports iOS 12.0 and above. It has been tested with iOS 12.5 and above. +This module supports iOS 14.0 and above. It has been tested with iOS 14 and above. ### This page covers: * [Requirements](#requirements) diff --git a/RInAppMessaging.podspec b/RInAppMessaging.podspec index cd8f4cac..2358d7a8 100644 --- a/RInAppMessaging.podspec +++ b/RInAppMessaging.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.license = { :type => 'MIT', :file => 'LICENSE' } s.authors = 'Rakuten Ecosystem Mobile' s.source = { :git => "https://github.com/rakutentech/ios-inappmessaging.git", :tag => s.version.to_s } - s.ios.deployment_target = '12.0' + s.ios.deployment_target = '14.0' s.swift_versions = ['5.7.1'] s.resources = ['Sources/RInAppMessaging/Resources/PrivacyInfo.xcprivacy'] s.dependency 'RSDKUtils', '~> 4.0' diff --git a/RInAppMessaging.xcodeproj/project.pbxproj b/RInAppMessaging.xcodeproj/project.pbxproj index 0973d4a4..41cdc28b 100644 --- a/RInAppMessaging.xcodeproj/project.pbxproj +++ b/RInAppMessaging.xcodeproj/project.pbxproj @@ -1062,7 +1062,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1249,7 +1249,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1298,7 +1298,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; diff --git a/Sample/AppStarterViewController.swift b/Sample/AppStarterViewController.swift index 462f0097..0e4e713d 100644 --- a/Sample/AppStarterViewController.swift +++ b/Sample/AppStarterViewController.swift @@ -7,7 +7,7 @@ class AppStarterViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - guard #available(iOS 13, *) else { + guard #available(iOS 14, *) else { swiftUIButton.isEnabled = false return } @@ -21,7 +21,7 @@ class AppStarterViewController: UIViewController { view.window?.rootViewController = uiKitTabBarController } - @available(iOS 13.0, *) + @available(iOS 14.0, *) @IBAction func swiftUiDidTap(_ sender: Any) { let swiftUITabBarController = UIHostingController(rootView: TabBarView()) view.window?.rootViewController = swiftUITabBarController diff --git a/Sample/Shared/Helpers/View+Extension.swift b/Sample/Shared/Helpers/View+Extension.swift index 9c57082d..650938be 100644 --- a/Sample/Shared/Helpers/View+Extension.swift +++ b/Sample/Shared/Helpers/View+Extension.swift @@ -1,7 +1,7 @@ import SwiftUI #if canImport(UIKit) -@available(iOS 13.0, *) +@available(iOS 14.0, *) extension View { func hideKeyboard() { UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) diff --git a/Sample/SwiftUI/CustomEventView.swift b/Sample/SwiftUI/CustomEventView.swift index 4b254fd7..b4a027c0 100644 --- a/Sample/SwiftUI/CustomEventView.swift +++ b/Sample/SwiftUI/CustomEventView.swift @@ -1,7 +1,7 @@ import SwiftUI import RInAppMessaging -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct CustomEventView: View { @State private var isAlertPresented = false @@ -108,7 +108,7 @@ struct CustomEventView: View { } } -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct CustomEventView_Previews: PreviewProvider { static var previews: some View { CustomEventView() diff --git a/Sample/SwiftUI/MainView.swift b/Sample/SwiftUI/MainView.swift index a4ef0543..84326d2e 100644 --- a/Sample/SwiftUI/MainView.swift +++ b/Sample/SwiftUI/MainView.swift @@ -1,7 +1,7 @@ import SwiftUI @testable import RInAppMessaging -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct MainView: View { @State private var isErrorAlertPresented = false @@ -77,7 +77,7 @@ struct MainView: View { } } -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct MainView_Previews: PreviewProvider { static var previews: some View { MainView() diff --git a/Sample/SwiftUI/SecondView.swift b/Sample/SwiftUI/SecondView.swift index a669508c..1d55c99e 100644 --- a/Sample/SwiftUI/SecondView.swift +++ b/Sample/SwiftUI/SecondView.swift @@ -1,7 +1,7 @@ import SwiftUI import RInAppMessaging -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct SecondView: View { @Environment(\.presentationMode) var presentationMode @@ -42,7 +42,7 @@ struct SecondView: View { } } -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct SecondView_Previews: PreviewProvider { static var previews: some View { SecondView() diff --git a/Sample/SwiftUI/TabBarView.swift b/Sample/SwiftUI/TabBarView.swift index d1b772d2..156ad006 100644 --- a/Sample/SwiftUI/TabBarView.swift +++ b/Sample/SwiftUI/TabBarView.swift @@ -1,6 +1,6 @@ import SwiftUI -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct TabBarView: View { var body: some View { VStack { @@ -30,14 +30,14 @@ struct TabBarView: View { } } -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct TabView_Previews: PreviewProvider { static var previews: some View { TabBarView() } } -@available(iOS 13.0, *) +@available(iOS 14.0, *) extension View { func canHaveTooltipIfAvailable(identifier: String) -> some View { if #available(iOS 15.0, *) { diff --git a/Sample/SwiftUI/UserInfoView.swift b/Sample/SwiftUI/UserInfoView.swift index 4f41843b..34d4948d 100644 --- a/Sample/SwiftUI/UserInfoView.swift +++ b/Sample/SwiftUI/UserInfoView.swift @@ -1,7 +1,7 @@ import SwiftUI import RInAppMessaging -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct UserInfoView: View { @State private var userIDText: String = "" @@ -87,7 +87,7 @@ struct UserInfoView: View { } } -@available(iOS 13.0, *) +@available(iOS 14.0, *) struct UserInfoView_Previews: PreviewProvider { static var previews: some View { UserInfoView() diff --git a/SampleSPM/SampleSPM.xcodeproj/project.pbxproj b/SampleSPM/SampleSPM.xcodeproj/project.pbxproj index 79600c2a..5e84d7b2 100644 --- a/SampleSPM/SampleSPM.xcodeproj/project.pbxproj +++ b/SampleSPM/SampleSPM.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -1106,7 +1106,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1124,7 +1124,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 575EYS6ZJA; INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1323,7 +1323,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1373,7 +1373,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; @@ -1392,7 +1392,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 575EYS6ZJA; INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1416,7 +1416,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 575EYS6ZJA; INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Sources/RInAppMessaging/Extensions/UIApplication+IAM.swift b/Sources/RInAppMessaging/Extensions/UIApplication+IAM.swift index 0281c906..5d61f379 100644 --- a/Sources/RInAppMessaging/Extensions/UIApplication+IAM.swift +++ b/Sources/RInAppMessaging/Extensions/UIApplication+IAM.swift @@ -4,7 +4,7 @@ extension UIApplication { func getKeyWindow() -> UIWindow? { var keySceneWindow: UIWindow? - if #available(iOS 13.0, *) { + if #available(iOS 14.0, *) { keySceneWindow = connectedScenes .filter({ $0.activationState == .foregroundActive }) .compactMap({ $0 as? UIWindowScene }) @@ -16,7 +16,7 @@ extension UIApplication { } func getCurrentStatusBarStyle() -> UIStatusBarStyle? { - if #available(iOS 13.0, *), + if #available(iOS 14.0, *), let keyScene = connectedScenes .filter({ $0.activationState != .unattached }) .compactMap({ $0 as? UIWindowScene }) diff --git a/Sources/RInAppMessaging/Extensions/View+IAM.swift b/Sources/RInAppMessaging/Extensions/View+IAM.swift index 99555729..5e901625 100644 --- a/Sources/RInAppMessaging/Extensions/View+IAM.swift +++ b/Sources/RInAppMessaging/Extensions/View+IAM.swift @@ -1,7 +1,7 @@ import Foundation import SwiftUI -@available(iOS 13.0, *) +@available(iOS 14.0, *) internal extension View { /// Hide or show the view based on a boolean value. /// diff --git a/Tests/Tests/RouterSpec.swift b/Tests/Tests/RouterSpec.swift index 5fd444f7..2b581e82 100644 --- a/Tests/Tests/RouterSpec.swift +++ b/Tests/Tests/RouterSpec.swift @@ -11,7 +11,7 @@ import class RSDKUtilsMain.TypedDependencyManager @testable import RInAppMessaging -@available(iOS 13.0, *) // Because of UIImage(named:in:with:) +@available(iOS 14.0, *) // Because of UIImage(named:in:with:) class RouterSpec: QuickSpec { // swiftlint:disable:previous type_body_length diff --git a/Tests/Tests/UIApplicationExtensionSpec.swift b/Tests/Tests/UIApplicationExtensionSpec.swift index 8aee3259..9f8095ca 100644 --- a/Tests/Tests/UIApplicationExtensionSpec.swift +++ b/Tests/Tests/UIApplicationExtensionSpec.swift @@ -26,7 +26,7 @@ class UIApplicationExtensionsSpec: QuickSpec { } // Tests below will run only on iOS 13+ - guard #available(iOS 13.0, *) else { + guard #available(iOS 14.0, *) else { return } @@ -54,7 +54,7 @@ class UIApplicationExtensionsSpec: QuickSpec { context("when calling getCurrentStatusBarStyle method") { it("will not return nil on iOS 13+") { - if #available(iOS 13.0, *) { + if #available(iOS 14.0, *) { expect(application.statusBarStyle).toNot(beNil()) } else { expect(application.statusBarStyle).to(beNil()) diff --git a/Tests/Tests/ViewPresenterSpec.swift b/Tests/Tests/ViewPresenterSpec.swift index 0ea6dc9a..24c99a05 100644 --- a/Tests/Tests/ViewPresenterSpec.swift +++ b/Tests/Tests/ViewPresenterSpec.swift @@ -346,7 +346,7 @@ class ViewPresenterSpec: QuickSpec { expect(view.wasSetupCalled).to(beTrue()) } - if #available(iOS 13.0, *) { + if #available(iOS 14.0, *) { it("will call initializeView on the view object with expected model") { presenter.associatedImage = UIImage(named: "test-image", in: .unitTests, with: nil) presenter.viewDidInitialize() From 7ab2a6239b9c6e4f760734fea0a99395f4fa1494 Mon Sep 17 00:00:00 2001 From: Soumen Rautray Date: Thu, 3 Oct 2024 14:26:13 +0530 Subject: [PATCH 4/9] chore: add production Logs (RMCCX-6877) --- .../RInAppMessaging/CampaignDispatcher.swift | 3 +- .../CampaignsListManager.swift | 2 ++ .../RInAppMessaging/CampaignsValidator.swift | 2 +- .../Extensions/UITabBar+IAM.swift | 2 +- .../InAppMessagingInteractor.swift | 1 + .../InAppMessagingModule.swift | 9 ++++-- .../Protocols/ErrorReportable.swift | 4 +-- .../Protocols/HttpRequestable.swift | 8 ++--- Sources/RInAppMessaging/RInAppMessaging.swift | 12 ++++--- .../Repositories/AccountRepository.swift | 3 ++ .../Repositories/CampaignRepository.swift | 14 ++++++--- Sources/RInAppMessaging/Router.swift | 14 ++++----- .../Services/ConfigurationService.swift | 8 ++--- .../Services/DisplayPermissionService.swift | 8 ++--- .../Services/MessageMixerService.swift | 8 ++--- Sources/RInAppMessaging/UserDataCache.swift | 4 +-- .../Utilities/CommonUtility.swift | 31 ++++++++++++++++++- .../TriggerAttributesValidator.swift | 4 +-- .../Presenters/SlideUpViewPresenter.swift | 2 +- .../RInAppMessaging/Views/SlideUpView.swift | 4 +-- 20 files changed, 97 insertions(+), 46 deletions(-) diff --git a/Sources/RInAppMessaging/CampaignDispatcher.swift b/Sources/RInAppMessaging/CampaignDispatcher.swift index 466b9e11..4ee2f44c 100644 --- a/Sources/RInAppMessaging/CampaignDispatcher.swift +++ b/Sources/RInAppMessaging/CampaignDispatcher.swift @@ -88,7 +88,7 @@ internal class CampaignDispatcher: CampaignDispatcherType, TaskSchedulable { let campaignID = queuedCampaignIDs.removeFirst() guard let campaign = campaignRepository.list.first(where: { $0.id == campaignID }) else { - Logger.debug("Warning: Queued campaign \(campaignID) does not exist in the repository anymore") + IAMLogger.debug("Warning: Queued campaign \(campaignID) does not exist in the repository anymore") return } let permissionResponse = permissionService.checkPermission(forCampaign: campaign.data) @@ -96,6 +96,7 @@ internal class CampaignDispatcher: CampaignDispatcherType, TaskSchedulable { delegate?.performPing() } + IAMLogger.debugLog("campaign impressionsLeft: \(campaign.impressionsLeft)") guard campaign.impressionsLeft > 0 && (permissionResponse.display || campaign.data.isTest) else { dispatchNext() return diff --git a/Sources/RInAppMessaging/CampaignsListManager.swift b/Sources/RInAppMessaging/CampaignsListManager.swift index c1d3ec56..99c5215e 100644 --- a/Sources/RInAppMessaging/CampaignsListManager.swift +++ b/Sources/RInAppMessaging/CampaignsListManager.swift @@ -34,6 +34,7 @@ internal class CampaignsListManager: CampaignsListManagerType, TaskSchedulable { } func refreshList() { + IAMLogger.debugLog("refreshList()") pingQueue.sync { pingMixerServer() } @@ -53,6 +54,7 @@ internal class CampaignsListManager: CampaignsListManagerType, TaskSchedulable { handleError(error) return } + IAMLogger.debugLog("pingMixerServer: response decoded") handleSuccess(decodedResponse) } diff --git a/Sources/RInAppMessaging/CampaignsValidator.swift b/Sources/RInAppMessaging/CampaignsValidator.swift index 0a113ef0..03032b56 100644 --- a/Sources/RInAppMessaging/CampaignsValidator.swift +++ b/Sources/RInAppMessaging/CampaignsValidator.swift @@ -52,7 +52,7 @@ internal struct CampaignsValidator: CampaignsValidatorType { } guard let campaignTriggers = campaign.data.triggers else { - Logger.debug("campaign (\(campaign.id)) has no triggers.") + IAMLogger.debug("campaign (\(campaign.id)) has no triggers.") return } diff --git a/Sources/RInAppMessaging/Extensions/UITabBar+IAM.swift b/Sources/RInAppMessaging/Extensions/UITabBar+IAM.swift index 93672c5a..db5eca0d 100644 --- a/Sources/RInAppMessaging/Extensions/UITabBar+IAM.swift +++ b/Sources/RInAppMessaging/Extensions/UITabBar+IAM.swift @@ -13,7 +13,7 @@ public extension UITabBar { .sorted { $0.frame.minX < $1.frame.minX } // Ensuring the right order guard tabBarButtons.count == items?.count else { - Logger.debug("Unexpected tab bar items setup: \(tabBarButtons) \(items ?? [])") + IAMLogger.debug("Unexpected tab bar items setup: \(tabBarButtons) \(items ?? [])") return } diff --git a/Sources/RInAppMessaging/InAppMessagingInteractor.swift b/Sources/RInAppMessaging/InAppMessagingInteractor.swift index 86a0d3cb..2150d00c 100644 --- a/Sources/RInAppMessaging/InAppMessagingInteractor.swift +++ b/Sources/RInAppMessaging/InAppMessagingInteractor.swift @@ -82,6 +82,7 @@ final class InAppMessagingInteractor { module.onVerifyContext = onVerifyContext module.setAccessibilityCompatibleDisplay(accessibilityCompatibleDisplay) if let userPerference { + IAMLogger.debugLog("configure: registerPreference - userPerference") module.registerPreference(userPerference) } iamModule = module diff --git a/Sources/RInAppMessaging/InAppMessagingModule.swift b/Sources/RInAppMessaging/InAppMessagingModule.swift index b0e5dbaf..075153c9 100644 --- a/Sources/RInAppMessaging/InAppMessagingModule.swift +++ b/Sources/RInAppMessaging/InAppMessagingModule.swift @@ -82,7 +82,7 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, guard isInitialized else { return false } - + IAMLogger.debugLog("logEvent: \(event)") checkUserChanges() eventMatcher.matchAndStore(event: event) campaignTriggerAgent.validateAndTriggerCampaigns() @@ -91,9 +91,11 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, func registerPreference(_ preference: UserInfoProvider) { accountRepository.setPreference(preference) - + IAMLogger.debugLog("registerPreference: \(preference)") + guard isInitialized else { if accountRepository.updateUserInfo() { + IAMLogger.debugLog("registerPreference: updateUserInfo") campaignRepository.loadCachedData() } return @@ -103,6 +105,7 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, } func closeMessage(clearQueuedCampaigns: Bool) { + IAMLogger.debugLog("closeMessage: \(clearQueuedCampaigns)") if clearQueuedCampaigns { readyCampaignDispatcher.resetQueue() } @@ -110,6 +113,7 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, } func closeTooltip(with uiElementIdentifier: String) { + IAMLogger.debugLog("closeTooltip: \(uiElementIdentifier)") router.discardDisplayedTooltip(with: uiElementIdentifier) } @@ -120,6 +124,7 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, // visible for testing func checkUserChanges() { if accountRepository.updateUserInfo() { + IAMLogger.debugLog("checkUserChanges: updateUserInfo() - user has changed") campaignRepository.loadCachedData() campaignsListManager.refreshList() } diff --git a/Sources/RInAppMessaging/Protocols/ErrorReportable.swift b/Sources/RInAppMessaging/Protocols/ErrorReportable.swift index ccb0476b..b41c84ab 100644 --- a/Sources/RInAppMessaging/Protocols/ErrorReportable.swift +++ b/Sources/RInAppMessaging/Protocols/ErrorReportable.swift @@ -17,9 +17,9 @@ extension ErrorReportable { errorDelegate?.didReceive(error: error) if let unwrappedData = data { - Logger.debug(description + " (\(String(describing: unwrappedData))") + IAMLogger.debug(description + " (\(String(describing: unwrappedData))") } else { - Logger.debug(description) + IAMLogger.debug(description) } } } diff --git a/Sources/RInAppMessaging/Protocols/HttpRequestable.swift b/Sources/RInAppMessaging/Protocols/HttpRequestable.swift index 3836a991..396c879b 100644 --- a/Sources/RInAppMessaging/Protocols/HttpRequestable.swift +++ b/Sources/RInAppMessaging/Protocols/HttpRequestable.swift @@ -57,7 +57,7 @@ extension HttpRequestable { addtionalHeaders: [HeaderAttribute]?) -> RequestResult { if Thread.current.isMainThread { - Logger.debug("Performing HTTP task synchronously on main thread. This should be avoided.") + IAMLogger.debug("Performing HTTP task synchronously on main thread. This should be avoided.") assertionFailure() } @@ -72,7 +72,7 @@ extension HttpRequestable { completion: { result = $0 }) guard let unwrappedResult = result else { - Logger.debug("Error: Didn't get any result - completion handler not called!") + IAMLogger.debug("Error: Didn't get any result - completion handler not called!") assertionFailure() return .failure(.unknown) } @@ -141,7 +141,7 @@ extension HttpRequestable { if let error = error { completion(.failure(.taskFailed(error))) - Logger.debug(error) + IAMLogger.debug(String(describing: error)) return } @@ -153,7 +153,7 @@ extension HttpRequestable { completion(.failure(.httpError(UInt(statusCode), response, data))) let errorMessage = data != nil ? String(data: data!, encoding: .utf8) : "" - Logger.debug("HTTP call failed (\(statusCode))\n\(errorMessage ?? "")") + IAMLogger.debug("HTTP call failed (\(statusCode))\n\(errorMessage ?? "")") return } diff --git a/Sources/RInAppMessaging/RInAppMessaging.swift b/Sources/RInAppMessaging/RInAppMessaging.swift index 60a7bf3f..e81a5b34 100644 --- a/Sources/RInAppMessaging/RInAppMessaging.swift +++ b/Sources/RInAppMessaging/RInAppMessaging.swift @@ -83,11 +83,11 @@ import RSDKUtils @objc public static func configure(subscriptionID: String? = nil, configurationURL: String? = nil, enableTooltipFeature: Bool = false) { - + IAMLogger.debugLog("configure") guard verifyRMCEnvironment(subscriptionID: subscriptionID), !isInitialized else { let description = "⚠️ SDK configure request rejected. Initialization status: \(isInitialized)" let error = NSError.iamError(description: description) - Logger.debug(description) + IAMLogger.debug(description) errorCallback?(error) return } @@ -125,8 +125,9 @@ import RSDKUtils /// Log the event name passed in and also pass the event name to the view controller to display a matching campaign. /// - Parameter event: The Event object to log. @objc public static func logEvent(_ event: Event) { + IAMLogger.debugLog("logEvent: \(event)") if !isUserRegistered { - Logger.debug("⚠️ Warning: RegisterPreference should be called before logging any Events.") + IAMLogger.debug("⚠️ Warning: RegisterPreference should be called before logging any Events.") } inAppQueue.async { interactor.logEvent(event) @@ -140,6 +141,7 @@ import RSDKUtils /// - Note: This method creates a strong reference to provided object. /// - Parameter provider: object that will always contain up-to-date user information. @objc public static func registerPreference(_ provider: UserInfoProvider) { + IAMLogger.debugLog("registerPreference: \(provider)") isUserRegistered = true inAppQueue.async { interactor.userPerference = provider @@ -153,6 +155,7 @@ import RSDKUtils /// - Parameter clearQueuedCampaigns: when set to true, it will clear also the list of campaigns that were /// triggered and are queued to be displayed. @objc public static func closeMessage(clearQueuedCampaigns: Bool = false) { + IAMLogger.debugLog("closeMessage") inAppQueue.async { interactor.closeMessage(clearQueuedCampaigns: clearQueuedCampaigns) } @@ -165,6 +168,7 @@ import RSDKUtils /// - Parameter uiElementIdentifier: accessibilityIdentifier of UI element that displayed tooltip is attached to. /// (a.k.a. `UIElement` parameter in tooltip JSON payload) @objc public static func closeTooltip(with uiElementIdentifier: String) { + IAMLogger.debugLog("closeTooltip : \(uiElementIdentifier)") inAppQueue.async { interactor.closeTooltip(with: uiElementIdentifier) } @@ -176,7 +180,7 @@ import RSDKUtils guard let url = config.configURLString , let configURL = URL(string: url) else { let description = "⚠️ Invalid Configuration URL: \(config.configURLString ?? "")" let error = NSError.iamError(description: description) - Logger.debug(description) + IAMLogger.debug(description) errorCallback?(error) assertionFailure(description) return URL(string: "invalid")! diff --git a/Sources/RInAppMessaging/Repositories/AccountRepository.swift b/Sources/RInAppMessaging/Repositories/AccountRepository.swift index 04e8beae..9aafdfa4 100644 --- a/Sources/RInAppMessaging/Repositories/AccountRepository.swift +++ b/Sources/RInAppMessaging/Repositories/AccountRepository.swift @@ -44,6 +44,7 @@ final class AccountRepository: AccountRepositoryType { func updateUserInfo() -> Bool { guard let userInfoProvider = userInfoProvider else { // No userInfoProvider object has been registered yet + IAMLogger.debugLog("updateUserInfo: No userInfoProvider object has been registered yet") return false } if BundleInfo.applicationId?.contains("rakuten") == true, !Environment.isUnitTestEnvironment { @@ -51,6 +52,7 @@ final class AccountRepository: AccountRepositoryType { } let newHash = userDataCache.userHash(from: userInfoProvider.userIdentifiers) + IAMLogger.debugLog("updateUserInfo: newUserHash: \(newHash)") guard let currentHash = userInfoHash else { // updateUserInfo() has been called for the first time after registering `userInfoProvider` userInfoHash = newHash @@ -63,6 +65,7 @@ final class AccountRepository: AccountRepositoryType { } userInfoHash = newHash + IAMLogger.debugLog("updateUserInfo: currentHash=\(currentHash), userInfoHash=\(String(describing: userInfoHash))") return currentHash != userInfoHash } diff --git a/Sources/RInAppMessaging/Repositories/CampaignRepository.swift b/Sources/RInAppMessaging/Repositories/CampaignRepository.swift index d7039247..ffaff7ed 100644 --- a/Sources/RInAppMessaging/Repositories/CampaignRepository.swift +++ b/Sources/RInAppMessaging/Repositories/CampaignRepository.swift @@ -79,6 +79,7 @@ internal class CampaignRepository: CampaignRepositoryType { } func syncWith(list: [Campaign], timestampMilliseconds: Int64, ignoreTooltips: Bool) { + IAMLogger.debugLog("syncWith start") lastSyncInMilliseconds = timestampMilliseconds let oldList = allCampaigns.get() @@ -108,13 +109,14 @@ internal class CampaignRepository: CampaignRepositoryType { saveDataToCache(updatedList) delegate?.didUpdateCampaignList() + IAMLogger.debugLog("syncWith end") } @discardableResult func optOutCampaign(_ campaign: Campaign) -> Campaign? { var newList = allCampaigns.get() guard let index = newList.firstIndex(where: { $0.id == campaign.id }) else { - Logger.debug("Campaign \(campaign.id) cannot be updated - not found in repository") + IAMLogger.debug("Campaign \(campaign.id) cannot be updated - not found in repository") return nil } @@ -131,17 +133,21 @@ internal class CampaignRepository: CampaignRepositoryType { @discardableResult func decrementImpressionsLeftInCampaign(id: String) -> Campaign? { - updateImpressionsLeftInCampaign(withID: id, by: -1) + IAMLogger.debugLog("decrementImpressionsLeftInCampaign: \(id)") + return updateImpressionsLeftInCampaign(withID: id, by: -1) } @discardableResult func incrementImpressionsLeftInCampaign(id: String) -> Campaign? { - updateImpressionsLeftInCampaign(withID: id, by: 1) + IAMLogger.debugLog("incrementImpressionsLeftInCampaign: \(id)") + return updateImpressionsLeftInCampaign(withID: id, by: 1) } func loadCachedData() { + IAMLogger.debugLog("loadCachedData: start") let cachedData = userDataCache.getUserData(identifiers: accountRepository.getUserIdentifiers())?.campaignData ?? [] allCampaigns.set(value: cachedData) + IAMLogger.debugLog("loadCachedData: end") } // MARK: - Helpers @@ -149,7 +155,7 @@ internal class CampaignRepository: CampaignRepositoryType { private func updateImpressionsLeftInCampaign(withID id: String, by value: Int) -> Campaign? { var newList = allCampaigns.get() guard let index = newList.firstIndex(where: { $0.id == id }) else { - Logger.debug("Campaign \(id) could not be updated - not found in the repository") + IAMLogger.debug("Campaign \(id) could not be updated - not found in the repository") return nil } let campaign = newList[index] diff --git a/Sources/RInAppMessaging/Router.swift b/Sources/RInAppMessaging/Router.swift index 76e4f601..5c301e3e 100644 --- a/Sources/RInAppMessaging/Router.swift +++ b/Sources/RInAppMessaging/Router.swift @@ -109,13 +109,13 @@ internal class Router: RouterType, ViewListenerObserver { let campaignViewType = campaign.data.type guard campaignViewType != .invalid else { - Logger.debug("Error: Campaign view type is invalid") + IAMLogger.debug("Error: Campaign view type is invalid") completion(true) return } guard let presenter = getPresenter(for: campaignViewType) else { - Logger.debug("Error: \(campaignViewType) couldn't be resolved") + IAMLogger.debug("Error: \(campaignViewType) couldn't be resolved") assertionFailure() completion(true) return @@ -154,14 +154,14 @@ internal class Router: RouterType, ViewListenerObserver { } presenter = resolvedPresenter default: - Logger.debug("Error: Campaign view type is not supported") + IAMLogger.debug("Error: Campaign view type is not supported") } return presenter } private func resolvePresenter(type: T.Type) -> T? { guard let presenter = self.dependencyManager.resolve(type: type) else { - Logger.debug("Error: \(type) couldn't be resolved") + IAMLogger.debug("Error: \(type) couldn't be resolved") return nil } return presenter @@ -184,7 +184,7 @@ internal class Router: RouterType, ViewListenerObserver { presenter.campaign = campaign view = { SlideUpView(presenter: presenter) } case .invalid, .html: - Logger.debug("Error: Campaign view type not supported") + IAMLogger.debug("Error: Campaign view type not supported") } return view } @@ -199,7 +199,7 @@ internal class Router: RouterType, ViewListenerObserver { completion: @escaping (_ cancelled: Bool) -> Void) { guard let presenter = self.dependencyManager.resolve(type: TooltipPresenterType.self) else { - Logger.debug("Error: TooltipPresenterType couldn't be resolved") + IAMLogger.debug("Error: TooltipPresenterType couldn't be resolved") assertionFailure() return } @@ -254,7 +254,7 @@ internal class Router: RouterType, ViewListenerObserver { confirmation: @escaping @autoclosure () -> Bool, completion: @escaping (_ cancelled: Bool) -> Void) { guard let presenter = self.dependencyManager.resolve(type: TooltipPresenterType.self) else { - Logger.debug("Error: TooltipPresenterType couldn't be resolved") + IAMLogger.debug("Error: TooltipPresenterType couldn't be resolved") assertionFailure() return } diff --git a/Sources/RInAppMessaging/Services/ConfigurationService.swift b/Sources/RInAppMessaging/Services/ConfigurationService.swift index 9f6c5238..adda1a18 100644 --- a/Sources/RInAppMessaging/Services/ConfigurationService.swift +++ b/Sources/RInAppMessaging/Services/ConfigurationService.swift @@ -67,7 +67,7 @@ internal struct ConfigurationService: ConfigurationServiceType, HttpRequestable return .success(response.data) } catch { let description = "Failed to parse json" - Logger.debug("\(description): \(error)") + IAMLogger.debug("\(description): \(error)") return .failure(error) } } @@ -78,7 +78,7 @@ extension ConfigurationService { private func getConfigRequest() throws -> GetConfigRequest { guard let appVersion = bundleInfo.appVersion, let appId = bundleInfo.applicationId else { - Logger.debug("failed creating a request body") + IAMLogger.debug("failed creating a request body") throw RequestError.missingMetadata } @@ -96,7 +96,7 @@ extension ConfigurationService { var headerBuilder = HeaderAttributesBuilder() if !headerBuilder.addSubscriptionID(configurationRepository: configurationRepository) { - Logger.debug("Info.plist must contain a valid InAppMessagingAppSubscriptionID") + IAMLogger.debug("Info.plist must contain a valid InAppMessagingAppSubscriptionID") assertionFailure() } @@ -114,7 +114,7 @@ extension ConfigurationService { return .success(URLRequest(url: url)) } catch let error { - Logger.debug("failed creating a request - \(error)") + IAMLogger.debug("failed creating a request - \(error)") return .failure(error) } } diff --git a/Sources/RInAppMessaging/Services/DisplayPermissionService.swift b/Sources/RInAppMessaging/Services/DisplayPermissionService.swift index 38289606..11aa206c 100644 --- a/Sources/RInAppMessaging/Services/DisplayPermissionService.swift +++ b/Sources/RInAppMessaging/Services/DisplayPermissionService.swift @@ -37,7 +37,7 @@ internal class DisplayPermissionService: DisplayPermissionServiceType, HttpReque ] guard let displayPermissionUrl = configurationRepository.getEndpoints()?.displayPermission else { - Logger.debug("error: missing endpoint for DisplayPermissionService") + IAMLogger.debug("error: missing endpoint for DisplayPermissionService") return fallbackResponse } @@ -84,11 +84,11 @@ extension DisplayPermissionService { guard let subscriptionId = configurationRepository.getSubscriptionID(), let appVersion = bundleInfo.appVersion else { - Logger.debug("error while building request body for display permssion - missing metadata") + IAMLogger.debug("error while building request body for display permssion - missing metadata") return .failure(RequestError.missingMetadata) } guard let campaignId = parameters?[Constants.Request.campaignID] as? String else { - Logger.debug("error while building request body for display permssion - unexpected parameters") + IAMLogger.debug("error while building request body for display permssion - unexpected parameters") return .failure(RequestError.missingParameters) } @@ -105,7 +105,7 @@ extension DisplayPermissionService { let body = try JSONEncoder().encode(permissionRequest) return .success(body) } catch { - Logger.debug("failed creating a request body.") + IAMLogger.debug("failed creating a request body.") return .failure(error) } } diff --git a/Sources/RInAppMessaging/Services/MessageMixerService.swift b/Sources/RInAppMessaging/Services/MessageMixerService.swift index bb0805b2..93664974 100644 --- a/Sources/RInAppMessaging/Services/MessageMixerService.swift +++ b/Sources/RInAppMessaging/Services/MessageMixerService.swift @@ -33,7 +33,7 @@ internal class MessageMixerService: MessageMixerServiceType, HttpRequestable { guard let mixerServerUrl = configurationRepository.getEndpoints()?.ping else { let error = "Error retrieving InAppMessaging Mixer Server URL" - Logger.debug(error) + IAMLogger.debug(error) return .failure(.invalidConfiguration) } @@ -68,7 +68,7 @@ internal class MessageMixerService: MessageMixerServiceType, HttpRequestable { return .success(response) } catch { let description = "Failed to parse json" - Logger.debug("\(description): \(error)") + IAMLogger.debug("\(description): \(error)") return .failure(error) } } @@ -80,7 +80,7 @@ extension MessageMixerService { func buildHttpBody(with parameters: [String: Any]?) -> Result { guard let appVersion = bundleInfo.appVersion else { - Logger.debug("failed creating a request body") + IAMLogger.debug("failed creating a request body") return .failure(RequestError.missingMetadata) } @@ -94,7 +94,7 @@ extension MessageMixerService { let body = try JSONEncoder().encode(pingRequest) return .success(body) } catch let error { - Logger.debug("failed creating a request body - \(error)") + IAMLogger.debug("failed creating a request body - \(error)") return .failure(error) } } diff --git a/Sources/RInAppMessaging/UserDataCache.swift b/Sources/RInAppMessaging/UserDataCache.swift index c4f2a867..d7b973eb 100644 --- a/Sources/RInAppMessaging/UserDataCache.swift +++ b/Sources/RInAppMessaging/UserDataCache.swift @@ -45,7 +45,7 @@ internal class UserDataCache: UserDataCacheable { cachedContainers = decodedData } catch { cachedContainers = [:] - Logger.debug("UserDataCache decoding failed! \(error)") + IAMLogger.debug("UserDataCache decoding failed! \(error)") Environment.isUnitTestEnvironment ? () : assertionFailure() } } else { @@ -97,7 +97,7 @@ internal class UserDataCache: UserDataCacheable { let encodedData = try JSONEncoder().encode(cachedContainers) userDefaults.set(encodedData, forKey: persistedDataKey) } catch { - Logger.debug("UserDataCache encoding failed! \(error)") + IAMLogger.debug("UserDataCache encoding failed! \(error)") assertionFailure() } } diff --git a/Sources/RInAppMessaging/Utilities/CommonUtility.swift b/Sources/RInAppMessaging/Utilities/CommonUtility.swift index ebf88370..86266af5 100644 --- a/Sources/RInAppMessaging/Utilities/CommonUtility.swift +++ b/Sources/RInAppMessaging/Utilities/CommonUtility.swift @@ -1,4 +1,5 @@ import Foundation +import os #if SWIFT_PACKAGE import protocol RSDKUtilsMain.Lockable @@ -99,7 +100,7 @@ internal struct CommonUtility { return CustomAttribute(withKeyName: attribute.name, withTimeInMilliValue: value) } - Logger.debug("Failed converting value \(attribute.value) to \(attribute.type)") + IAMLogger.debug("Failed converting value \(attribute.value) to \(attribute.type)") return nil } @@ -126,3 +127,31 @@ internal enum Logger { #endif } } + +extension OSLog { + static let sdk = OSLog(category: "RInAppMessaging SDK") + + private convenience init(category: String, bundle: Bundle = Bundle(for: IAMLogger.self)) { + let identifier = bundle.infoDictionary?["CFBundleIdentifier"] as? String + self.init(subsystem: (identifier ?? "").appending(".logs"), category: category) + } +} + +internal class IAMLogger { + // Debug Logging + static func debug(_ message: String) { + #if DEBUG + print("InAppMessaging: " + message) + #else + os_log("%s", log: OSLog.sdk, type: .error, message) + #endif + } + + static func debugLog(_ message: String) { + #if DEBUG + // do nothing + #else + os_log("%s", log: OSLog.sdk, type: .error, message) + #endif + } + } diff --git a/Sources/RInAppMessaging/Utilities/TriggerAttributesValidator.swift b/Sources/RInAppMessaging/Utilities/TriggerAttributesValidator.swift index b07a9cdf..a23dd8f8 100644 --- a/Sources/RInAppMessaging/Utilities/TriggerAttributesValidator.swift +++ b/Sources/RInAppMessaging/Utilities/TriggerAttributesValidator.swift @@ -58,7 +58,7 @@ internal struct TriggerAttributesValidator { switch valueType { case .invalid: - Logger.debug("Error - invalid attribute value") + IAMLogger.debug("Error - invalid attribute value") return false case .string: @@ -116,7 +116,7 @@ internal struct TriggerAttributesValidator { ) } - Logger.debug("Error converting values") + IAMLogger.debug("Error converting values") return false } } diff --git a/Sources/RInAppMessaging/Views/Presenters/SlideUpViewPresenter.swift b/Sources/RInAppMessaging/Views/Presenters/SlideUpViewPresenter.swift index 0715deae..398b0597 100644 --- a/Sources/RInAppMessaging/Views/Presenters/SlideUpViewPresenter.swift +++ b/Sources/RInAppMessaging/Views/Presenters/SlideUpViewPresenter.swift @@ -17,7 +17,7 @@ internal class SlideUpViewPresenter: BaseViewPresenter, SlideUpViewPresenterType guard let messageBody = messagePayload.messageBody, let direction = campaign.data.messagePayload.messageSettings.displaySettings.slideFrom else { - Logger.debug("Error constructing a SlideUpView.") + IAMLogger.debug("Error constructing a SlideUpView.") view?.dismiss() return } diff --git a/Sources/RInAppMessaging/Views/SlideUpView.swift b/Sources/RInAppMessaging/Views/SlideUpView.swift index d5bb23b2..8d89f122 100644 --- a/Sources/RInAppMessaging/Views/SlideUpView.swift +++ b/Sources/RInAppMessaging/Views/SlideUpView.swift @@ -65,7 +65,7 @@ internal class SlideUpView: UIView, SlideUpViewType { func animateOnShow(completion: @escaping () -> Void) { guard [leftConstraint, bottomConstraint, rightConstraint].allSatisfy({ $0 != nil }) else { - Logger.debug("Error: Constraints not set up. Cancelling animation") + IAMLogger.debug("Error: Constraints not set up. Cancelling animation") assertionFailure() completion() return @@ -81,7 +81,7 @@ internal class SlideUpView: UIView, SlideUpViewType { leftConstraint.constant = frame.width rightConstraint.constant = -frame.width case .top: - Logger.debug("Error: Unsupported slide direction (top)") + IAMLogger.debug("Error: Unsupported slide direction (top)") } superview?.layoutIfNeeded() From 76514e8dac9736151d40194cdc1b14d12d11a514 Mon Sep 17 00:00:00 2001 From: Soumen Rautray Date: Sun, 6 Oct 2024 23:25:53 +0530 Subject: [PATCH 5/9] chore: refactor logs (RMCCX-6788) --- .../InAppMessagingInteractor.swift | 3 +++ .../RInAppMessaging/InAppMessagingModule.swift | 3 --- Sources/RInAppMessaging/RInAppMessaging.swift | 3 ++- .../Utilities/CommonUtility.swift | 18 ++---------------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Sources/RInAppMessaging/InAppMessagingInteractor.swift b/Sources/RInAppMessaging/InAppMessagingInteractor.swift index 2150d00c..f777df57 100644 --- a/Sources/RInAppMessaging/InAppMessagingInteractor.swift +++ b/Sources/RInAppMessaging/InAppMessagingInteractor.swift @@ -102,6 +102,7 @@ final class InAppMessagingInteractor { } func logEvent(_ event: Event) { + IAMLogger.debugLog("logEvent: \(event)") let didLogEvent = iamModule?.logEvent(event) == true if !didLogEvent { eventBuffer.append(event) @@ -109,10 +110,12 @@ final class InAppMessagingInteractor { } func closeMessage(clearQueuedCampaigns: Bool) { + IAMLogger.debugLog("closeMessage: \(clearQueuedCampaigns)") iamModule?.closeMessage(clearQueuedCampaigns: clearQueuedCampaigns) } func closeTooltip(with uiElementIdentifier: String) { + IAMLogger.debugLog("closeTooltip: \(uiElementIdentifier)") iamModule?.closeTooltip(with: uiElementIdentifier) } diff --git a/Sources/RInAppMessaging/InAppMessagingModule.swift b/Sources/RInAppMessaging/InAppMessagingModule.swift index 075153c9..6cfee8ad 100644 --- a/Sources/RInAppMessaging/InAppMessagingModule.swift +++ b/Sources/RInAppMessaging/InAppMessagingModule.swift @@ -82,7 +82,6 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, guard isInitialized else { return false } - IAMLogger.debugLog("logEvent: \(event)") checkUserChanges() eventMatcher.matchAndStore(event: event) campaignTriggerAgent.validateAndTriggerCampaigns() @@ -105,7 +104,6 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, } func closeMessage(clearQueuedCampaigns: Bool) { - IAMLogger.debugLog("closeMessage: \(clearQueuedCampaigns)") if clearQueuedCampaigns { readyCampaignDispatcher.resetQueue() } @@ -113,7 +111,6 @@ internal class InAppMessagingModule: ErrorDelegate, CampaignDispatcherDelegate, } func closeTooltip(with uiElementIdentifier: String) { - IAMLogger.debugLog("closeTooltip: \(uiElementIdentifier)") router.discardDisplayedTooltip(with: uiElementIdentifier) } diff --git a/Sources/RInAppMessaging/RInAppMessaging.swift b/Sources/RInAppMessaging/RInAppMessaging.swift index e81a5b34..45277ab7 100644 --- a/Sources/RInAppMessaging/RInAppMessaging.swift +++ b/Sources/RInAppMessaging/RInAppMessaging.swift @@ -83,7 +83,6 @@ import RSDKUtils @objc public static func configure(subscriptionID: String? = nil, configurationURL: String? = nil, enableTooltipFeature: Bool = false) { - IAMLogger.debugLog("configure") guard verifyRMCEnvironment(subscriptionID: subscriptionID), !isInitialized else { let description = "⚠️ SDK configure request rejected. Initialization status: \(isInitialized)" let error = NSError.iamError(description: description) @@ -92,6 +91,8 @@ import RSDKUtils return } + IAMLogger.debugLog("configure - device:\(UIDevice.deviceID ?? ""), appVer:\(bundleInfo.appVersion ?? ""), rmcVer: \(bundleInfo.rmcSdkVersion ?? "")") + let config = InAppMessagingModuleConfiguration( configURLString: configurationURL ?? BundleInfo.inAppConfigurationURL, subscriptionID: sanitizeSubscriptionID(subscriptionID) ?? BundleInfo.inAppSubscriptionId, diff --git a/Sources/RInAppMessaging/Utilities/CommonUtility.swift b/Sources/RInAppMessaging/Utilities/CommonUtility.swift index 86266af5..99156a70 100644 --- a/Sources/RInAppMessaging/Utilities/CommonUtility.swift +++ b/Sources/RInAppMessaging/Utilities/CommonUtility.swift @@ -114,20 +114,6 @@ internal struct CommonUtility { } } -internal enum Logger { - static func debug(_ value: Any) { - #if DEBUG - print("InAppMessaging: " + String(describing: value)) - #endif - } - - static func debug(_ message: String) { - #if DEBUG - print("InAppMessaging: " + message) - #endif - } -} - extension OSLog { static let sdk = OSLog(category: "RInAppMessaging SDK") @@ -143,7 +129,7 @@ internal class IAMLogger { #if DEBUG print("InAppMessaging: " + message) #else - os_log("%s", log: OSLog.sdk, type: .error, message) + os_log("%{PUBLIC}@", log: OSLog.sdk, type: .error, message) #endif } @@ -151,7 +137,7 @@ internal class IAMLogger { #if DEBUG // do nothing #else - os_log("%s", log: OSLog.sdk, type: .error, message) + os_log("%{PUBLIC}@", log: OSLog.sdk, type: .debug, message) #endif } } From 476758a3c34f0cd3ab3b1fc2288348048db96d23 Mon Sep 17 00:00:00 2001 From: Soumen Rautray Date: Sun, 6 Oct 2024 23:46:04 +0530 Subject: [PATCH 6/9] chore: fix bitrise error (RMCCX-6877) --- Sources/RInAppMessaging/RInAppMessaging.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/RInAppMessaging/RInAppMessaging.swift b/Sources/RInAppMessaging/RInAppMessaging.swift index 45277ab7..810e1747 100644 --- a/Sources/RInAppMessaging/RInAppMessaging.swift +++ b/Sources/RInAppMessaging/RInAppMessaging.swift @@ -1,4 +1,4 @@ -import Foundation +import UIKit import struct UserNotifications.UNAuthorizationOptions #if SWIFT_PACKAGE From d9c2343f9e797962b2269a6cf7c4d0d212bf283c Mon Sep 17 00:00:00 2001 From: Soumen Rautray Date: Mon, 7 Oct 2024 00:23:17 +0530 Subject: [PATCH 7/9] chore: test public logs (RMCCX-6877) --- Sources/RInAppMessaging/Utilities/CommonUtility.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/RInAppMessaging/Utilities/CommonUtility.swift b/Sources/RInAppMessaging/Utilities/CommonUtility.swift index 99156a70..6b0c39c8 100644 --- a/Sources/RInAppMessaging/Utilities/CommonUtility.swift +++ b/Sources/RInAppMessaging/Utilities/CommonUtility.swift @@ -129,7 +129,7 @@ internal class IAMLogger { #if DEBUG print("InAppMessaging: " + message) #else - os_log("%{PUBLIC}@", log: OSLog.sdk, type: .error, message) + os_log("%{public}s", log: OSLog.sdk, type: .info, message) #endif } @@ -137,7 +137,7 @@ internal class IAMLogger { #if DEBUG // do nothing #else - os_log("%{PUBLIC}@", log: OSLog.sdk, type: .debug, message) + os_log("%{public}s", log: OSLog.sdk, type: .info, message) #endif } } From f80f21f39a9fa39b2b056bc8d035645ee0b4766e Mon Sep 17 00:00:00 2001 From: Soumen Rautray Date: Mon, 7 Oct 2024 00:45:28 +0530 Subject: [PATCH 8/9] chore: refactor code (RMCCX-6877) --- Sources/RInAppMessaging/InAppMessagingInteractor.swift | 2 +- Sources/RInAppMessaging/Utilities/CommonUtility.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/RInAppMessaging/InAppMessagingInteractor.swift b/Sources/RInAppMessaging/InAppMessagingInteractor.swift index f777df57..4623a4fe 100644 --- a/Sources/RInAppMessaging/InAppMessagingInteractor.swift +++ b/Sources/RInAppMessaging/InAppMessagingInteractor.swift @@ -102,7 +102,7 @@ final class InAppMessagingInteractor { } func logEvent(_ event: Event) { - IAMLogger.debugLog("logEvent: \(event)") + IAMLogger.debugLog("logEvent: \(event.type.name)") let didLogEvent = iamModule?.logEvent(event) == true if !didLogEvent { eventBuffer.append(event) diff --git a/Sources/RInAppMessaging/Utilities/CommonUtility.swift b/Sources/RInAppMessaging/Utilities/CommonUtility.swift index 6b0c39c8..ba4d5fe4 100644 --- a/Sources/RInAppMessaging/Utilities/CommonUtility.swift +++ b/Sources/RInAppMessaging/Utilities/CommonUtility.swift @@ -129,7 +129,7 @@ internal class IAMLogger { #if DEBUG print("InAppMessaging: " + message) #else - os_log("%{public}s", log: OSLog.sdk, type: .info, message) + os_log("%s", log: OSLog.sdk, type: .info, message) #endif } @@ -137,7 +137,7 @@ internal class IAMLogger { #if DEBUG // do nothing #else - os_log("%{public}s", log: OSLog.sdk, type: .info, message) + os_log("%s", log: OSLog.sdk, type: .info, message) #endif } } From b5857b5ec802c5fb3282d625748770a0dc66ec40 Mon Sep 17 00:00:00 2001 From: Soumen Rautray Date: Mon, 7 Oct 2024 01:08:13 +0530 Subject: [PATCH 9/9] chore: add additional logs (RMCCX-6788) --- Sources/RInAppMessaging/InAppMessagingInteractor.swift | 1 + Sources/RInAppMessaging/RInAppMessaging.swift | 2 +- Sources/RInAppMessaging/Utilities/CommonUtility.swift | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/RInAppMessaging/InAppMessagingInteractor.swift b/Sources/RInAppMessaging/InAppMessagingInteractor.swift index 4623a4fe..3c92cfb4 100644 --- a/Sources/RInAppMessaging/InAppMessagingInteractor.swift +++ b/Sources/RInAppMessaging/InAppMessagingInteractor.swift @@ -102,6 +102,7 @@ final class InAppMessagingInteractor { } func logEvent(_ event: Event) { + IAMLogger.debugLog("logEvent called") IAMLogger.debugLog("logEvent: \(event.type.name)") let didLogEvent = iamModule?.logEvent(event) == true if !didLogEvent { diff --git a/Sources/RInAppMessaging/RInAppMessaging.swift b/Sources/RInAppMessaging/RInAppMessaging.swift index 810e1747..dee8aa90 100644 --- a/Sources/RInAppMessaging/RInAppMessaging.swift +++ b/Sources/RInAppMessaging/RInAppMessaging.swift @@ -90,7 +90,7 @@ import RSDKUtils errorCallback?(error) return } - + IAMLogger.debugLog("configure called") IAMLogger.debugLog("configure - device:\(UIDevice.deviceID ?? ""), appVer:\(bundleInfo.appVersion ?? ""), rmcVer: \(bundleInfo.rmcSdkVersion ?? "")") let config = InAppMessagingModuleConfiguration( diff --git a/Sources/RInAppMessaging/Utilities/CommonUtility.swift b/Sources/RInAppMessaging/Utilities/CommonUtility.swift index ba4d5fe4..4fa1255f 100644 --- a/Sources/RInAppMessaging/Utilities/CommonUtility.swift +++ b/Sources/RInAppMessaging/Utilities/CommonUtility.swift @@ -129,7 +129,7 @@ internal class IAMLogger { #if DEBUG print("InAppMessaging: " + message) #else - os_log("%s", log: OSLog.sdk, type: .info, message) + os_log("%{PUBLIC}@", log: OSLog.sdk, type: .default, message) #endif } @@ -137,7 +137,7 @@ internal class IAMLogger { #if DEBUG // do nothing #else - os_log("%s", log: OSLog.sdk, type: .info, message) + os_log("%{PUBLIC}@", log: OSLog.sdk, type: .default, message) #endif } }