Skip to content

Commit

Permalink
Added extra fields in event (#19)
Browse files Browse the repository at this point in the history
* Added extra field in events

* Minor_changes

* MinorChanges

* Update Example/trackier-ios-sdk/AppDelegate.swift

Co-authored-by: Hemant Mann <hemant.mann121@gmail.com>
  • Loading branch information
IloveJavaa and Hemant-Mann authored Aug 8, 2022
1 parent 2208496 commit bb19aef
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand Down
24 changes: 13 additions & 11 deletions Example/trackier-ios-sdk/Base.lproj/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -17,15 +14,15 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 CocoaPods. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<rect key="frame" x="20" y="439" width="440" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="trackier-ios-sdk" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<rect key="frame" x="20" y="139.5" width="440" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand All @@ -40,7 +37,12 @@
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
<point key="canvasLocation" x="243" y="139"/>
</view>
</objects>
<resources>
<systemColor name="darkTextColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
31 changes: 30 additions & 1 deletion Example/trackier-ios-sdk/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,41 @@
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ppo-Ja-VKg">
<rect key="frame" x="76" y="95" width="230" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Simple Events">
<backgroundConfiguration key="background">
<color key="backgroundColor" systemColor="linkColor"/>
</backgroundConfiguration>
<color key="baseForegroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mj5-oG-ybm">
<rect key="frame" x="49" y="149" width="278" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Revenue Events">
<backgroundConfiguration key="background">
<color key="backgroundColor" systemColor="linkColor"/>
</backgroundConfiguration>
<color key="baseForegroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</buttonConfiguration>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="22" y="113"/>
<point key="canvasLocation" x="21.600000000000001" y="112.89355322338831"/>
</scene>
</scenes>
<resources>
<systemColor name="linkColor">
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
45 changes: 19 additions & 26 deletions Example/trackier-ios-sdk/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand All @@ -93,6 +87,5 @@ extension UIDevice {
}
return identifier
}

}

6 changes: 3 additions & 3 deletions trackier-ios-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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/<TWITTER_USERNAME>'

s.swift_version = '5.0'
Expand Down
2 changes: 1 addition & 1 deletion trackier-ios-sdk/Classes/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions trackier-ios-sdk/Classes/TrackierEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<String, Any> {
var dict = Dictionary<String, Any>()
dict["id"] = self.id
Expand All @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions trackier-ios-sdk/Classes/TrackierSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
6 changes: 6 additions & 0 deletions trackier-ios-sdk/Classes/TrackierSDKInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class TrackierSDKInstance {
var customerEmail = ""
var customerOptionals: Dictionary<String, Any>? = nil
var organic = false
var customerPhone = ""
var customerName = ""

/**
* Initialize method should be called to initialize the sdk
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions trackier-ios-sdk/Classes/TrackierWorkRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,6 +61,8 @@ class TrackierWorkRequest {
}
dict["organic"] = organic
dict["sdkt"] = sdkt
dict["cphone"] = customerPhone
dict["cname"] = customerName
return dict
}

Expand Down

0 comments on commit bb19aef

Please sign in to comment.