Skip to content

Commit

Permalink
Release 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuhan ZOU committed Mar 6, 2016
1 parent 21be93a commit ded8958
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
8 changes: 4 additions & 4 deletions SensorsAnalyticsSDK/HelloSensorsAnalytics/DemoController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ - (void)didReceiveMemoryWarning {
}

- (void)testInit {
[SensorsAnalyticsSDK sharedInstanceWithServerURL:@"http://sa_host:8006/sa"
andConfigureURL:@"http://sa_host:8133/api/vtrack/config/iOS.conf"
andVTrackServerURL:@"ws://sa_host:8020/ws"
andDebugMode:SensorsAnalyticsDebugOff];
[SensorsAnalyticsSDK sharedInstanceWithServerURL:@"http://sa_host:8006/sa?token=e6a62d9f88674650"
andConfigureURL:@"http://sa_host:8007/api/vtrack/config/iOS.conf"
andVTrackServerURL:@"ws://sa_host:8007/ws"
andDebugMode:SensorsAnalyticsDebugOnly];
}

- (void)testTrack {
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/SensorsAnalyticsSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SensorsAnalyticsSDK"
s.version = "1.3.1"
s.version = "1.3.2"
s.summary = "The offical iOS SDK of Sensors Analytics."
s.homepage = "http://www.sensorsdata.cn"
s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" }
Expand Down
21 changes: 19 additions & 2 deletions SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,32 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsDebugMode) {

/**
* @abstract
* 根据传入的所部署的 Sensors Analytics 服务器的URL,返回一个<code>SensorsAnalyticsSDK</code>的单例
* 根据传入的配置,返回一个关闭可视化埋点功能的<code>SensorsAnalyticsSDK</code>的单例
*
* @discussion
* 若不需要可视化埋点功能,则 configureURL 和 vtrackServerURL 参数传入 nil 即可。
*
* @param serverURL 收集事件的URL
* @param configureURL 获取配置信息的URL
* @param debugMode Sensors Analytics 的Debug模式
*
* @return 返回的单例
*/
+ (SensorsAnalyticsSDK *)sharedInstanceWithServerURL:(NSString *)serverURL
andConfigureURL:(NSString *)configureURL
andDebugMode:(SensorsAnalyticsDebugMode)debugMode;

/**
* @abstract
* 根据传入的配置,返回一个<code>SensorsAnalyticsSDK</code>的单例
*
* @discussion
* 若不需要可视化埋点功能,则 configureURL 和 vtrackServerURL 参数传入 nil 即可。
*
* @param serverURL 收集事件的URL
* @param configureURL 获取配置信息的URL
* @param vtrackServerURL 可视化埋点配置系统的URL
* @param debugMode 是否打开SensorsAnalytics的Debug模式
* @param debugMode Sensors Analytics 的Debug模式
*
* @return 返回的单例
*/
Expand Down
24 changes: 15 additions & 9 deletions SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "SASwizzler.h"
#import "SensorsAnalyticsSDK.h"

#define VERSION @"1.3.1"
#define VERSION @"1.3.2"

@implementation SensorsAnalyticsDebugException

Expand Down Expand Up @@ -72,6 +72,16 @@ @implementation SensorsAnalyticsSDK {

#pragma mark - Initialization

+ (SensorsAnalyticsSDK *)sharedInstanceWithServerURL:(NSString *)serverURL
andConfigureURL:(NSString *)configureURL
andDebugMode:(SensorsAnalyticsDebugMode)debugMode {
return [SensorsAnalyticsSDK sharedInstanceWithServerURL:serverURL
andConfigureURL:configureURL
andVTrackServerURL:nil
andDebugMode:debugMode];
}


+ (SensorsAnalyticsSDK *)sharedInstanceWithServerURL:(NSString *)serverURL
andConfigureURL:(NSString *)configureURL
andVTrackServerURL:(NSString *)vtrackServerURL
Expand Down Expand Up @@ -121,18 +131,14 @@ - (instancetype)initWithServerURL:(NSString *)serverURL
andDebugMode:(SensorsAnalyticsDebugMode)debugMode {
if (serverURL == nil || [serverURL length] == 0) {
@throw [NSException exceptionWithName:@"InvalidArgumentException"
reason:@"serverURL, configureURL or vtrackServerURL is nil"
reason:@"serverURL is nil"
userInfo:nil];
}

if (debugMode != SensorsAnalyticsDebugOff) {
NSURL *serverUrl = [NSURL URLWithString:serverURL];
if ([serverUrl.path length] < [@"debug" length] || ![serverUrl.path hasSuffix:@"debug"]) {
NSString *errMsg = [NSString stringWithFormat:@"The server url of SensorsAnalytics must ends with 'debug' while DEBUG mode is defined. [url='%@' expected_url='http://example.com/debug?token=xxx']", serverURL];
@throw [SensorsAnalyticsDebugException exceptionWithName:@"InvalidArgumentException"
reason:errMsg
userInfo:nil];
}
// 将 URI Path 替换成 Debug 模式的 '/debug'
NSURL *url = [[[NSURL URLWithString:serverURL] URLByDeletingLastPathComponent] URLByAppendingPathComponent:@"/debug"];
serverURL = [url absoluteString];
}

if (self = [self init]) {
Expand Down

0 comments on commit ded8958

Please sign in to comment.