diff --git a/PandaSDK.podspec b/PandaSDK.podspec index 7669dbb..85c4ffc 100644 --- a/PandaSDK.podspec +++ b/PandaSDK.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "PandaSDK" - spec.version = "0.5.2" + spec.version = "0.6.1" spec.summary = "Panda pod which will help us boost our revenue." # This description is used to generate tags and improve search results. diff --git a/Sources/PandaSDK/ConfiguredPanda.swift b/Sources/PandaSDK/ConfiguredPanda.swift index c846d7b..e9b08dd 100644 --- a/Sources/PandaSDK/ConfiguredPanda.swift +++ b/Sources/PandaSDK/ConfiguredPanda.swift @@ -33,7 +33,7 @@ final public class Panda: PandaProtocol, ObserverSupport { private var viewControllers: Set> = [] private var payload: PandaPayload? private var entryPoint: String? { - return payload?.extraEventValues["entry_point"] + return payload?.entryPoint } public var onPurchase: ((String) -> Void)? @@ -330,8 +330,7 @@ final public class Panda: PandaProtocol, ObserverSupport { private func createViewModel(screenData: ScreenData, product: String? = nil, payload: PandaPayload? = nil) -> WebViewModel { let viewModel = WebViewModel(screenData: screenData, payload: payload) - let extraValues = viewModel.payload?.extraEventValues - let entryPoint = extraValues?["entry_point"] + let entryPoint = payload?.entryPoint if let product = product { appStoreClient.getProduct(with: product) { result in diff --git a/Sources/PandaSDK/Models/PandaPayload.swift b/Sources/PandaSDK/Models/PandaPayload.swift index af3eb33..0e1ef9e 100644 --- a/Sources/PandaSDK/Models/PandaPayload.swift +++ b/Sources/PandaSDK/Models/PandaPayload.swift @@ -8,26 +8,44 @@ import UIKit public struct PandaPayload { - let shouldShowDefaultScreen: Bool - let screenBackgroundColor: UIColor? - let extraEventValues: [String: String] - let pageLoadingTimeout: TimeInterval - let htmlDownloadTimeout: TimeInterval? - let data: [String: Any]? + internal let shouldShowDefaultScreen: Bool + internal let screenBackgroundColor: UIColor? + internal let entryPoint: String? + internal let pageLoadingTimeout: TimeInterval + internal let htmlDownloadTimeout: TimeInterval? + internal let data: [String: Any]? public init( shouldShowDefaultScreen: Bool = true, screenBackgroundColor: UIColor? = nil, - extraEventValues: [String: String] = [:], + entryPoint: String? = nil, pageLoadingTimeout: TimeInterval = 3.0, htmlDownloadTimeout: TimeInterval? = nil, - data: [String: Any]? = nil + targetLanguage: String? = nil, + fromLanguage: String? = nil, + strings: [[String: String]]? = nil, + lessonTitle: String? = nil ) { self.shouldShowDefaultScreen = shouldShowDefaultScreen self.screenBackgroundColor = screenBackgroundColor - self.extraEventValues = extraEventValues + self.entryPoint = entryPoint self.pageLoadingTimeout = pageLoadingTimeout self.htmlDownloadTimeout = htmlDownloadTimeout + var data: [String: Any] = [:] + if let targetLanguage = targetLanguage { + data["target_language"] = targetLanguage + } + if let fromLanguage = fromLanguage { + data["from_language"] = fromLanguage + } + + if let strings = strings { + data["strings"] = strings + } + if let lessonTitle = lessonTitle { + data["lesson_title"] = lessonTitle + } + self.data = data } } diff --git a/Sources/PandaSDK/UnconfiguredPanda.swift b/Sources/PandaSDK/UnconfiguredPanda.swift index 4ad6e68..05988b5 100644 --- a/Sources/PandaSDK/UnconfiguredPanda.swift +++ b/Sources/PandaSDK/UnconfiguredPanda.swift @@ -163,8 +163,7 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport { payload: PandaPayload? = nil ) -> WebViewModel { let viewModel = WebViewModel(screenData: screenData, payload: payload) - let extraValues = viewModel.payload?.extraEventValues - let source = extraValues?["entry_point"] + let source = payload?.entryPoint viewModel.onSurvey = { value, screenId, screenName in pandaLog("Survey: \(value)") }