Skip to content

Commit

Permalink
Pull request #8: Feature/meg
Browse files Browse the repository at this point in the history
Merge in SST/mobile-testing-ios-sdk from feature/meg to master

* commit 'f6c9291cef711f03d12d19dac64d2227da01de72': (3 commits)
  Mutual exclusive group fixes
  ...
  • Loading branch information
Parvesh Chauhan authored and Vivek Bansal committed Dec 13, 2022
2 parents 9541981 + f6c9291 commit 942bc09
Show file tree
Hide file tree
Showing 24 changed files with 1,298 additions and 28 deletions.
10 changes: 5 additions & 5 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ PODS:
- Socket.IO-Client-Swift (15.2.0):
- Starscream (~> 3.1)
- Starscream (3.1.1)
- VWO (2.8.0):
- VWO/All (= 2.8.0)
- VWO/All (2.8.0):
- VWO (2.11.0):
- VWO/All (= 2.11.0)
- VWO/All (2.11.0):
- Socket.IO-Client-Swift (~> 15.2.0)

DEPENDENCIES:
Expand All @@ -30,8 +30,8 @@ SPEC CHECKSUMS:
SCLAlertView: 6a77bb2edfc65e04dbe57725546cb4107a506b85
Socket.IO-Client-Swift: 1e3e3a1f09f3312a167f0d781eb2f383d477357c
Starscream: 4bb2f9942274833f7b4d296a55504dcfc7edb7b0
VWO: c12710457497bc88cdca575bd3151e246ac5a57c
VWO: cd8207460a018f8d38a5425e7c13e3b76fc63034

PODFILE CHECKSUM: 71bfa555223ee2b1ddab35d14fef462b5e6267e6

COCOAPODS: 1.10.2
COCOAPODS: 1.11.3
2 changes: 2 additions & 0 deletions Demo/VWO Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// setCurrentViewController(vc: houseNav)
setCurrentViewController(vc: phoneNav)
// VWOManager.launch("033cf474a02bb4aafea16dc0685c896a-11000006")

return true
}

Expand Down
8 changes: 6 additions & 2 deletions Demo/VWO Demo/Sorting campaign/PhoneListVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ class PhoneListVC: UIViewController {
print("\(segue.destination) \(segue.source)")
let destination = segue.destination as! PhoneDetailVC
let t = tableView.indexPathForSelectedRow!.row
VWO.trackConversion("productView")

// let TestKey = VWO.getCampaign("e57e8bd1-fb5f-478d-80d2-5127eb5d79f7", args: ["groupId":"8"])
// let TestKey = VWO.getCampaign("e57e8bd1-fb5f-478d-80d2-5127eb5d79f7", args: ["test_key":"ME123"])
let TestKey = VWO.getCampaign("9c3832ad-15f9-420a-93cd-a7f2cde0f7bc", args: ["test_key":"ME123","groupId":"8"])

destination.phone = phoneList[t]
}

