From bb19aeff526b19dfc9466a271f971c97d5017908 Mon Sep 17 00:00:00 2001 From: Sanu gupta Date: Mon, 8 Aug 2022 12:34:44 +0530 Subject: [PATCH] Added extra fields in event (#19) * Added extra field in events * Minor_changes * MinorChanges * Update Example/trackier-ios-sdk/AppDelegate.swift Co-authored-by: Hemant Mann --- Example/Podfile.lock | 4 +- .../Base.lproj/LaunchScreen.xib | 24 +++++----- .../Base.lproj/Main.storyboard | 31 ++++++++++++- Example/trackier-ios-sdk/ViewController.swift | 45 ++++++++----------- trackier-ios-sdk.podspec | 6 +-- trackier-ios-sdk/Classes/Constants.swift | 2 +- trackier-ios-sdk/Classes/TrackierEvent.swift | 12 +++++ trackier-ios-sdk/Classes/TrackierSDK.swift | 8 ++++ .../Classes/TrackierSDKInstance.swift | 6 +++ .../Classes/TrackierWorkRequest.swift | 4 ++ 10 files changed, 98 insertions(+), 44 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index a5d7289..9c6f817 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,7 +1,7 @@ PODS: - Alamofire (5.4.4) - CryptoSwift (1.4.3) - - trackier-ios-sdk (1.6.20): + - trackier-ios-sdk (1.6.27): - Alamofire (~> 5.4.1) - CryptoSwift (~> 1.4.1) - Willow (~> 5.0) @@ -23,7 +23,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Alamofire: f3b09a368f1582ab751b3fff5460276e0d2cf5c9 CryptoSwift: a0799ee936271bd2253a006f1e4523df21845000 - trackier-ios-sdk: 29599f9e9eea5bb6d7345c8c0c9b292d1bae5c1f + trackier-ios-sdk: a59e480fc0978d95879245aa820e2315f3fbab1f Willow: a6310f9aedcb6f4de8c35b94fd3416a660ae9280 PODFILE CHECKSUM: 6307d8f5aa6ba32335caaaa5b91debc7fcb4378e diff --git a/Example/trackier-ios-sdk/Base.lproj/LaunchScreen.xib b/Example/trackier-ios-sdk/Base.lproj/LaunchScreen.xib index c1ec315..a69260e 100644 --- a/Example/trackier-ios-sdk/Base.lproj/LaunchScreen.xib +++ b/Example/trackier-ios-sdk/Base.lproj/LaunchScreen.xib @@ -1,12 +1,9 @@ - - - - + + - - + @@ -17,15 +14,15 @@ @@ -40,7 +37,12 @@ - + + + + + + diff --git a/Example/trackier-ios-sdk/Base.lproj/Main.storyboard b/Example/trackier-ios-sdk/Base.lproj/Main.storyboard index b95ff6c..f07eee5 100644 --- a/Example/trackier-ios-sdk/Base.lproj/Main.storyboard +++ b/Example/trackier-ios-sdk/Base.lproj/Main.storyboard @@ -18,12 +18,41 @@ + + + + - + + + + + + diff --git a/Example/trackier-ios-sdk/ViewController.swift b/Example/trackier-ios-sdk/ViewController.swift index 06617af..f157c15 100644 --- a/Example/trackier-ios-sdk/ViewController.swift +++ b/Example/trackier-ios-sdk/ViewController.swift @@ -14,47 +14,49 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. - - } + userDetails(); } +} + func userDetails(){ let event = TrackierEvent(id: TrackierEvent.LOGIN) /*Passing the UserId and User EmailId Data */ - event.setUserId("XXXXXXXX"); //Pass the UserId values here - event.setUserEmail("abc@gmail.com"); //Pass the user email id in the argument. - + TrackierSDK.setUserID(userId: "2998329") //Pass the UserId values here + TrackierSDK.setUserEmail(userEmail: "abc@gmail.com"); //Pass the user email id in the argument. + TrackierSDK.setUserName(userName: "abc") + TrackierSDK.setUserPhone(userPhone: "xxxxxxxxxx") + event.setDiscount(discount: 3.0) + event.setCouponCode(couponCode: "test2") /*Passing the custom value in the events */ - event.addEventValue("customeValue1","XXXXX"); - event.addEventValue("customeValue2","XXXXX"); + event.addEventValue(prop: "customeValue1", val: "test1"); + event.addEventValue(prop: "customeValue2", val: "XXXXX"); DispatchQueue.global().async { sleep(1) TrackierSDK.trackEvent(event: event) + } } - } func eventsRevenueTracking(){ - + let event = TrackierEvent(id: TrackierEvent.LOGIN) - + //Passing the revenue events be like below example - event.revenue = 10.0; //Pass your generated revenue here. + event.setRevenue(revenue: 10.0, currency: "INR"); //Pass your generated revenue here. event.currency = "INR"; //Pass your currency here. event.orderId = "orderID"; event.param1 = "param1"; event.param2 = "param2"; - event.setEventValue("ev1", "eventValue1"); - event.setEventValue("ev2", 1); + event.addEventValue(prop: "customeValue1", val: "test1"); + event.addEventValue(prop: "customeValue2", val: "XXXXX"); DispatchQueue.global().async { sleep(1) TrackierSDK.trackEvent(event: event) + } } - -} - func eventsTracking(){ let event = TrackierEvent(id:"sEMWSCTXeu") @@ -71,17 +73,9 @@ func eventsTracking(){ DispatchQueue.global().async { sleep(1) TrackierSDK.trackEvent(event: event) + } } -} - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - - } - - extension UIDevice { var modelName: String { var systemInfo = utsname() @@ -93,6 +87,5 @@ extension UIDevice { } return identifier } - } diff --git a/trackier-ios-sdk.podspec b/trackier-ios-sdk.podspec index adee64b..ae5005f 100644 --- a/trackier-ios-sdk.podspec +++ b/trackier-ios-sdk.podspec @@ -8,8 +8,8 @@ Pod::Spec.new do |s| s.name = 'trackier-ios-sdk' - s.version = '1.6.27' - s.summary = 'This is trackier-ios-sdk 1.6.27' + s.version = '1.6.28' + s.summary = 'This is trackier-ios-sdk 1.6.28' # This description is used to generate tags and improve search results. # * Think: What does it do? Why did you write it? What is the focus? @@ -25,7 +25,7 @@ This is trackier ios SDK which is used for attribution and event tracking in iOS # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'trackier' => 'dev@trackier.com' } - s.source = { :git => 'https://github.com/trackier/ios-sdk.git', :tag => '1.6.27' } + s.source = { :git => 'https://github.com/trackier/ios-sdk.git', :tag => '1.6.28' } # s.social_media_url = 'https://twitter.com/' s.swift_version = '5.0' diff --git a/trackier-ios-sdk/Classes/Constants.swift b/trackier-ios-sdk/Classes/Constants.swift index 04c6b94..f65546b 100644 --- a/trackier-ios-sdk/Classes/Constants.swift +++ b/trackier-ios-sdk/Classes/Constants.swift @@ -8,7 +8,7 @@ import Foundation class Constants { - static let SDK_VERSION = "1.6.27" + static let SDK_VERSION = "1.6.28" static let USER_AGENT = "com.trackier.sdk:ios-sdk:" + SDK_VERSION static let API_VERSION = "v1" static let BASE_URL = "https://events.trackier.io/" + API_VERSION diff --git a/trackier-ios-sdk/Classes/TrackierEvent.swift b/trackier-ios-sdk/Classes/TrackierEvent.swift index 5e9c915..7236b95 100644 --- a/trackier-ios-sdk/Classes/TrackierEvent.swift +++ b/trackier-ios-sdk/Classes/TrackierEvent.swift @@ -28,6 +28,8 @@ public class TrackierEvent { public var param10: String? = "" var revenue: Float64? = 0.0 + var discount: Float64? = 0.0 + var couponCode: String? = "" var ev = [String: Any]() public func addEventValue(prop: String, val: Any) { @@ -41,6 +43,14 @@ public class TrackierEvent { } } + public func setDiscount(discount: Float64) { + self.discount = discount + } + + public func setCouponCode(couponCode: String) { + self.couponCode = couponCode + } + func getHashMap() -> Dictionary { var dict = Dictionary() dict["id"] = self.id @@ -57,6 +67,8 @@ public class TrackierEvent { dict["param10"] = self.param10 dict["currency"] = self.currency dict["revenue"] = self.revenue + dict["discount"] = self.discount + dict["c_code"] = self.couponCode dict["ev"] = self.ev return dict } diff --git a/trackier-ios-sdk/Classes/TrackierSDK.swift b/trackier-ios-sdk/Classes/TrackierSDK.swift index ee3272b..94f7228 100644 --- a/trackier-ios-sdk/Classes/TrackierSDK.swift +++ b/trackier-ios-sdk/Classes/TrackierSDK.swift @@ -71,4 +71,12 @@ public class TrackierSDK { public static func trackAsOrganic(organic: Bool) { shared.instance.organic = organic } + + public static func setUserPhone(userPhone: String) { + shared.instance.customerPhone = userPhone + } + + public static func setUserName(userName: String) { + shared.instance.customerName = userName + } } diff --git a/trackier-ios-sdk/Classes/TrackierSDKInstance.swift b/trackier-ios-sdk/Classes/TrackierSDKInstance.swift index 878ca8f..e398cf7 100644 --- a/trackier-ios-sdk/Classes/TrackierSDKInstance.swift +++ b/trackier-ios-sdk/Classes/TrackierSDKInstance.swift @@ -27,6 +27,8 @@ class TrackierSDKInstance { var customerEmail = "" var customerOptionals: Dictionary? = nil var organic = false + var customerPhone = "" + var customerName = "" /** * Initialize method should be called to initialize the sdk @@ -125,6 +127,8 @@ class TrackierSDKInstance { wrk.customerEmail = customerEmail wrk.customerOptionals = customerOptionals wrk.organic = organic + wrk.customerName = customerName + wrk.customerPhone = customerPhone wrk.eventObj = event DispatchQueue.global().async { APIManager.doWork(workRequest: wrk) @@ -147,6 +151,8 @@ class TrackierSDKInstance { wrk.customerEmail = customerEmail wrk.customerOptionals = customerOptionals wrk.organic = organic + wrk.customerName = customerName + wrk.customerPhone = customerPhone let lastSessionTime = getLastSessionTime() wrk.lastSessionTime = Utils.convertUnixTsToISO(ts: lastSessionTime) let currentSessionTime = Int64(Date().timeIntervalSince1970) diff --git a/trackier-ios-sdk/Classes/TrackierWorkRequest.swift b/trackier-ios-sdk/Classes/TrackierWorkRequest.swift index f972d84..90fd151 100644 --- a/trackier-ios-sdk/Classes/TrackierWorkRequest.swift +++ b/trackier-ios-sdk/Classes/TrackierWorkRequest.swift @@ -28,6 +28,8 @@ class TrackierWorkRequest { var secretId: String = "" var secretKey: String = "" var sdkt = "" + var customerPhone = "" + var customerName = "" init(kind: String, appToken: String, mode: String) { self.kind = kind @@ -59,6 +61,8 @@ class TrackierWorkRequest { } dict["organic"] = organic dict["sdkt"] = sdkt + dict["cphone"] = customerPhone + dict["cname"] = customerName return dict }