diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index a7acadf6..16416933 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -112,6 +112,7 @@ open class TabsModel: MoleculeModelProtocol { open class TabItemModel: Codable { open var label: LabelModel open var action: ActionModelProtocol? + public var analyticsData: JSONValueDictionary? public init(label: LabelModel) { self.label = label @@ -120,6 +121,7 @@ open class TabItemModel: Codable { private enum CodingKeys: String, CodingKey { case label case action + case analyticsData } open func setDefaults() { @@ -138,12 +140,14 @@ open class TabItemModel: Codable { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) label = try typeContainer.decode(LabelModel.self, forKey: .label) action = try typeContainer.decodeModelIfPresent(codingKey: .action) + analyticsData = try typeContainer.decodeIfPresent(JSONValueDictionary.self, forKey: .analyticsData) setDefaults() } - + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModel(label, forKey: .label) try container.encodeModelIfPresent(action, forKey: .action) + try container.encodeIfPresent(analyticsData, forKey: .analyticsData) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index 631bf50f..c97c0ed1 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -66,6 +66,11 @@ extension TabsTableViewCell: TabsDelegate { MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model.tabs, additionalData: nil, delegateObject: delegateObject) } MVMCoreUIActionHandler.performActionUnstructured(with: SwapMoleculesActionModel(index < previousTabIndex ? .left : .right), sourceModel: model, additionalData: nil, delegateObject: delegateObject) + + if let analyticsData = try? model.tabs.tabs[index].analyticsData?.toJSONAny(), + let controller = delegateObject?.moleculeDelegate as? MVMCoreViewControllerProtocol { + MVMCoreUILoggingHandler.shared()?.defaultLogPageUpdate(forController: controller, from: ["analyticsData": analyticsData]) + } } }