Manos Chorianopoulos

add trackers v1

......@@ -107,6 +107,7 @@
- (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
- (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
@end
#endif /* MyApi_h */
......
......@@ -11,6 +11,10 @@
#import "WLUtils.h"
#import <SwiftWarplyFramework.h>
//#import "WLUserManager.h"
//#import "WLAnalyticsManager.h"
//#import <AdSupport/AdSupport.h>
@implementation MyApi
NSString *WARP_PRODUCTION_BASE_URL = @"https://engage.warp.ly";
......@@ -1659,4 +1663,14 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority {
NSString *event_Name = eventName;
NSNumber *time_submitted = [NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]];
NSDictionary *inapp_event = [NSDictionary dictionaryWithObjectsAndKeys:event_Name, @"event_id", nil, @"page_id", time_submitted, @"time_submitted", nil, @"action_metadata", nil];
NSDictionary *eventContext = [NSDictionary dictionaryWithObject:inapp_event forKey:@"inapp_analytics"];
WLEventSimple *simpleEvent = [[WLEventSimple alloc] initWithType:@"inapp_analytics" andContext:eventContext];
[[Warply sharedService] addEvent:simpleEvent priority:priority];
}
@end
......
......@@ -72,6 +72,14 @@ public class swiftApi {
UserDefaults.standard.set(newValue, forKey: "userNonTelco")
}
public func getTrackersEnabledUD() -> Bool {
return UserDefaults.standard.bool(forKey: "trackersEnabled")
}
public func setTrackersEnabledUD(_ newValue: Bool) -> Void {
UserDefaults.standard.set(newValue, forKey: "trackersEnabled")
}
public func getStepsWebview() -> Int {
return GlobalVariables.stepsWebview
}
......@@ -5788,18 +5796,31 @@ public class swiftApi {
public func setTrackersEnabled(_ isEnabled: Bool) -> Void {
var newProfileMetadata: [String: Any] = ["trackers_enabled": isEnabled]
swiftApi().setTrackersEnabledUD(isEnabled)
swiftApi().editProfileAsync(firstname: "", lastname: "", email: "", salutation: "", msisdn: "", nickname: "", gender: "", birthday: "", nameday: "", taxid: "", profileMetadata: newProfileMetadata, optin: false, newsletter: false, sms: false, segmentation: false, smsSegmentation: false, editProfileCallback)
// var newProfileMetadata: [String: Any] = ["trackers_enabled": isEnabled]
func editProfileCallback (_ editProfileData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (editProfileData != nil) {
// swiftApi().editProfileAsync(firstname: "", lastname: "", email: "", salutation: "", msisdn: "", nickname: "", gender: "", birthday: "", nameday: "", taxid: "", profileMetadata: newProfileMetadata, optin: false, newsletter: false, sms: false, segmentation: false, smsSegmentation: false, editProfileCallback)
DispatchQueue.main.async {
}
} else {
// func editProfileCallback (_ editProfileData: swiftApi.VerifyTicketResponseModel?) -> Void {
// if (editProfileData != nil) {
// DispatchQueue.main.async {
// }
// } else {
// }
// }
}
public func logTrackersEvent(_ eventType: String, _ eventName: String) -> Void {
if (swiftApi().getTrackersEnabledUD() == true) {
let instanceOfMyApi = MyApi()
let eventFullName = eventType + ":" + eventName
instanceOfMyApi.sendEvent(eventFullName, priority: false)
}
}
......