parsing analytics data

This commit is contained in:
Damodaram 2020-06-16 09:51:59 +05:30
parent b987bbc2c1
commit 78ca4984f1
3 changed files with 24 additions and 0 deletions

View File

@ -10,6 +10,8 @@ import Foundation
@objcMembers public class CarouselItemModel: MoleculeCollectionItemModel, CarouselItemModelProtocol {
public var analyticsData: [String : String]?
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
@ -28,6 +30,7 @@ import Foundation
private enum CodingKeys: String, CodingKey {
case peakingUI
case peakingArrowColor
case analyticsData
}
//--------------------------------------------------
@ -38,6 +41,7 @@ import Foundation
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
peakingUI = try typeContainer.decodeIfPresent(Bool.self, forKey: .peakingUI)
peakingArrowColor = try typeContainer.decodeIfPresent(Color.self, forKey: .peakingArrowColor)
analyticsData = try typeContainer.decodeIfPresent([String:String].self, forKey: .analyticsData)
try super.init(from: decoder)
}
@ -46,5 +50,6 @@ import Foundation
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(peakingUI, forKey: .peakingUI)
try container.encodeIfPresent(peakingArrowColor, forKey: .peakingArrowColor)
try container.encodeIfPresent(analyticsData, forKey: .analyticsData)
}
}

View File

@ -163,6 +163,9 @@ open class Carousel: View {
pageIndex = carouselModel.index
pagingView?.currentIndex = carouselModel.index
collectionView.reloadData()
// track analyticsData
trackSwipeActionAnalyticsforIndex(pageIndex)
}
//--------------------------------------------------
@ -297,6 +300,13 @@ open class Carousel: View {
cell.accessibilityElementsHidden = true
}
}
func trackSwipeActionAnalyticsforIndex(_ index : Int){
guard let itemModel = molecules?[index],
let analyticsData = itemModel.analyticsData,
let viewcontrollerObject = delegateObject?.moleculeDelegate as? MVMCoreViewControllerProtocol else { return }
MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController:viewcontrollerObject, actionInformation: analyticsData, additionalData: analyticsData)
}
}
extension Carousel: UICollectionViewDelegateFlowLayout {
@ -454,5 +464,7 @@ extension Carousel: UIScrollViewDelegate {
// Cycle to other end if on buffer cell.
pagingView?.currentIndex = pageIndex
showPeaking(true)
// track analyticsData
trackSwipeActionAnalyticsforIndex(pageIndex)
}
}

View File

@ -10,4 +10,11 @@ import Foundation
public protocol CarouselItemModelProtocol: ContainerModelProtocol {
var analyticsData: [String:String]? { get }
}
public extension CarouselItemModelProtocol {
var analyticsData: [String:String]? {
get { return nil}
}
}