From 3e3f267e78fa808a7239b8799eb5243266716389 Mon Sep 17 00:00:00 2001 From: Akylbek Utekeshev Date: Tue, 17 Oct 2023 23:51:05 +0600 Subject: [PATCH 1/4] MBX-2750 LogLevelError by default --- Mindbox/Mindbox.swift | 2 +- MindboxLogger/Shared/MBLogger.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Mindbox/Mindbox.swift b/Mindbox/Mindbox.swift index d0524f2d..1fc5f48b 100644 --- a/Mindbox/Mindbox.swift +++ b/Mindbox/Mindbox.swift @@ -29,7 +29,7 @@ public class Mindbox: NSObject { - In __RELEASE__ schema logs writes _async_ on queue with __qos: .utility__ - Warninig: - By default _logLevel_: __.none__ + By default _logLevel_: __.error__ */ public static let logger = MBLogger.shared diff --git a/MindboxLogger/Shared/MBLogger.swift b/MindboxLogger/Shared/MBLogger.swift index 4739b766..fa1c9e75 100644 --- a/MindboxLogger/Shared/MBLogger.swift +++ b/MindboxLogger/Shared/MBLogger.swift @@ -25,7 +25,7 @@ public class MBLogger { - Note: `.error` by default; `.none` for disable logging */ - public var logLevel: LogLevel = .debug + public var logLevel: LogLevel = .error private enum ExecutionMethod { case sync(lock: NSRecursiveLock) From 4f4862d2291b27b6619b241123cf329ffba7c53d Mon Sep 17 00:00:00 2001 From: Akylbek Utekeshev Date: Mon, 30 Oct 2023 17:18:08 +0600 Subject: [PATCH 2/4] MBX-2864 mindboxPerformAndWait --- Mindbox/Database/MBDatabaseRepository.swift | 20 +++++++++---------- .../NSManagedObjectContext+Extension.swift | 2 +- .../MBLoggerCoreDataManager.swift | 12 +++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Mindbox/Database/MBDatabaseRepository.swift b/Mindbox/Database/MBDatabaseRepository.swift index e92578c0..bcb008c1 100644 --- a/Mindbox/Database/MBDatabaseRepository.swift +++ b/Mindbox/Database/MBDatabaseRepository.swift @@ -68,7 +68,7 @@ class MBDatabaseRepository { // MARK: - CRUD operations func create(event: Event) throws { - try context.performAndWait { + try context.mindboxPerformAndWait { let entity = CDEvent(context: context) entity.transactionId = event.transactionId entity.timestamp = Date().timeIntervalSince1970 @@ -80,7 +80,7 @@ class MBDatabaseRepository { } func read(by transactionId: String) throws -> CDEvent? { - try context.performAndWait { + try context.mindboxPerformAndWait { Logger.common(message: "Reading event with transactionId: \(transactionId)", level: .info, category: .database) let request: NSFetchRequest = CDEvent.fetchRequest(by: transactionId) guard let entity = try findEvent(by: request) else { @@ -93,7 +93,7 @@ class MBDatabaseRepository { } func update(event: Event) throws { - try context.performAndWait { + try context.mindboxPerformAndWait { Logger.common(message: "Updating event with transactionId: \(event.transactionId)", level: .info, category: .database) let request: NSFetchRequest = CDEvent.fetchRequest(by: event.transactionId) guard let entity = try findEvent(by: request) else { @@ -106,7 +106,7 @@ class MBDatabaseRepository { } func delete(event: Event) throws { - try context.performAndWait { + try context.mindboxPerformAndWait { Logger.common(message: "Deleting event with transactionId: \(event.transactionId)", level: .info, category: .database) let request = CDEvent.fetchRequest(by: event.transactionId) guard let entity = try findEvent(by: request) else { @@ -119,7 +119,7 @@ class MBDatabaseRepository { } func query(fetchLimit: Int, retryDeadline: TimeInterval = 60) throws -> [Event] { - try context.performAndWait { + try context.mindboxPerformAndWait { Logger.common(message: "Quering events with fetchLimit: \(fetchLimit)", level: .info, category: .database) let request: NSFetchRequest = CDEvent.fetchRequestForSend(lifeLimitDate: lifeLimitDate, retryDeadLine: retryDeadline) request.fetchLimit = fetchLimit @@ -149,7 +149,7 @@ class MBDatabaseRepository { func countDeprecatedEvents() throws -> Int { let context = persistentContainer.newBackgroundContext() let request: NSFetchRequest = CDEvent.deprecatedEventsFetchRequest(lifeLimitDate: lifeLimitDate) - return try context.performAndWait { + return try context.mindboxPerformAndWait { Logger.common(message: "Counting deprecated elements", level: .info, category: .database) do { let count = try context.count(for: request) @@ -167,7 +167,7 @@ class MBDatabaseRepository { let eraseRequest = NSBatchDeleteRequest(fetchRequest: fetchRequest) infoUpdateVersion = nil installVersion = nil - try context.performAndWait { + try context.mindboxPerformAndWait { try context.execute(eraseRequest) try saveEvent(withContext: context) try countEvents() @@ -177,7 +177,7 @@ class MBDatabaseRepository { @discardableResult func countEvents() throws -> Int { let request: NSFetchRequest = CDEvent.countEventsFetchRequest() - return try context.performAndWait { + return try context.mindboxPerformAndWait { Logger.common(message: "Events count limit: \(limit)", level: .info, category: .database) Logger.common(message: "Counting events...", level: .info, category: .database) do { @@ -206,7 +206,7 @@ class MBDatabaseRepository { } private func delete(by request: NSFetchRequest, withContext context: NSManagedObjectContext) throws { - try context.performAndWait { + try context.mindboxPerformAndWait { Logger.common(message: "Finding elements to remove", level: .info, category: .database) let events = try context.fetch(request) @@ -275,7 +275,7 @@ private extension MBDatabaseRepository { store.metadata[key.rawValue] = value persistentContainer.persistentStoreCoordinator.setMetadata(store.metadata, for: store) do { - try context.performAndWait { + try context.mindboxPerformAndWait { try saveContext(context) Logger.common(message: "Did save metadata of \(key.rawValue) to: \(String(describing: value))", level: .info, category: .database) } } catch { diff --git a/MindboxLogger/Shared/Extensions/NSManagedObjectContext+Extension.swift b/MindboxLogger/Shared/Extensions/NSManagedObjectContext+Extension.swift index ac897371..842e1712 100644 --- a/MindboxLogger/Shared/Extensions/NSManagedObjectContext+Extension.swift +++ b/MindboxLogger/Shared/Extensions/NSManagedObjectContext+Extension.swift @@ -10,7 +10,7 @@ import Foundation import CoreData public extension NSManagedObjectContext { - func performAndWait(_ block: () throws -> T) rethrows -> T { + func mindboxPerformAndWait(_ block: () throws -> T) rethrows -> T { return try _performAndWaitHelper( fn: performAndWait, execute: block, rescue: { throw $0 } ) diff --git a/MindboxLogger/Shared/LoggerRepository/MBLoggerCoreDataManager.swift b/MindboxLogger/Shared/LoggerRepository/MBLoggerCoreDataManager.swift index 21274eb1..3a2b62de 100644 --- a/MindboxLogger/Shared/LoggerRepository/MBLoggerCoreDataManager.swift +++ b/MindboxLogger/Shared/LoggerRepository/MBLoggerCoreDataManager.swift @@ -75,7 +75,7 @@ public class MBLoggerCoreDataManager { try delete() } - try self.context.performAndWait { + try self.context.mindboxPerformAndWait { let entity = CDLogMessage(context: self.context) entity.message = message entity.timestamp = timestamp @@ -84,7 +84,7 @@ public class MBLoggerCoreDataManager { } public func getFirstLog() throws -> LogMessage? { - try context.performAndWait { + try context.mindboxPerformAndWait { let fetchRequest = NSFetchRequest(entityName: Constants.model) fetchRequest.predicate = NSPredicate(value: true) fetchRequest.sortDescriptors = [NSSortDescriptor(key: "timestamp", ascending: true)] @@ -100,7 +100,7 @@ public class MBLoggerCoreDataManager { } public func getLastLog() throws -> LogMessage? { - try context.performAndWait { + try context.mindboxPerformAndWait { let fetchRequest = NSFetchRequest(entityName: Constants.model) fetchRequest.predicate = NSPredicate(value: true) fetchRequest.sortDescriptors = [NSSortDescriptor(key: "timestamp", ascending: false)] @@ -116,7 +116,7 @@ public class MBLoggerCoreDataManager { } public func fetchPeriod(_ from: Date, _ to: Date) throws -> [LogMessage] { - try context.performAndWait { + try context.mindboxPerformAndWait { let fetchRequest = NSFetchRequest(entityName: Constants.model) fetchRequest.predicate = NSPredicate(format: "timestamp >= %@ AND timestamp <= %@", from as NSDate, @@ -132,7 +132,7 @@ public class MBLoggerCoreDataManager { } public func delete() throws { - try context.performAndWait { + try context.mindboxPerformAndWait { let request = NSFetchRequest(entityName: Constants.model) let count = try context.count(for: request) let limit: Double = (Double(count) * 0.1).rounded() // 10% percent of all records should be removed @@ -152,7 +152,7 @@ public class MBLoggerCoreDataManager { } public func deleteAll() throws { - try context.performAndWait { + try context.mindboxPerformAndWait { let request = NSFetchRequest(entityName: Constants.model) request.includesPropertyValues = false let results = try context.fetch(request) From 62494e113cf2359230d50730bba85f02fc019362 Mon Sep 17 00:00:00 2001 From: Akylbek Utekeshev Date: Tue, 31 Oct 2023 17:17:51 +0600 Subject: [PATCH 3/4] Bump SDK version to 2.8.1 --- Mindbox.podspec | 2 +- MindboxNotifications.podspec | 2 +- SDKVersionProvider/SDKVersionProvider.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Mindbox.podspec b/Mindbox.podspec index f9274af9..88d67b4f 100644 --- a/Mindbox.podspec +++ b/Mindbox.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "Mindbox" - spec.version = "2.8.0" + spec.version = "2.8.1" spec.summary = "SDK for integration with Mindbox" spec.description = "This library allows you to integrate data transfer to Mindbox Marketing Cloud" spec.homepage = "https://github.com/mindbox-cloud/ios-sdk" diff --git a/MindboxNotifications.podspec b/MindboxNotifications.podspec index 79169eea..3e0fe4b4 100644 --- a/MindboxNotifications.podspec +++ b/MindboxNotifications.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "MindboxNotifications" - spec.version = "2.8.0" + spec.version = "2.8.1" spec.summary = "SDK for integration notifications with Mindbox" spec.description = "This library allows you to integrate notifications and transfer them to Mindbox Marketing Cloud" spec.homepage = "https://github.com/mindbox-cloud/ios-sdk" diff --git a/SDKVersionProvider/SDKVersionProvider.swift b/SDKVersionProvider/SDKVersionProvider.swift index d752a873..b6f2ae99 100644 --- a/SDKVersionProvider/SDKVersionProvider.swift +++ b/SDKVersionProvider/SDKVersionProvider.swift @@ -8,5 +8,5 @@ import Foundation public class SDKVersionProvider { - public static let sdkVersion = "2.8.0" + public static let sdkVersion = "2.8.1" } From dcc56d876455f218d949d57ec657c6c104913853 Mon Sep 17 00:00:00 2001 From: Akylbek Utekeshev Date: Tue, 31 Oct 2023 17:25:34 +0600 Subject: [PATCH 4/4] Version UP 2.8.1 --- Mindbox.podspec | 2 +- MindboxLogger.podspec | 2 +- MindboxNotifications.podspec | 2 +- SDKVersionProvider/SDKVersionConfig.xcconfig | 2 +- git-release-branch-create.sh | 18 ++++++++++++++---- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Mindbox.podspec b/Mindbox.podspec index 88d67b4f..89851407 100644 --- a/Mindbox.podspec +++ b/Mindbox.podspec @@ -14,6 +14,6 @@ Pod::Spec.new do |spec| 'Mindbox' => ['Mindbox/**/*.xcassets', 'Mindbox/**/*.xcdatamodeld'] } spec.swift_version = "5" - spec.dependency 'MindboxLogger', '0.0.4' + spec.dependency 'MindboxLogger', '0.0.5' end diff --git a/MindboxLogger.podspec b/MindboxLogger.podspec index 591bae5d..f774c9be 100644 --- a/MindboxLogger.podspec +++ b/MindboxLogger.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "MindboxLogger" - spec.version = "0.0.4" + spec.version = "0.0.5" spec.summary = "SDK for utilities to work with Mindbox" spec.description = "-" spec.homepage = "https://github.com/mindbox-cloud/ios-sdk" diff --git a/MindboxNotifications.podspec b/MindboxNotifications.podspec index 3e0fe4b4..b8232141 100644 --- a/MindboxNotifications.podspec +++ b/MindboxNotifications.podspec @@ -11,6 +11,6 @@ Pod::Spec.new do |spec| spec.source_files = "MindboxNotifications/**/*.{swift}", "SDKVersionProvider/**/*.{swift}" spec.exclude_files = "Classes/Exclude" spec.swift_version = "5" - spec.dependency 'MindboxLogger', '0.0.4' + spec.dependency 'MindboxLogger', '0.0.5' end diff --git a/SDKVersionProvider/SDKVersionConfig.xcconfig b/SDKVersionProvider/SDKVersionConfig.xcconfig index 2f2ba19a..76fd1e39 100644 --- a/SDKVersionProvider/SDKVersionConfig.xcconfig +++ b/SDKVersionProvider/SDKVersionConfig.xcconfig @@ -1 +1 @@ -MARKETING_VERSION = 2.8.0 +MARKETING_VERSION = 2.8.1 diff --git a/git-release-branch-create.sh b/git-release-branch-create.sh index f90b362f..95a42a70 100755 --- a/git-release-branch-create.sh +++ b/git-release-branch-create.sh @@ -29,11 +29,21 @@ git checkout $branch_name #Add changelog to the index and create a commit podspec_file="Mindbox.podspec" notifivation_podspec_file="MindboxNotifications.podspec" -sdkversionprovider_file="SDKVersionProvider.swift" +sdkversionprovider_file="SDKVersionProvider/SDKVersionProvider.swift" +sdkversionconfig_file="SDKVersionProvider/SDKVersionConfig.xcconfig" current_version=$(grep -E '^\s+spec.version\s+=' "$podspec_file" | cut -d'"' -f2) -sed -i '' "s/^ spec.version = ."$/ spec.version = "$version"/" $podspec_file -sed -i '' "s/^ spec.version = ."$/ spec.version = "$version"/" $notifivation_podspec_file -sed -i '' "s/public static let sdkVersion = ".*"$/public static let sdkVersion = "$version"/" $sdkversionprovider_file + +# Обновление версии в Mindbox.podspec +sed -i '' "s/^[[:space:]]*spec.version[[:space:]]*=[[:space:]]*\".*\"$/ spec.version = \"$version\"/" $podspec_file + +# Обновление версии в MindboxNotifications.podspec +sed -i '' "s/^[[:space:]]*spec.version[[:space:]]*=[[:space:]]*\".*\"$/ spec.version = \"$version\"/" $notifivation_podspec_file + +# Обновление версии в SDKVersionProvider.swift +sed -i '' "s/public static let sdkVersion = \".*\"$/public static let sdkVersion = \"$version\"/" $sdkversionprovider_file + +# Обновление MARKETING_VERSION в SDKVersionConfig.xcconfig +sed -i '' "s/^MARKETING_VERSION = .*$/MARKETING_VERSION = $version/" $sdkversionconfig_file echo "Bump SDK version from $current_version to $version."