Skip to content

Commit

Permalink
1.6.29
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Apr 24, 2024
1 parent 9246c13 commit b8ac20a
Show file tree
Hide file tree
Showing 45 changed files with 381 additions and 138 deletions.
50 changes: 37 additions & 13 deletions .github/workflows/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Create AffiseAttributionLib XCFramework
uses: unsignedapps/swift-create-xcframework@v2.3.0
with:
target: "AffiseAttributionLib"
target: "AffiseAttributionLib, AffiseModuleAdvertising, AffiseModuleStatus, AffiseModuleSubscription"

# Release
- name: Release
Expand All @@ -68,17 +68,41 @@ jobs:
asset_name: AffiseAttributionLib-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
asset_content_type: application/zip

# # Upload AffiseModuleStatus
# - name: Upload Release AffiseModuleStatus Framework 🗳
# if: ${{ success() }}
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./AffiseModuleStatus.zip
# asset_name: AffiseModuleStatus-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
# asset_content_type: application/zip
# Upload AffiseModuleStatus
- name: Upload Release AffiseModuleStatus Framework 🗳
if: ${{ success() }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AffiseModuleStatus.zip
asset_name: AffiseModuleStatus-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
asset_content_type: application/zip

# Upload AffiseModuleAdvertising
- name: Upload Release AffiseModuleAdvertising Framework 🗳
if: ${{ success() }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AffiseModuleAdvertising.zip
asset_name: AffiseModuleAdvertising-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
asset_content_type: application/zip

# Upload AffiseModuleSubscription
- name: Upload Release AffiseModuleSubscription Framework 🗳
if: ${{ success() }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AffiseModuleSubscription.zip
asset_name: AffiseModuleSubscription-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
asset_content_type: application/zip

# # Upload AffiseSKAdNetwork
# - name: Upload Release AffiseSKAdNetwork Framework 🗳
Expand All @@ -90,4 +114,4 @@ jobs:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./AffiseSKAdNetwork.zip
# asset_name: AffiseSKAdNetwork-${{ steps.version_tag.outputs.VERSION }}.xcframework.zip
# asset_content_type: application/zip
# asset_content_type: application/zip
2 changes: 1 addition & 1 deletion AffiseAttributionLib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Pod::Spec.new do |spec|
spec.name = "AffiseAttributionLib"
spec.version = ENV['LIB_VERSION'] || "1.6.28"
spec.version = ENV['LIB_VERSION'] || "1.6.29"
spec.summary = "Affise Attribution iOS library"
spec.description = "Affise SDK is a software you can use to collect app usage statistics, device identifiers, deeplink usage, track install referrer."
spec.homepage = "https://github.com/affise/sdk-ios"
Expand Down
28 changes: 17 additions & 11 deletions AffiseAttributionLib/Classes/Affise.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation
#if canImport(WebKit)
import WebKit
#endif

/**
* Entry point to initialise Affise Attribution library
Expand Down Expand Up @@ -42,23 +44,27 @@ public final class Affise: NSObject {
public static func isInitialized() -> Bool {
return api?.isInitialized() ?? false
}

/**
* deprecated
* Send events
*/
// @objc
// private static func sendEvents() {
// api?.eventsManager.sendEvents()
// }


/**
* Store and send [event]
*/
@objc
public static func sendEvent(_ event: Event) {
internal static func sendEvent(_ event: Event) {
api?.storeEventUseCase.storeEvent(event: event)
}
/**
* Send now [event]
*/
@objc
internal static func sendEventNow(_ event: Event, _ success: @escaping OnSendSuccessCallback, _ failed: @escaping OnSendFailedCallback) {
api?.immediateSendToServerUseCase.sendNow(event: event, success: success) { response in
let toSave = failed(response)
if toSave {
api?.storeEventUseCase.storeEvent(event: event)
}
return toSave
}
}

/**
* Add [pushToken]
Expand Down
1 change: 1 addition & 0 deletions AffiseAttributionLib/Classes/AffiseApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal protocol AffiseApi {
var storeInternalEventUseCase: StoreInternalEventUseCase {get}
var debugValidateUseCase: DebugValidateUseCase {get}
var debugNetworkUseCase: DebugNetworkUseCase {get}
var immediateSendToServerUseCase: ImmediateSendToServerUseCase {get}

func isInitialized() -> Bool
}
9 changes: 8 additions & 1 deletion AffiseAttributionLib/Classes/AffiseComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ internal class AffiseComponent: AffiseApi {
appLifecycleEventsManager: appLifecycleEventsManager
)
lazy var eventsStorage:EventsStorage = EventsStorageImpl(logsManager: logsManager, fileManager: fileManager)
lazy var eventToSerializedEventConverter:EventToSerializedEventConverter = EventToSerializedEventConverter()
lazy var eventsRepository:EventsRepository = EventsRepositoryImpl(
converterToBase64: ConverterToBase64(),
converterToSerializedEvent: EventToSerializedEventConverter(),
converterToSerializedEvent: eventToSerializedEventConverter,
logsManager: logsManager,
eventsStorage: eventsStorage
)
Expand Down Expand Up @@ -123,6 +124,12 @@ internal class AffiseComponent: AffiseApi {
logsManager: logsManager,
preferencesUseCase: preferencesUseCase
)
lazy var immediateSendToServerUseCase: ImmediateSendToServerUseCase = ImmediateSendToServerUseCaseImpl(
cloudRepository: cloudRepository,
postBackModelFactory: postBackModelFactory,
converterToSerializedEvent: eventToSerializedEventConverter,
logsManager: logsManager
)
lazy var deeplinkClickRepository: DeeplinkClickRepository = DeeplinkClickRepositoryImpl()
lazy var deeplinkManager: DeeplinkManager = DeeplinkManagerImpl(
isDeeplinkRepository: deeplinkClickRepository,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public typealias OnSendFailedCallback = (_ status: HttpResponse) -> Bool
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public typealias OnSendSuccessCallback = () -> Void
10 changes: 9 additions & 1 deletion AffiseAttributionLib/Classes/events/base/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ public class Event: NSObject {
*/
@objc
public func send() {
Affise.sendEvent(self);
Affise.sendEvent(self)
}

/**
* Send this event
*/
@objc
public func sendNow(_ success: @escaping OnSendSuccessCallback, _ failed: @escaping OnSendFailedCallback) {
Affise.sendEventNow(self, success, failed)
}

@objc
Expand Down
1 change: 1 addition & 0 deletions AffiseAttributionLib/Classes/modules/AffiseKeyValue.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation


@objc
public class AffiseKeyValue: NSObject {

Expand Down
2 changes: 2 additions & 0 deletions AffiseAttributionLib/Classes/modules/AffiseModule.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation
import UIKit


@objc
open class AffiseModule: NSObject {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import UIKit


internal class AffiseModuleManager {

private let bundle: Bundle
Expand Down Expand Up @@ -48,7 +49,7 @@ internal class AffiseModuleManager {
}

func status(_ module: AffiseModules, _ onComplete: @escaping OnKeyValueCallback) {
getModule(module)?.status(onComplete) ?? onComplete([AffiseKeyValue(module.value(), "not found")])
getModule(module)?.status(onComplete) ?? onComplete([AffiseKeyValue(module.className(), "not found")])
}

private func moduleStart(_ module: AffiseModule) {
Expand All @@ -57,7 +58,9 @@ internal class AffiseModuleManager {
}

private func classType(_ name: AffiseModules) -> AffiseModule.Type? {
guard let cls = NSClassFromString(name.value()) as? AffiseModule.Type else { return nil }
let aClass: AnyClass? = NSClassFromString(name.className()) ?? NSClassFromString(name.classNameModule())
guard let aClass = aClass else { return nil }
guard let cls = aClass as? AffiseModule.Type else { return nil }
return cls
}

Expand Down
7 changes: 5 additions & 2 deletions AffiseAttributionLib/Classes/modules/AffiseModules.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation


@objc
public enum AffiseModules: Int {
case Advertising
Expand All @@ -17,13 +18,15 @@ public enum AffiseModules: Int {

extension AffiseModules: CaseIterable, CustomStringConvertible {

internal func value() -> String { "Affise\(self.enumValue)Module" }
internal func className() -> String { "Affise\(self.enumValue)Module" }

internal func classNameModule() -> String { "AffiseModule\(self.enumValue).\(self.enumValue)Module" }

internal static func values() -> [AffiseModules] { allCases }

public var description: String { enumValue }

public static func from(_ name: String) -> AffiseModules? {
return allCases.first { $0.value().contains(name) }
return allCases.first { $0.className().contains(name) }
}
}
2 changes: 2 additions & 0 deletions AffiseAttributionLib/Classes/modules/OnKeyValueCallback.swift
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import Foundation

public typealias OnKeyValueCallback = (_ data: [AffiseKeyValue]) -> Void
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation


@objc
public class AffiseProduct: NSObject {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation


@objc
public enum AffiseProductType: Int {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import Foundation


@objc
public class AffiseProductsResult: NSObject {

public let products: [String: AffiseProduct]
public let products: [AffiseProduct]

public let invalidIds: [String]

public init(products: [String: AffiseProduct], invalid: [String]) {
public init(products: [AffiseProduct], invalid: [String]) {
self.products = products
self.invalidIds = invalid
}

public override var description: String {
"AffiseProductsResult(products=[\(products.keys.joined(separator: ", "))], invalidIds=[\(invalidIds.joined(separator: ", "))])"
"AffiseProductsResult(products=[\(products.map { $0.productId ?? "" }.joined(separator: ", "))], invalidIds=[\(invalidIds.joined(separator: ", "))])"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation


public typealias AffiseResult<Success> = Swift.Result<Success, Error>

public typealias AffiseResultCallback<Success> = (AffiseResult<Success>) -> Void
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Foundation


public protocol AffiseSubscriptionApi {
static func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>)
static func purchase(_ productId: String, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>)

static func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation


public enum AffiseSubscriptionError: Error {
case notInitialized
case productNotFound([String])
Expand All @@ -11,7 +12,7 @@ extension AffiseSubscriptionError: CustomStringConvertible {
switch self {
case .notInitialized: return "affise not initialized"
case .productNotFound(let ids): return "product not found [\(ids.joined(separator: ", "))]"
case .purchaseFailed(let error): return "purchase failed: \(error)"
case .purchaseFailed(let error): return "purchase failed: \(error?.localizedDescription ?? "")"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation


@objc
public enum TimeUnitType: Int {

Expand Down
5 changes: 5 additions & 0 deletions AffiseAttributionLib/Classes/network/CloudRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ protocol CloudRepository {
* Send [data] to current [url]
*/
func send(data: Array<PostBackModel>, url: String) throws

/**
* Send [data] to [url]
*/
func createRequest(url: String, data: [PostBackModel]) -> HttpResponse
}
32 changes: 16 additions & 16 deletions AffiseAttributionLib/Classes/network/CloudRepositoryImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,6 @@ internal class CloudRepositoryImpl {
self.userAgentProvider = userAgentProvider
self.converter = converter
}

/**
* Send [data] to [url]
*/
private func createRequest(url: String, data: [PostBackModel]) -> HttpResponse {
guard let httpsUrl = url.toURL() else { return HttpResponse(0, "", nil) }

//Create request
return networkService.executeRequest(
httpsUrl: httpsUrl,
method: .POST,
data: converter.convert(from: data).toData(),
timeout: TIMEOUT_SEND,
headers: createHeaders()
)
}

/**
* Create headers
Expand Down Expand Up @@ -78,4 +62,20 @@ extension CloudRepositoryImpl: CloudRepository {
}
}
}

/**
* Send [data] to [url]
*/
func createRequest(url: String, data: [PostBackModel]) -> HttpResponse {
guard let httpsUrl = url.toURL() else { return HttpResponse(0, "", nil) }

//Create request
return networkService.executeRequest(
httpsUrl: httpsUrl,
method: .POST,
data: converter.convert(from: data).toData(),
timeout: TIMEOUT_SEND,
headers: createHeaders()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
class AffSDKVersionProvider: StringPropertyProvider {

override func provide() -> String? {
return "1.6.28"
return "1.6.29"
}

public override func getOrder() -> Float {
Expand Down
Loading

0 comments on commit b8ac20a

Please sign in to comment.