Manos Chorianopoulos

add firebase events v2

......@@ -236,7 +236,7 @@ var timer2: DispatchSourceTimer?
if (swiftApi().getTrackingStepsEnabled() == false) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "lovalty_steps_activation"
firebaseEvent._eventName = "loyalty_steps_activation"
firebaseEvent._parameters = nil
SwiftEventBus.post("firebase", sender: firebaseEvent)
......@@ -253,7 +253,103 @@ var timer2: DispatchSourceTimer?
print("**************** WARPLY Webview Log START *****************")
print(event)
print("**************** WARPLY Webview Log END *****************")
} else if (eventArray[1] == "loyalty_questionnaire_selected") {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_questionnaire_selected"
firebaseEvent.setParameter = ("completed", "true")
SwiftEventBus.post("firebase", sender: firebaseEvent)
} else if (eventArray[1] == "loyalty_questionnaire_answer_again") {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_questionnaire_answer_again"
firebaseEvent._parameters = nil
SwiftEventBus.post("firebase", sender: firebaseEvent)
} else if (eventArray[1] == "loyalty_questionnaire_answers_deleted") {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_questionnaire_answers_deleted"
firebaseEvent._parameters = nil
SwiftEventBus.post("firebase", sender: firebaseEvent)
} else if (eventArray[1] == "loyalty_questionnaire_later") {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_questionnaire_later"
firebaseEvent.setParameter = ("completed", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
} else if (eventArray[1] == "loyalty_sdk_offer_selected") {
var name: String = ""
if (eventArray.count > 2) {
name = String(eventArray[2])
} else {
name = ""
}
var type: String = ""
if (eventArray.count > 3) {
type = String(eventArray[3])
} else {
type = ""
}
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", name)
firebaseEvent.setParameter = ("type", type)
SwiftEventBus.post("firebase", sender: firebaseEvent)
} else if (eventArray[1] == "loyalty_offer_activated") {
var name: String = ""
if (eventArray.count > 2) {
name = String(eventArray[2])
} else {
name = ""
}
var type: String = ""
if (eventArray.count > 3) {
type = String(eventArray[3])
} else {
type = ""
}
var successful: String = ""
if (eventArray.count > 4) {
successful = String(eventArray[4])
} else {
successful = ""
}
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", name)
firebaseEvent.setParameter = ("type", type)
firebaseEvent.setParameter = ("successful", successful)
SwiftEventBus.post("firebase", sender: firebaseEvent)
} else if (eventArray[1] == "time_spent_on_loyalty_sdk") {
var name: String = ""
if (eventArray.count > 2) {
name = String(eventArray[2])
} else {
name = ""
}
var seconds: String = ""
if (eventArray.count > 3) {
seconds = String(eventArray[3])
} else {
seconds = ""
}
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", name)
firebaseEvent.setParameter = ("seconds", seconds)
SwiftEventBus.post("firebase", sender: firebaseEvent)
}
}
}
}
......
......@@ -156,14 +156,36 @@ import UIKit
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "true")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.")
// self.postEventRequest()
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
......
......@@ -151,6 +151,13 @@ import SwiftEventBus
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "true")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards.")
swiftApi().getCouponsAsync(getCouponsCallback)
......@@ -174,15 +181,46 @@ import SwiftEventBus
} else {
}
}
} else if (response?.getStatus == 3) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Το κουπόνι δεν είναι διαθέσιμο για αγορά")
} else if (response?.getStatus == 5) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Δεν έχεις αρκετούς πόντους")
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
......
......@@ -18,6 +18,8 @@ import SwiftEventBus
public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns()
public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
var timerGFY: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -68,6 +70,14 @@ import SwiftEventBus
super.viewWillAppear(animated)
self.refreshData()
self.startTimer()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
......@@ -108,6 +118,39 @@ import SwiftEventBus
self.tableView.reloadData()
}
func startTimer() {
print("========= GFY Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".gfy.timer")
timerGFY = DispatchSource.makeTimerSource(queue: queue)
timerGFY!.schedule(deadline: .now(), repeating: .seconds(1))
timerGFY!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= GFY interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerGFY!.resume()
}
func stopTimer() {
print("========= GFY Timer Stopped! =========")
timerGFY?.cancel()
timerGFY = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "GiftsForYou")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
}
// MARK: - TableView
......@@ -174,6 +217,13 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item._title))
firebaseEvent.setParameter = ("type", "gift")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
vc.ccms = item
......@@ -199,7 +249,7 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item?.name ?? ""))
firebaseEvent.setParameter = ("name", (item.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
SwiftEventBus.post("firebase", sender: firebaseEvent)
......@@ -291,6 +341,12 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? ""
seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? ""
SwiftEventBus.post("seasonal", sender: seasonalEvent)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (campaigns[indexPath.row]._title ?? ""))
firebaseEvent.setParameter = ("type", "seasonal")
SwiftEventBus.post("firebase", sender: firebaseEvent)
}
}
}
......
......@@ -17,6 +17,9 @@ import UIKit
var pageController: UIPageViewController!
var tabSelected = 0
var timerHistory: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -57,6 +60,52 @@ import UIKit
pageController.setViewControllers([analysisVC!], direction:.forward, animated:false)
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.startTimer()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
func startTimer() {
print("========= GiftsCalculator Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".history.timer")
timerHistory = DispatchSource.makeTimerSource(queue: queue)
timerHistory!.schedule(deadline: .now(), repeating: .seconds(1))
timerHistory!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= GiftsCalculator interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerHistory!.resume()
}
func stopTimer() {
print("========= GiftsCalculator Timer Stopped! =========")
timerHistory?.cancel()
timerHistory = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "GiftsCalculator")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
////////////////////////////////////////////////////////////////////////////////
private func viewControllerAt(_ index:Int) -> AnalysisChildViewController?
{
......
......@@ -17,6 +17,9 @@ import SwiftEventBus
public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns()
var timerMFY: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -56,6 +59,14 @@ import SwiftEventBus
super.viewWillAppear(animated)
self.refreshData()
self.startTimer()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
......@@ -82,6 +93,39 @@ import SwiftEventBus
self.tableView.reloadData()
}
func startTimer() {
print("========= MFY Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".mfy.timer")
timerMFY = DispatchSource.makeTimerSource(queue: queue)
timerMFY!.schedule(deadline: .now(), repeating: .seconds(1))
timerMFY!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= MFY interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerMFY!.resume()
}
func stopTimer() {
print("========= MFY Timer Stopped! =========")
timerMFY?.cancel()
timerMFY = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "MoreForYou")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
}
// MARK: - TableView
......@@ -148,6 +192,13 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item._title))
firebaseEvent.setParameter = ("type", "gift")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
vc.ccms = item
......@@ -172,7 +223,7 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item?.name ?? ""))
firebaseEvent.setParameter = ("name", (item.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
SwiftEventBus.post("firebase", sender: firebaseEvent)
......
......@@ -210,14 +210,35 @@ import UIKit
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "true")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.")
// self.postEventRequest()
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
......
......@@ -46,6 +46,9 @@ import SwiftEventBus
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
var timerWallet: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -364,6 +367,39 @@ import SwiftEventBus
self.present(alert, animated: true, completion: nil)
}
func startTimer() {
print("========= MyRewards Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".wallet.timer")
timerWallet = DispatchSource.makeTimerSource(queue: queue)
timerWallet!.schedule(deadline: .now(), repeating: .seconds(1))
timerWallet!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= MyRewards interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerWallet!.resume()
}
func stopTimer() {
print("========= MyRewards Timer Stopped! =========")
timerWallet?.cancel()
timerWallet = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "MyRewards")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
// MARK: - Actions
@IBAction func qustionnaireButtonAction(_ sender: Any) {
swiftApi().openQuestionnaire(self);
......
......@@ -5025,6 +5025,12 @@ public class swiftApi {
} else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (ccms._title))
firebaseEvent.setParameter = ("type", "gift")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
vc.ccms = ccms
......