Skip to content

Commit

Permalink
Revenue and Discount bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
IloveJavaa committed Aug 9, 2022
1 parent e1e547f commit cb621b1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class TrackierfluttersdkPlugin : FlutterPlugin, MethodCallHandler {
discount = configMap.get("discount") as Double
trackierEvent.discount = discount.toFloat()
}
if (configMap.containsKey("c_code")) {
couponCode = configMap.get("c_code") as String
if (configMap.containsKey("couponCode")) {
couponCode = configMap.get("couponCode") as String
trackierEvent.couponCode = couponCode
}
if (configMap.containsKey("param1")) {
Expand Down
8 changes: 6 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _MyAppState extends State<MyApp> {
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
TrackerSDKConfig trackerSDKConfig =
new TrackerSDKConfig("xxfe3694-1ef5-430d-baa7-01ba36332xxx", "development");
new TrackerSDKConfig("0455721b-33c5-4c9f-805e-596d818d910a", "development");//xxfe3694-1ef5-430d-baa7-01ba36332xxx

Trackierfluttersdk.setUserId("this_is_a_userId");
Trackierfluttersdk.setUserEmail("[email protected]");
Expand Down Expand Up @@ -102,8 +102,12 @@ class _MyAppState extends State<MyApp> {

_trackSimpleEvent() {
TrackierEvent trackierEvent = new TrackierEvent("1CFfUn3xEY");
trackierEvent.revenue = 10.0;
trackierEvent.revenue = 70.0;
trackierEvent.discount = 2.0;
trackierEvent.currency = "INR";
trackierEvent.orderId = "orderID";
trackierEvent.param1 = "param1";
trackierEvent.param2 = "param2";
trackierEvent.couponCode = "test1";
Trackierfluttersdk.setUserName("abc");
Trackierfluttersdk.setUserPhone("6562127727");
Expand Down
10 changes: 5 additions & 5 deletions ios/Classes/SwiftTrackierfluttersdkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public class SwiftTrackierfluttersdkPlugin: NSObject, FlutterPlugin {
func trackEvent(dict: Optional<Dictionary<String, Any>>) -> Void {
let eventId: String = "\(dict?["eventId"] as? String ?? "")"
let currency: String = "\(dict?["currency"] as? String ?? "")"
let revenue: String = "\(dict?["revenue"] as? String ?? "")"
let revenue: Float64 = (dict?["revenue"] as? Float64 ?? 0.0)
let orderId: String = "\(dict?["orderId"] as? String ?? "")"
let discount: String = "\(dict?["discount"] as? String ?? "")"
let couponCode: String = "\(dict?["c_code"] as? String ?? "")"
let discount: Float64 = (dict?["discount"] as? Float64 ?? 0.0)
let couponCode: String = "\(dict?["couponCode"] as? String ?? "")"
let param1: String = "\(dict?["param1"] as? String ?? "")"
let param2: String = "\(dict?["param2"] as? String ?? "")"
let param3: String = "\(dict?["param3"] as? String ?? "")"
Expand All @@ -94,10 +94,10 @@ public class SwiftTrackierfluttersdkPlugin: NSObject, FlutterPlugin {
}

let event = TrackierEvent(id: eventId)
event.setRevenue(revenue: Float64((revenue as NSString).floatValue), currency: currency)
event.setRevenue(revenue: Float64(revenue), currency: currency)
event.orderId = orderId
event.setCouponCode(couponCode: couponCode)
event.setDiscount(discount: Float64((discount as NSString).floatValue))
event.setDiscount(discount: Float64(discount))
event.param1 = param1
event.param2 = param2
event.param3 = param3
Expand Down
2 changes: 1 addition & 1 deletion lib/trackierevent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TrackierEvent {
Map<String, Object?> eventMap = {
'eventId': eventId,
'orderId': orderId,
'c_code' : couponCode,
'couponCode' : couponCode,
'discount' : discount,
'currency': currency,
'revenue': revenue,
Expand Down

0 comments on commit cb621b1

Please sign in to comment.