Skip to content

Commit

Permalink
1.6.38
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Aug 6, 2024
1 parent ebb3b18 commit 9bca540
Show file tree
Hide file tree
Showing 24 changed files with 279 additions and 127 deletions.
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.37"
spec.version = ENV['LIB_VERSION'] || "1.6.38"
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: 22 additions & 6 deletions AffiseAttributionLib/Classes/Affise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,35 @@ public final class Affise: NSObject {
}

/**
* Get referrer
* Get referrer url
*/
@objc
public static func getReferrer(_ callback: @escaping OnReferrerCallback) {
api?.retrieveInstallReferrerUseCase.getReferrer(callback)
public static func getReferrerUrl(_ callback: @escaping OnReferrerCallback) {
api?.retrieveReferrerUseCase.getReferrerUrl(callback)
}

/**
* Get referrer Value
* Get referrer url value
*/
@objc
public static func getReferrerValue(_ key: ReferrerKey, _ callback: @escaping OnReferrerCallback) {
api?.retrieveInstallReferrerUseCase.getReferrerValue(key, callback)
public static func getReferrerUrlValue(_ key: ReferrerKey, _ callback: @escaping OnReferrerCallback) {
api?.retrieveReferrerUseCase.getReferrerUrlValue(key, callback)
}

/**
* Get referrer on server
*/
@objc
public static func getReferrerOnServer(_ callback: @escaping OnReferrerCallback) {
api?.retrieveReferrerOnServerUseCase.getReferrerOnServer(callback)
}

/**
* Get referrer on server value
*/
@objc
public static func getReferrerOnServerValue(_ key: ReferrerKey, _ callback: @escaping OnReferrerCallback) {
api?.retrieveReferrerOnServerUseCase.getReferrerOnServerValue(key, callback)
}

/**
Expand Down
3 changes: 2 additions & 1 deletion AffiseAttributionLib/Classes/AffiseApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ internal protocol AffiseApi {
var initPropertiesStorage: InitPropertiesStorage {get}
var preferencesUseCase: PreferencesUseCase {get}
var postBackModelFactory: PostBackModelFactory {get}
var retrieveInstallReferrerUseCase: RetrieveInstallReferrerUseCase {get}
var retrieveReferrerUseCase: RetrieveReferrerUseCase {get}
var retrieveReferrerOnServerUseCase: RetrieveReferrerOnServerUseCase {get}
var moduleManager: AffiseModuleManager {get}
var storeInternalEventUseCase: StoreInternalEventUseCase {get}
var debugValidateUseCase: DebugValidateUseCase {get}
Expand Down
7 changes: 5 additions & 2 deletions AffiseAttributionLib/Classes/AffiseComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,13 @@ internal class AffiseComponent: AffiseApi {
logsManager: logsManager,
deeplinkClickRepository: deeplinkClickRepository,
deviceUseCase: deviceUseCase,
remarketingUseCase: remarketingUseCase
remarketingUseCase: remarketingUseCase,
retrieveReferrerUseCase: retrieveReferrerUseCase
).create()

lazy var retrieveInstallReferrerUseCase: RetrieveInstallReferrerUseCase = RetrieveInstallReferrerUseCase(
lazy var retrieveReferrerUseCase: RetrieveReferrerUseCase = RetrieveReferrerUseCase()

lazy var retrieveReferrerOnServerUseCase: RetrieveReferrerOnServerUseCase = RetrieveReferrerOnServerUseCase(
moduleManager: moduleManager
)

Expand Down
2 changes: 1 addition & 1 deletion AffiseAttributionLib/Classes/internal/BuildConfig.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

internal struct BuildConfig {
static let AFFISE_VERSION = "1.6.37"
static let AFFISE_VERSION = "1.6.38"
}
2 changes: 1 addition & 1 deletion AffiseAttributionLib/Classes/internal/InternalAffise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension Affise {
*/
@objc
public static func handleReferrer(_ url: URL?) {
Affise.getApi()?.retrieveInstallReferrerUseCase.setReferrer(url)
Affise.getApi()?.retrieveReferrerUseCase.setReferrer(url)
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

/**
* Provider for parameter [ProviderType.REFERRER]
*/
class ReferrerProvider: StringPropertyProvider {

private let useCase: RetrieveReferrerUseCase

init(_ useCase: RetrieveReferrerUseCase) {
self.useCase = useCase
}

override func provide() -> String? {
return useCase.getReferrer()
}

public override func getOrder() -> Float {
34.0
}

public override func getKey() -> ProviderType? {
ProviderType.REFERRER
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class PropertiesProviderFactory {
private let deeplinkClickRepository: DeeplinkClickRepository
private let deviceUseCase: DeviceUseCase
private let remarketingUseCase: RemarketingUseCase
private let retrieveReferrerUseCase: RetrieveReferrerUseCase

init(app: UIApplication,
bundle: Bundle,
Expand All @@ -32,7 +33,8 @@ internal class PropertiesProviderFactory {
logsManager: LogsManager,
deeplinkClickRepository: DeeplinkClickRepository,
deviceUseCase: DeviceUseCase,
remarketingUseCase: RemarketingUseCase
remarketingUseCase: RemarketingUseCase,
retrieveReferrerUseCase: RetrieveReferrerUseCase
) {
self.app = app
self.bundle = bundle
Expand All @@ -46,6 +48,7 @@ internal class PropertiesProviderFactory {
self.deeplinkClickRepository = deeplinkClickRepository
self.deviceUseCase = deviceUseCase
self.remarketingUseCase = remarketingUseCase
self.retrieveReferrerUseCase = retrieveReferrerUseCase
}

func create() -> PostBackModelFactory {
Expand Down Expand Up @@ -119,7 +122,8 @@ internal class PropertiesProviderFactory {
PushTokenProvider(preferences: preferences),
OsAndVersionProvider(remarketingUseCase),
DeviceProvider(remarketingUseCase),
BuildProvider(remarketingUseCase)
BuildProvider(remarketingUseCase),
ReferrerProvider(retrieveReferrerUseCase)
]
)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Foundation

class RetrieveReferrerOnServerUseCase {

private let moduleManager: AffiseModuleManager
private var referrerModule: ReferrerCallback?

init(
moduleManager: AffiseModuleManager
) {
self.moduleManager = moduleManager
}

private func getReffererModule() -> ReferrerCallback? {
if self.referrerModule != nil {
return self.referrerModule
}
guard let module = moduleManager.getModule(.Status) else { return nil }
guard let referrerModule = module as? ReferrerCallback else { return nil }
self.referrerModule = referrerModule
return referrerModule
}

private func handleReferrerOnServer(_ callback: @escaping OnReferrerCallback) {
getReffererModule()?.getReferrer(callback) ?? callback(nil)
}

/**
* Return referrer on server
*/
func getReferrerOnServer(_ callback: @escaping OnReferrerCallback) {
handleReferrerOnServer { value in
callback(value)
}
}

/**
* Return referrer on server parameter by key
*/
func getReferrerOnServerValue(_ key: ReferrerKey, _ callback: @escaping OnReferrerCallback) {
handleReferrerOnServer { value in
callback(value?.getQueryStringParameter(key.value()))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Foundation

class RetrieveReferrerUseCase {

private var referrerURL: URL?

/**
* Set referrerURL
*/
func setReferrer(_ url: URL?) {
referrerURL = url
}

func getReferrer() -> String? {
return referrerURL?.absoluteString
}

/**
* Return referrer URL
*/
func getReferrerUrl(_ callback: @escaping OnReferrerCallback) {
callback(referrerURL?.absoluteString)
}

/**
* Return referrer URL parameter by key
*/
func getReferrerUrlValue(_ key: ReferrerKey, _ callback: @escaping OnReferrerCallback) {
callback(referrerURL?.absoluteString.getQueryStringParameter(key.value()))
}
}
5 changes: 5 additions & 0 deletions AffiseAttributionLib/Classes/utils/StringUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public extension String {
var isBlank: Bool {
return allSatisfy { $0.isWhitespace }
}

internal func getQueryStringParameter(_ param: String) -> String? {
guard let url = URLComponents(string: self) else { return nil }
return url.queryItems?.first(where: { $0.name == param })?.value
}
}


Expand Down
2 changes: 1 addition & 1 deletion AffiseInternal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |spec|
spec.name = "AffiseInternal"
spec.version = ENV['LIB_VERSION'] || "1.6.37"
spec.version = ENV['LIB_VERSION'] || "1.6.38"
spec.summary = "Affise Internal library"
spec.description = "Affise Internal wrapper library for crossplatform"
spec.homepage = "https://github.com/affise/sdk-ios"
Expand Down
12 changes: 8 additions & 4 deletions AffiseInternal/Classes/AffiseApiMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public enum AffiseApiMethod: Int {
case GET_PROVIDERS
case IS_FIRST_RUN
// callback
case GET_REFERRER_CALLBACK
case GET_REFERRER_VALUE_CALLBACK
case GET_REFERRER_URL_CALLBACK
case GET_REFERRER_URL_VALUE_CALLBACK
case GET_REFERRER_ON_SERVER_CALLBACK
case GET_REFERRER_ON_SERVER_VALUE_CALLBACK
case REGISTER_DEEPLINK_CALLBACK
case SKAD_REGISTER_ERROR_CALLBACK
case SKAD_POSTBACK_ERROR_CALLBACK
Expand Down Expand Up @@ -73,8 +75,10 @@ public enum AffiseApiMethod: Int {
case .GET_PROVIDERS: return "get_providers"
case .IS_FIRST_RUN: return "is_first_run"
// callback
case .GET_REFERRER_CALLBACK: return "get_referrer_callback"
case .GET_REFERRER_VALUE_CALLBACK: return "get_referrer_value_callback"
case .GET_REFERRER_URL_CALLBACK: return "get_referrer_url_callback"
case .GET_REFERRER_URL_VALUE_CALLBACK: return "get_referrer_url_value_callback"
case .GET_REFERRER_ON_SERVER_CALLBACK: return "get_referrer_on_server_callback"
case .GET_REFERRER_ON_SERVER_VALUE_CALLBACK: return "get_referrer_on_server_value_callback"
case .REGISTER_DEEPLINK_CALLBACK: return "register_deeplink_callback"
case .SKAD_REGISTER_ERROR_CALLBACK: return "skad_register_error_callback"
case .SKAD_POSTBACK_ERROR_CALLBACK: return "skad_postback_error_callback"
Expand Down
Loading

0 comments on commit 9bca540

Please sign in to comment.