Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
王洋洋 committed Apr 6, 2023
1 parent e557de1 commit 7cea80d
Show file tree
Hide file tree
Showing 36 changed files with 1,959 additions and 452 deletions.
15 changes: 11 additions & 4 deletions Example/Example-iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#import <SensorsABTest.h>

/// 测试环境,获取试验地址
static NSString* kSABResultsTestURL = @"http://10.129.138.19:8202/api/v2/abtest/online/results?project-key=4D3483ECF05968FC4522BB2B52CB3B1CCA1D3FCA";
static NSString* kSABResultsTestURL = @"http://10.129.29.10:8202/api/v2/abtest/online/results?project-key=130EB9E0EE57A09D91AC167C6CE63F7723CE0B22";

// 测试环境,数据接收地址
static NSString* kSABTestServerURL = @"http://10.130.6.4:8106/sa?project=default";
static NSString* kSABTestServerURL = @"http://10.129.28.106:8106/sa?project=default";

@interface AppDelegate ()

Expand All @@ -47,21 +47,28 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

- (void)startSensorsAnalyticsSDKWithConfigOptions:(NSDictionary *)launchOptions {
SAConfigOptions *options = [[SAConfigOptions alloc] initWithServerURL:kSABTestServerURL launchOptions:launchOptions];
options.autoTrackEventType = SensorsAnalyticsEventTypeAppStart | SensorsAnalyticsEventTypeAppEnd | SensorsAnalyticsEventTypeAppClick | SensorsAnalyticsEventTypeAppViewScreen;
// options.autoTrackEventType = SensorsAnalyticsEventTypeAppStart | SensorsAnalyticsEventTypeAppEnd | SensorsAnalyticsEventTypeAppClick | SensorsAnalyticsEventTypeAppViewScreen;
options.autoTrackEventType = SensorsAnalyticsEventTypeAppStart | SensorsAnalyticsEventTypeAppEnd | SensorsAnalyticsEventTypeAppViewScreen;

options.enableHeatMap = YES;
options.enableVisualizedAutoTrack = YES;
options.enableJavaScriptBridge = YES;
#ifdef DEBUG
options.enableLog = YES;
options.flushNetworkPolicy = SensorsAnalyticsNetworkTypeNONE;
#endif


[SensorsAnalyticsSDK startWithConfigOptions:options];

}

- (void)startSensorsABTest {
SensorsABTestConfigOptions *abtestConfigOptions = [[SensorsABTestConfigOptions alloc] initWithURL:kSABResultsTestURL];
[SensorsABTest startWithConfigOptions:abtestConfigOptions];


[SensorsABTest.sharedInstance setCustomIDs:@{@"custom_subject_id":@"iOS自定义主体333"}];

}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
Expand Down
212 changes: 149 additions & 63 deletions Example/Example-iOS/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

44 changes: 37 additions & 7 deletions Example/Example-iOS/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,45 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}
break;
case 3: { // other
case 3: { // Subject 多主体,fache 接口
switch (row) { //
case 0: { // user 主体
id result = [[SensorsABTest sharedInstance] fetchCacheABTestWithParamName:@"li" defaultValue:@(1111)];
NSLog(@"fetchCacheABTest,Subject User,paramName:%@ - result:%@\n", @"li", result);
}
break;

case 1: { // device 主体
id result = [[SensorsABTest sharedInstance] fetchCacheABTestWithParamName:@"cqs_color" defaultValue:@"默认试验值"];
NSLog(@"fetchCacheABTest,Subject Device,paramName:%@ - result:%@\n", @"cqs_color", result);
}
break;
case 2: { // custom 主体
id result = [[SensorsABTest sharedInstance] fetchCacheABTestWithParamName:@"cqs_os" defaultValue:@"默认试验值"];
NSLog(@"fetchCacheABTest,Subject Custom,paramName:%@ - result:%@\n", @"cqs_os", result);
}
break;
case 3: { // 自定义属性试验
SensorsABTestExperiment *experiment = [[SensorsABTestExperiment alloc] initWithParamName:@"cqs_device" defaultValue:@"设备默认值"];
experiment.properties = @{@"device": @"iPhone"};
[[SensorsABTest sharedInstance] fastFetchABTestWithExperiment:experiment completionHandler:^(id _Nullable result) {

NSLog(@"fastFetchABTestWithExperiment,自定义属性 device 试验,paramName:%@ - result:%@\n", @"cqs_device", result);
}];
}
break;
default:
break;
}
}
break;
case 4: { // other
switch (row) { //
case 0: { // flush
[[SensorsAnalyticsSDK sharedInstance] flush];
}
break;

case 1: { // go webView
WKWebViewController *webViewVC = [[WKWebViewController alloc] init];
[self.navigationController pushViewController:webViewVC animated:YES];
Expand All @@ -172,7 +204,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}
break;
case 4: { // login、logout、identify 、resetAnonymousId
case 5: { // login、logout、identify 、resetAnonymousId
switch (row) {
case 0: { // login
[[SensorsAnalyticsSDK sharedInstance] login:@"login_test_20201217" withProperties:@{ @"name": @"batest_relod_login" }];
Expand All @@ -198,8 +230,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
break;
}
}
break;
// other
case 5: {
case 6: {
switch (row) {
case 0: {

Expand All @@ -211,19 +244,16 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
dispatch_async(serialQueue1, ^{
id result = [[SensorsABTest sharedInstance] fetchCacheABTestWithParamName:@"index_cqs" defaultValue:@(1111)];
NSLog(@"fetchCacheABTest1,paramName:%@ - result:%@\n", @"index_cqs", result);

});

dispatch_async(serialQueue2, ^{
id result = [[SensorsABTest sharedInstance] fetchCacheABTestWithParamName:@"index_cqs" defaultValue:@(2222)];
NSLog(@"fetchCacheABTest2,paramName:%@ - result:%@\n", @"index_cqs", result);

});

dispatch_async(serialQueue3, ^{
id result = [[SensorsABTest sharedInstance] fetchCacheABTestWithParamName:@"index_cqs" defaultValue:@(3333)];
NSLog(@"fetchCacheABTest3,paramName:%@ - result:%@\n", @"index_cqs", result);

});
}
}
Expand Down
3 changes: 3 additions & 0 deletions Example/Example-iOS/WKWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ - (void)viewDidLoad {
// 不做多链接试验
// httpStr = @"http://jssdk.debugbox.sensorsdata.cn/js/ls/ab/index.html?saSDKMultilink=true";

// 配置化测试
// httpStr = @"http://10.120.195.209/js/zyf/abtest_regex/index.html";

NSURL *httpUrl = [NSURL URLWithString:httpStr];
NSURLRequest *request = [NSURLRequest requestWithURL:httpUrl];

Expand Down
2 changes: 1 addition & 1 deletion Example/Example-macOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
static NSString *const SADefaultServerURL = @"http://10.130.6.4:8106/sa?project=default";

/// 测试环境,获取试验地址
static NSString* kSABResultsTestURL = @"http://10.129.138.19:8202/api/v2/abtest/online/results?project-key=4D3483ECF05968FC4522BB2B52CB3B1CCA1D3FCA";
static NSString* kSABResultsTestURL = @"http://10.129.29.10:8202/api/v2/abtest/online/results?project-key=130EB9E0EE57A09D91AC167C6CE63F7723CE0B22";

@interface AppDelegate ()

Expand Down
Loading

0 comments on commit 7cea80d

Please sign in to comment.