Skip to content

Commit

Permalink
Merge pull request #48 from mercadolibre/fix/discount-tracker
Browse files Browse the repository at this point in the history
Discount tracker protocol updated
  • Loading branch information
vveltri-meli authored Feb 7, 2020
2 parents 78bfe59 + 5fc568b commit 34e8b7b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v1.8.1
🚀 1.8.1 🚀
- Restored tap tracking on Discount Box component.
- Modified MLBusinessDiscountTrackerProtocol.

# v1.8
🚀 1.8 🚀
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DiscountTrackerData: NSObject, MLBusinessDiscountTrackerProtocol {
self.touchPointId = touchPointId
}

func track(action: String, eventData: [[String : Any]]) {
func track(action: String, eventData: [String : Any]) {
//Melidata tracking
print("Melidata track path: \(basePath)/\(touchPointId)/\(action) with event data: \(eventData)")
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Commons/MLBusinessDiscountTrackerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import Foundation

@objc public protocol MLBusinessDiscountTrackerProtocol: NSObjectProtocol {
func track(action: String, eventData: [[String : Any]])
func track(action: String, eventData: [String : Any])
}
6 changes: 3 additions & 3 deletions Source/Components/Discount/MLBusinessDiscountBoxView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ private extension MLBusinessDiscountBoxView {
}
}

private func getEventDataFrom(discountItems: [MLBusinessSingleItemProtocol]) -> [[String : Any]] {
private func getEventDataFrom(discountItems: [MLBusinessSingleItemProtocol]) -> [String : Any] {
var eventData = [[String : Any]]()
for discountItem in discountItems {
if let eventDataForItem = discountItem.eventDataForItem?() {
eventData.append(eventDataForItem)
}
}
return eventData
return ["items" : eventData]
}

private func updateUI() {
Expand Down Expand Up @@ -156,7 +156,7 @@ private extension MLBusinessDiscountBoxView {
extension MLBusinessDiscountBoxView: MLBusinessUserInteractionProtocol {
func didTap(item: MLBusinessSingleItemProtocol, index: Int, section: Int) {
if let viewData = viewData, let trackingProvider = viewData.getDiscountTracker?(), let eventDataForItem = item.eventDataForItem?() {
trackingProvider.track(action: "tap", eventData: [eventDataForItem])
trackingProvider.track(action: "tap", eventData: eventDataForItem)
}

tapAction?(index, item.deepLinkForItem(), item.trackIdForItem())
Expand Down

0 comments on commit 34e8b7b

Please sign in to comment.