Expand All @@ -50,7 +54,7 @@ class PhoneListVC: UIViewController {


@IBAction func reloadTapped(_ sender: Any) {
let variation = VWO.variationNameFor(testKey: "sorting")
let variation = VWO.variationNameFor(testKey: "METest")
switch variation {
case "Sort-Alphabetically":
phoneList.sort(by: sortPhoneAlphabetically)
Expand Down
4 changes: 3 additions & 1 deletion Demo/VWO Demo/VWOManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ class VWOManager {
VWO.logLevel = .debug
let config = VWOConfig()
// config.setCustomDimension(customDimensionKey: "userId", customDimensionValue: "userName")
config.userID = "userId"
config.userID = "9c3832ad-15f9-420a-93cd-a7f2cde0f7bc"
// config.isChinaCDN = false
VWO.launch(apiKey: apiKey, config: config, completion: {
DispatchQueue.main.async {
// VWO.pushCustomDimension(customDimensionKey: "userId", customDimensionValue: "userName")
hud.hide(animated: false)
SCLAlertView().showSuccess("Success", subTitle: "VWO launched successfully \(apiKey)")


}
}, failure: { (errorString) in
DispatchQueue.main.async {
Expand Down
56 changes: 56 additions & 0 deletions VWO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

/* Begin PBXBuildFile section */
32C4822427A421CE007128E3 /* SocketIO in Frameworks */ = {isa = PBXBuildFile; productRef = 32C4822327A421CE007128E3 /* SocketIO */; };
7B165B05293756EE0060EEE2 /* MutuallyExclusiveGroups.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B165B03293756EE0060EEE2 /* MutuallyExclusiveGroups.h */; };
7B165B06293756EE0060EEE2 /* MutuallyExclusiveGroups.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B165B04293756EE0060EEE2 /* MutuallyExclusiveGroups.m */; };
7B165B0929376B6E0060EEE2 /* Group.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B165B0729376B6E0060EEE2 /* Group.h */; };
7B165B0A29376B6E0060EEE2 /* Group.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B165B0829376B6E0060EEE2 /* Group.m */; };
7B165B0D29376B8C0060EEE2 /* CampaignUniquenessTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B165B0B29376B8C0060EEE2 /* CampaignUniquenessTracker.h */; };
7B165B0E29376B8C0060EEE2 /* CampaignUniquenessTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B165B0C29376B8C0060EEE2 /* CampaignUniquenessTracker.m */; };
7B165B1129376BA30060EEE2 /* CampaignGroupMapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B165B0F29376BA30060EEE2 /* CampaignGroupMapper.h */; };
7B165B1229376BA30060EEE2 /* CampaignGroupMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B165B1029376BA30060EEE2 /* CampaignGroupMapper.m */; };
7B165B1529383B1D0060EEE2 /* MurmurHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B165B1329383B1D0060EEE2 /* MurmurHash.h */; };
7B165B1629383B1D0060EEE2 /* MurmurHash.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B165B1429383B1D0060EEE2 /* MurmurHash.m */; };
7B6B7E09294094AA00961493 /* VWOGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6B7E07294094AA00961493 /* VWOGroup.h */; };
7B6B7E0A294094AA00961493 /* VWOGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6B7E08294094AA00961493 /* VWOGroup.m */; };
E31714C71F838C2F0036CF07 /* VWOTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E31714C61F838C2F0036CF07 /* VWOTests.swift */; };
E32079C120075516005CB5CD /* CampaignIDMissing.json in Resources */ = {isa = PBXBuildFile; fileRef = E32079C020075516005CB5CD /* CampaignIDMissing.json */; };
E32079C320075541005CB5CD /* CampaignStatusMissing.json in Resources */ = {isa = PBXBuildFile; fileRef = E32079C220075541005CB5CD /* CampaignStatusMissing.json */; };
Expand Down Expand Up @@ -136,6 +148,18 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
7B165B03293756EE0060EEE2 /* MutuallyExclusiveGroups.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MutuallyExclusiveGroups.h; sourceTree = "<group>"; };
7B165B04293756EE0060EEE2 /* MutuallyExclusiveGroups.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MutuallyExclusiveGroups.m; sourceTree = "<group>"; };
7B165B0729376B6E0060EEE2 /* Group.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Group.h; sourceTree = "<group>"; };
7B165B0829376B6E0060EEE2 /* Group.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Group.m; sourceTree = "<group>"; };
7B165B0B29376B8C0060EEE2 /* CampaignUniquenessTracker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CampaignUniquenessTracker.h; sourceTree = "<group>"; };
7B165B0C29376B8C0060EEE2 /* CampaignUniquenessTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CampaignUniquenessTracker.m; sourceTree = "<group>"; };
7B165B0F29376BA30060EEE2 /* CampaignGroupMapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CampaignGroupMapper.h; sourceTree = "<group>"; };
7B165B1029376BA30060EEE2 /* CampaignGroupMapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CampaignGroupMapper.m; sourceTree = "<group>"; };
7B165B1329383B1D0060EEE2 /* MurmurHash.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MurmurHash.h; sourceTree = "<group>"; };
7B165B1429383B1D0060EEE2 /* MurmurHash.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MurmurHash.m; sourceTree = "<group>"; };
7B6B7E07294094AA00961493 /* VWOGroup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VWOGroup.h; sourceTree = "<group>"; };
7B6B7E08294094AA00961493 /* VWOGroup.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VWOGroup.m; sourceTree = "<group>"; };
E31714C51F838C2F0036CF07 /* VWOTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "VWOTests-Bridging-Header.h"; sourceTree = "<group>"; };
E31714C61F838C2F0036CF07 /* VWOTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VWOTests.swift; sourceTree = "<group>"; };
E319151E1F67F1B900FC1695 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -267,6 +291,23 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
7B165AF82936AEA70060EEE2 /* MEG */ = {
isa = PBXGroup;
children = (
7B165B03293756EE0060EEE2 /* MutuallyExclusiveGroups.h */,
7B165B04293756EE0060EEE2 /* MutuallyExclusiveGroups.m */,
7B165B0729376B6E0060EEE2 /* Group.h */,
7B165B0829376B6E0060EEE2 /* Group.m */,
7B165B0B29376B8C0060EEE2 /* CampaignUniquenessTracker.h */,
7B165B0C29376B8C0060EEE2 /* CampaignUniquenessTracker.m */,
7B165B0F29376BA30060EEE2 /* CampaignGroupMapper.h */,
7B165B1029376BA30060EEE2 /* CampaignGroupMapper.m */,
7B165B1329383B1D0060EEE2 /* MurmurHash.h */,
7B165B1429383B1D0060EEE2 /* MurmurHash.m */,
);
path = MEG;
sourceTree = "<group>";
};
E3529571206B704600C90716 /* Socket */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -314,6 +355,7 @@
E39814D81F6288C80035D519 /* VWO */ = {
isa = PBXGroup;
children = (
7B165AF82936AEA70060EEE2 /* MEG */,
E39814D91F6288C80035D519 /* VWO.h */,
E36AC7181F75614E0041ACDF /* VWO.m */,
E39815731F6291960035D519 /* VWOController.h */,
Expand Down Expand Up @@ -382,6 +424,8 @@
E398154C1F6291680035D519 /* VWOVariation.m */,
E3F7CBB22004C91400CC8C03 /* VWOSegment.h */,
E3F7CBB32004C91400CC8C03 /* VWOSegment.m */,
7B6B7E07294094AA00961493 /* VWOGroup.h */,
7B6B7E08294094AA00961493 /* VWOGroup.m */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -493,21 +537,26 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
7B6B7E09294094AA00961493 /* VWOGroup.h in Headers */,
E39815851F6291970035D519 /* VWOLogger.h in Headers */,
E39815591F6291680035D519 /* VWOGoal.h in Headers */,
E3871A1D212FE27C0033D86B /* NSString+MD5.h in Headers */,
E3D29FCA1FBEDE2A00A11C61 /* NSString+VWO.h in Headers */,
E3D29FC61FBEDAB300A11C61 /* NSDate+VWO.h in Headers */,
E39815811F6291970035D519 /* VWODevice.h in Headers */,
7B165B1529383B1D0060EEE2 /* MurmurHash.h in Headers */,
E398155B1F6291680035D519 /* VWOQueue.h in Headers */,
E3F7CBAC2004A9B100CC8C03 /* VWOStack.h in Headers */,
E388B6CE1F8F7D350023E11E /* VWOURLQueue.h in Headers */,
E344B2F01F87906900A4EEE6 /* VWOUserDefaults.h in Headers */,
E39815571F6291680035D519 /* VWOCampaign.h in Headers */,
E39815831F6291970035D519 /* VWOFile.h in Headers */,
7B165B0929376B6E0060EEE2 /* Group.h in Headers */,
7B165B05293756EE0060EEE2 /* MutuallyExclusiveGroups.h in Headers */,
E35484F51F713C2E00E14D2E /* NSURLSession+Synchronous.h in Headers */,
E3529574206B720A00C90716 /* VWOSocketConnector.h in Headers */,
E3E95E8D206D0B13006DCE6C /* VWOConfig.h in Headers */,
7B165B1129376BA30060EEE2 /* CampaignGroupMapper.h in Headers */,
E398155F1F6291680035D519 /* VWOVariation.h in Headers */,
E39567A3206E5DA80030B30B /* VWOCampaignFetcher.h in Headers */,
E3BBA3602068FA630046B2F2 /* VWOSocket.h in Headers */,
Expand All @@ -516,6 +565,7 @@
E3D5F7FD1F6BD86C0011C43C /* VWOURL.h in Headers */,
E3F7CBB42004C91400CC8C03 /* VWOSegment.h in Headers */,
E398159C1F6293BC0035D519 /* NSDictionary+VWO.h in Headers */,
7B165B0D29376B8C0060EEE2 /* CampaignUniquenessTracker.h in Headers */,
E3F7CBA82004A07800CC8C03 /* VWOInfixEvaluator.h in Headers */,
E39814E71F6288C80035D519 /* VWO.h in Headers */,
);
Expand Down Expand Up @@ -659,22 +709,28 @@
buildActionMask = 2147483647;
files = (
E344B2F11F87906900A4EEE6 /* VWOUserDefaults.m in Sources */,
7B165B1629383B1D0060EEE2 /* MurmurHash.m in Sources */,
7B165B06293756EE0060EEE2 /* MutuallyExclusiveGroups.m in Sources */,
E3D29FC71FBEDAB300A11C61 /* NSDate+VWO.m in Sources */,
E3871A1E212FE27C0033D86B /* NSString+MD5.m in Sources */,
E36AC7191F75614E0041ACDF /* VWO.m in Sources */,
E3F7CBAD2004A9B100CC8C03 /* VWOStack.m in Sources */,
E39567A4206E5DA80030B30B /* VWOCampaignFetcher.m in Sources */,
E3BBA3612068FA630046B2F2 /* VWOSocket.m in Sources */,
E39815941F6291C10035D519 /* VWOSegmentEvaluator.m in Sources */,
7B6B7E0A294094AA00961493 /* VWOGroup.m in Sources */,
7B165B0A29376B6E0060EEE2 /* Group.m in Sources */,
E3E95E8E206D0B13006DCE6C /* VWOConfig.m in Sources */,
E35484F61F713C2E00E14D2E /* NSURLSession+Synchronous.m in Sources */,
E398159D1F6293BC0035D519 /* NSDictionary+VWO.m in Sources */,
E39815861F6291970035D519 /* VWOLogger.m in Sources */,
7B165B0E29376B8C0060EEE2 /* CampaignUniquenessTracker.m in Sources */,
E39815821F6291970035D519 /* VWODevice.m in Sources */,
E398155A1F6291680035D519 /* VWOGoal.m in Sources */,
E3529575206B720A00C90716 /* VWOSocketConnector.m in Sources */,
E3D5F7FE1F6BD86C0011C43C /* VWOURL.m in Sources */,
E39815801F6291970035D519 /* VWOController.m in Sources */,
7B165B1229376BA30060EEE2 /* CampaignGroupMapper.m in Sources */,
E398155C1F6291680035D519 /* VWOQueue.m in Sources */,
E3F7CBA92004A07800CC8C03 /* VWOInfixEvaluator.m in Sources */,
E39815601F6291680035D519 /* VWOVariation.m in Sources */,
Expand Down
19 changes: 19 additions & 0 deletions VWO/MEG/CampaignGroupMapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CampaignGroupMapper.h
// VWO
//
// Created by Harsh Raghav on 30/11/22.
// Copyright © 2022 vwo. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface CampaignGroupMapper : NSObject

+ (NSDictionary *)getCampaignGroups: (NSDictionary *)jsonObject;
+ (NSDictionary *)createAndGetGroups: (NSDictionary *)jsonObject;
@end

NS_ASSUME_NONNULL_END
90 changes: 90 additions & 0 deletions VWO/MEG/CampaignGroupMapper.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// CampaignGroupMapper.m
// VWO
//
// Created by Harsh Raghav on 30/11/22.
// Copyright © 2022 vwo. All rights reserved.
//

#import "CampaignGroupMapper.h"
#import "VWOLogger.h"
#import "VWOCampaign.h"
#import "Group.h"

@implementation CampaignGroupMapper

static NSString * const KEY_CAMPAIGN_GROUPS = @"campaignGroups";
static NSString * const KEY_GROUPS = @"groups";
static NSString * const KEY_NAME = @"name";
static NSString * const KEY_CAMPAIGNS = @"campaigns";

float m = 1.0;

//months,

+ (NSDictionary *)getCampaignGroups: (NSDictionary *)jsonObject{

NSDictionary* jsonCampaignGroups = nil;
@try {
jsonCampaignGroups = jsonObject[KEY_CAMPAIGN_GROUPS];
}
@catch (NSException *exception) {
VWOLogDebug(@"MutuallyExclusive %@", exception);

}
return jsonCampaignGroups;
}


+ (NSDictionary *)createAndGetGroups: (NSDictionary *)jsonObject{
NSMutableDictionary<NSString*, Group*> *groups = [NSMutableDictionary new];
@try{
NSDictionary *jsonGroups = [self getGroups:jsonObject];

if(jsonGroups == nil) return groups;

NSArray<NSString*> *itrJsonGroups = [jsonGroups allKeys];
int index=0;
while (index < itrJsonGroups.count) {
NSString *key = itrJsonGroups[index];

NSDictionary *objGroup = jsonGroups[key];
NSArray *arrCampaigns = objGroup[KEY_CAMPAIGNS];

NSString *groupName = objGroup[KEY_NAME];

Group *group = [[Group alloc]init];
group.name = groupName;
group.Id = key.intValue;

for (int i = 0; i < arrCampaigns.count; i++) {
[group addCampaign:arrCampaigns[i]];
}
VWOLogDebug(@"MutuallyExclusive Added Group Id %d", group.Id);
VWOLogDebug(@"MutuallyExclusive Added Group Campaign %@", group.getCampaigns);

[groups setObject:group forKey:groupName];
index++;
}
}

@catch (NSException *exception) {
VWOLogDebug(@"MutuallyExclusive error while adding groups %@", exception);
}
return groups;
}

+ (NSDictionary *)getGroups: (NSDictionary *)jsonObject{
NSDictionary *jsonGroups = nil;

@try {
VWOCampaign *groupDict = [jsonObject objectForKey:KEY_GROUPS] ;
jsonGroups = groupDict.group.groups;
}
@catch (NSException *exception) {
VWOLogDebug(@"MutuallyExclusive %@", exception);
}
return jsonGroups;
}

@end
22 changes: 22 additions & 0 deletions VWO/MEG/CampaignUniquenessTracker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// CampaignUniquenessTracker.h
// VWO
//
// Created by Harsh Raghav on 30/11/22.
// Copyright © 2022 vwo. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface CampaignUniquenessTracker : NSObject {

}

- (BOOL)groupContainsCampaign:(NSString *) campaign;
- (NSString *)getNameOfGroupFor:(NSString *) campaign;
- (void)addCampaignAsRegistered:(NSString *) campaign group:(NSString *) group;
@end

NS_ASSUME_NONNULL_END
47 changes: 47 additions & 0 deletions VWO/MEG/CampaignUniquenessTracker.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// CampaignUniquenessTracker.m
// VWO
//
// Created by Harsh Raghav on 30/11/22.
// Copyright © 2022 vwo. All rights reserved.
//

#import "CampaignUniquenessTracker.h"

@implementation CampaignUniquenessTracker

-(id) init
{
self = [super init];
if(self)
{
//do something
}
return self;
}

static NSMutableDictionary<NSString *, NSString *> * CAMPAIGNS;

- (BOOL)groupContainsCampaign:(NSString *) campaign{

if (CAMPAIGNS == nil) {
CAMPAIGNS = [NSMutableDictionary new];
}
return (CAMPAIGNS[campaign] != nil);
}

- (NSString *)getNameOfGroupFor:(NSString *) campaign{
if (CAMPAIGNS == nil) {
CAMPAIGNS = [NSMutableDictionary new];
}
return CAMPAIGNS[campaign];
}
- (void)addCampaignAsRegistered:(NSString *) campaign group:(NSString *) group
{
if (CAMPAIGNS == nil) {
CAMPAIGNS = [NSMutableDictionary new];
}
[CAMPAIGNS setObject:campaign forKey:group];
}

@end
Loading

0 comments on commit 942bc09

Please sign in to comment.