Skip to content

Commit

Permalink
Merge pull request #257 from mindbox-cloud/release/2.8.0-rc
Browse files Browse the repository at this point in the history
Release/2.8.0-rc
  • Loading branch information
AndreyEmtsov authored Aug 31, 2023
2 parents 2fdee57 + 1e51c5f commit 7e6c580
Show file tree
Hide file tree
Showing 82 changed files with 4,049 additions and 1,448 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
unit:
runs-on: macos-12
runs-on: macos-13
steps:
- uses: actions/checkout@v3

Expand All @@ -37,7 +37,7 @@ jobs:

publish:
needs: [unit]
runs-on: macos-11
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- name: Release generation
Expand Down
28 changes: 14 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.768.0)
aws-sdk-core (3.173.0)
aws-partitions (1.786.0)
aws-sdk-core (3.178.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.64.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-kms (1.71.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.122.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-s3 (1.130.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.2)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
Expand Down Expand Up @@ -77,7 +77,7 @@ GEM
highline (~> 2.0.0)
concurrent-ruby (1.2.2)
declarative (0.0.20)
digest-crc (0.6.4)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
Expand All @@ -86,7 +86,7 @@ GEM
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
excon (0.99.0)
excon (0.100.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -116,7 +116,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.7)
fastlane (2.213.0)
fastlane (2.214.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -159,7 +159,7 @@ GEM
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.42.0)
google-apis-androidpublisher_v3 (0.45.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.0)
addressable (~> 2.5, >= 2.5.1)
Expand Down Expand Up @@ -190,7 +190,7 @@ GEM
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.5.2)
googleauth (1.6.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
Expand All @@ -205,7 +205,7 @@ GEM
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
json (2.6.3)
jwt (2.7.0)
jwt (2.7.1)
memoist (0.16.2)
mini_magick (4.12.0)
mini_mime (1.1.2)
Expand Down
2 changes: 1 addition & 1 deletion Mindbox.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "Mindbox"
spec.version = "2.7.0"
spec.version = "2.8.0-rc"
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"
Expand Down
566 changes: 526 additions & 40 deletions Mindbox.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>1.46e-05</real>
<real>0.000015</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>classNames</key>
<dict>
<key>ContentBackgroundLayerActionValidatorTests</key>
<dict>
<key>testPerformanceExample()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.004788</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
</dict>
<key>ContentBackgroundLayerSourceValidatorTests</key>
<dict>
<key>testPerformanceExample()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.005370</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,37 @@
<string>com.apple.platform.iphonesimulator</string>
</dict>
</dict>
<key>9944809D-7C33-4FC7-910D-5FCF8B8E40E0</key>
<dict>
<key>localComputer</key>
<dict>
<key>busSpeedInMHz</key>
<integer>0</integer>
<key>cpuCount</key>
<integer>1</integer>
<key>cpuKind</key>
<string>Apple M1 Pro</string>
<key>cpuSpeedInMHz</key>
<integer>0</integer>
<key>logicalCPUCoresPerPackage</key>
<integer>10</integer>
<key>modelCode</key>
<string>MacBookPro18,3</string>
<key>physicalCPUCoresPerPackage</key>
<integer>10</integer>
<key>platformIdentifier</key>
<string>com.apple.platform.macosx</string>
</dict>
<key>targetArchitecture</key>
<string>arm64</string>
<key>targetDevice</key>
<dict>
<key>modelCode</key>
<string>iPhone15,2</string>
<key>platformIdentifier</key>
<string>com.apple.platform.iphonesimulator</string>
</dict>
</dict>
</dict>
</dict>
</plist>
1 change: 1 addition & 0 deletions Mindbox/DI/DependencyContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protocol DependencyContainer {
var segmentationSevice: SegmentationServiceProtocol { get }
var imageDownloadService: ImageDownloadServiceProtocol { get }
var abTestDeviceMixer: ABTestDeviceMixer { get }
var urlExtractorService: VariantImageUrlExtractorService { get }
}

protocol InstanceFactory {
Expand Down
13 changes: 10 additions & 3 deletions Mindbox/DI/DependencyProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class DependencyProvider: DependencyContainer {
let segmentationSevice: SegmentationServiceProtocol
var imageDownloadService: ImageDownloadServiceProtocol
var abTestDeviceMixer: ABTestDeviceMixer
var urlExtractorService: VariantImageUrlExtractorService

init() throws {
utilitiesFetcher = MBUtilitiesFetcher()
Expand Down Expand Up @@ -61,6 +62,13 @@ final class DependencyProvider: DependencyContainer {
let imageDownloader = URLSessionImageDownloader(persistenceStorage: persistenceStorage)
imageDownloadService = ImageDownloadService(imageDownloader: imageDownloader)
abTestDeviceMixer = ABTestDeviceMixer()
let tracker = InAppMessagesTracker(databaseRepository: databaseRepository)
let displayUseCase = PresentationDisplayUseCase(tracker: tracker)
let actionUseCase = PresentationActionUseCase(tracker: tracker)
let actionHandler = InAppActionHandler(actionUseCase: actionUseCase)
let presentationManager = InAppPresentationManager(actionHandler: actionHandler,
displayUseCase: displayUseCase)
urlExtractorService = VariantImageUrlExtractorService()
inAppMessagesManager = InAppCoreManager(
configManager: InAppConfigurationManager(
inAppConfigAPI: InAppConfigurationAPI(persistenceStorage: persistenceStorage),
Expand All @@ -73,11 +81,10 @@ final class DependencyProvider: DependencyContainer {
persistenceStorage: persistenceStorage,
sdkVersionValidator: sdkVersionValidator,
imageDownloadService: imageDownloadService,
urlExtractorService: urlExtractorService,
abTestDeviceMixer: abTestDeviceMixer),
logsManager: logsManager, sessionStorage: sessionTemporaryStorage),
presentationManager: InAppPresentationManager(
inAppTracker: InAppMessagesTracker(databaseRepository: databaseRepository)
),
presentationManager: presentationManager,
persistenceStorage: persistenceStorage,
sessionStorage: sessionTemporaryStorage
)
Expand Down
18 changes: 18 additions & 0 deletions Mindbox/Extensions/KeyedDecodingContainer+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// KeyedDecodingContainer+Extensions.swift
// Mindbox
//
// Created by vailence on 09.08.2023.
//

import Foundation

extension KeyedDecodingContainer {
public func decodeIfPresentSafely<T: Decodable>(_ type: T.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> T? {
do {
return try decode(T.self, forKey: key)
} catch DecodingError.typeMismatch, DecodingError.keyNotFound {
return nil
}
}
}
32 changes: 32 additions & 0 deletions Mindbox/Extensions/UIColor+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// UIColor+Extensions.swift
// FirebaseCore
//
// Created by vailence on 21.07.2023.
//

import UIKit

extension UIColor {
convenience init(hex: String) {
var cString: String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()

if cString.hasPrefix("#") {
cString.remove(at: cString.startIndex)
}

if cString.count != 6 {
self.init(white: 1.0, alpha: 1.0)
} else {
var rgbValue: UInt32 = 0
Scanner(string: cString).scanHexInt32(&rgbValue)

self.init(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
alpha: CGFloat(1.0)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class InAppConfigutationMapper: InAppConfigurationMapperProtocol {
var filteredInAppsByEvent: [InAppMessageTriggerEvent: [InAppTransitionData]] = [:]
private let sdkVersionValidator: SDKVersionValidator
private let imageDownloadService: ImageDownloadServiceProtocol
private let urlExtractorService: VariantImageUrlExtractorService
private let abTestDeviceMixer: ABTestDeviceMixer

private let dispatchGroup = DispatchGroup()
Expand All @@ -37,6 +38,7 @@ final class InAppConfigutationMapper: InAppConfigurationMapperProtocol {
persistenceStorage: PersistenceStorage,
sdkVersionValidator: SDKVersionValidator,
imageDownloadService: ImageDownloadServiceProtocol,
urlExtractorService: VariantImageUrlExtractorService,
abTestDeviceMixer: ABTestDeviceMixer) {
self.geoService = geoService
self.segmentationService = segmentationService
Expand All @@ -46,6 +48,7 @@ final class InAppConfigutationMapper: InAppConfigurationMapperProtocol {
self.persistenceStorage = persistenceStorage
self.sdkVersionValidator = sdkVersionValidator
self.imageDownloadService = imageDownloadService
self.urlExtractorService = urlExtractorService
self.abTestDeviceMixer = abTestDeviceMixer
}

Expand All @@ -54,7 +57,7 @@ final class InAppConfigutationMapper: InAppConfigurationMapperProtocol {
_ response: ConfigResponse,
_ completion: @escaping (InAppFormData?) -> Void) {
let shownInAppsIds = Set(persistenceStorage.shownInAppsIds ?? [])
let responseInapps = filterInappsByABTests(response.abtests, responseInapps: response.inapps)
let responseInapps = filterInappsByABTests(response.abtests, responseInapps: response.inapps?.elements)
let filteredInapps = filterInappsBySDKVersion(responseInapps, shownInAppsIds: shownInAppsIds)
Logger.common(message: "Shown in-apps ids: [\(shownInAppsIds)]", level: .info, category: .inAppMessages)
if filteredInapps.isEmpty {
Expand Down Expand Up @@ -239,11 +242,9 @@ final class InAppConfigutationMapper: InAppConfigurationMapperProtocol {
}

var inAppsForEvent = filteredInAppsByEvent[triggerEvent] ?? [InAppTransitionData]()
if let inAppFormVariants = inapp.form.variants.first {
if let inAppFormVariants = inapp.form.variants.elements.first {
let formData = InAppTransitionData(inAppId: inapp.id,
imageUrl: inAppFormVariants.imageUrl, // Change this later
redirectUrl: inAppFormVariants.redirectUrl,
intentPayload: inAppFormVariants.intentPayload)
content: inAppFormVariants)
inAppsForEvent.append(formData)
filteredInAppsByEvent[triggerEvent] = inAppsForEvent
}
Expand All @@ -268,13 +269,18 @@ final class InAppConfigutationMapper: InAppConfigurationMapperProtocol {
continue
}

guard let imageValue = self.urlExtractorService.extractImageURL(from: inapp.content) else { continue }

group.enter()
Logger.common(message: "Starting inapp processing. [ID]: \(inapp.inAppId)", level: .debug, category: .inAppMessages)
self.imageDownloadService.downloadImage(withUrl: inapp.imageUrl) { result in

self.imageDownloadService.downloadImage(withUrl: imageValue) { result in
defer { group.leave() }
switch result {
case .success(let image):
formData = InAppFormData(inAppId: inapp.inAppId, image: image, redirectUrl: inapp.redirectUrl, intentPayload: inapp.intentPayload)
formData = InAppFormData(inAppId: inapp.inAppId,
image: image,
content: inapp.content)
shouldDownloadImage = false
case .failure:
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ImageDownloadService: ImageDownloadServiceProtocol {
Logger.common(message: "Failed to download image for url: \(url). \nError: \(error.localizedDescription)", level: .debug, category: .inAppMessages)
if error.code == NSURLErrorTimedOut {
completion(.failure(error))
} else {
completion(.failure(error))
}
} else if let response = response, response.statusCode != 200 {
Logger.common(message: "Image download failed with status code \(response.statusCode). [URL]: \(url)", level: .debug, category: .inAppMessages)
Expand Down
Loading

0 comments on commit 7e6c580

Please sign in to comment.