Skip to content

Commit

Permalink
Release 1.3.4
Browse files Browse the repository at this point in the history
1. 更新 configure url 规则
  • Loading branch information
Yuhan ZOU committed Mar 14, 2016
1 parent a3623d4 commit cf2fab8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
9 changes: 4 additions & 5 deletions SensorsAnalyticsSDK/HelloSensorsAnalytics/DemoController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ - (void)didReceiveMemoryWarning {
}

- (void)testInit {
[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];
[SensorsAnalyticsSDK sharedInstanceWithServerURL:@"http://{sa_host}:8006/sa?token={token}"
andConfigureURL:@"http://{sa_host}:8007/api/vtrack/config"
andDebugMode:SensorsAnalyticsDebugOff];
}

- (void)testTrack {
Expand All @@ -51,7 +50,7 @@ - (void)testTrackSignup {
- (void)testProfileSet {
SensorsAnalyticsSDK *sdk = [SensorsAnalyticsSDK sharedInstance];
if (sdk != nil) {
[sdk.people set:@"name" withValue:@"caojiang"];
[sdk.people set:@"name" to:@"caojiang"];
}

}
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.3"
s.version = "1.3.4"
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
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ - (id)sessionObjectForKey:(NSString *)key {
- (void)sendMessage:(id<SADesignerMessage>)message {
if (_connected) {
NSString *jsonString = [[NSString alloc] initWithData:[message JSONData] encoding:NSUTF8StringEncoding];
SALog(@"VTrack sending message: %@", [message description]);
// SADebug(@"Sending message: %@", jsonString);
SADebug(@"%@ VTrack sending message: %@", self, [message description]);
[_webSocket send:jsonString];
} else {
SALog(@"Not sending message as we are not connected: %@", [message debugDescription]);
Expand All @@ -162,7 +161,7 @@ - (void)sendMessage:(id<SADesignerMessage>)message {
id <SADesignerMessage> designerMessage = nil;

NSData *jsonData = [message isKindOfClass:[NSString class]] ? [(NSString *)message dataUsingEncoding:NSUTF8StringEncoding] : message;
// SADebug(@"%@ received message: %@", self, [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);
SADebug(@"%@ VTrack received message: %@", self, [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);

NSError *error = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
Expand Down
6 changes: 3 additions & 3 deletions SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsDebugMode) {
* 在每次调用track、signUp以及profileSet等接口的时候,都会检查如下条件,以判断是否向服务器上传数据:
* 1. 当前是否是WIFI/3G/4G网络条件
* 2. 与上次发送的时间间隔是否大于flushInterval
* 如果满足这两个条件,则向服务器发送一次数据;如果不满足,则把数据加入到队列中,等待下次检查时把整个队列的内容一并发送。
* 如果同时满足这两个条件,则向服务器发送一次数据;如果不满足,则把数据加入到队列中,等待下次检查时把整个队列的内容一并发送。
* 需要注意的是,为了避免占用过多存储,队列最多只缓存10000条数据。
*/
@property (atomic) UInt64 flushInterval;
Expand Down Expand Up @@ -340,7 +340,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsDebugMode) {
* @param profile Profile的名称
* @param content Profile的内容
*/
- (void)set:(NSString *) profile withValue:(id)content;
- (void)set:(NSString *) profile to:(id)content;

/**
* @abstract
Expand All @@ -352,7 +352,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsDebugMode) {
* @param profile Profile的名称
* @param content Profile的内容
*/
- (void)setOnce:(NSString *) profile withValue:(id)content;
- (void)setOnce:(NSString *) profile to:(id)content;


/**
Expand Down
20 changes: 15 additions & 5 deletions SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ + (SensorsAnalyticsSDK *)sharedInstanceWithServerURL:(NSString *)serverURL

NSString *vtrackServerURL = [components.URL absoluteString];

SALog(@"Default URL of VTrack server is: %@", vtrackServerURL);

return [SensorsAnalyticsSDK sharedInstanceWithServerURL:serverURL
andConfigureURL:configureURL
andVTrackServerURL:vtrackServerURL
Expand Down Expand Up @@ -154,11 +152,21 @@ - (instancetype)initWithServerURL:(NSString *)serverURL
}

if (debugMode != SensorsAnalyticsDebugOff) {
// 将 URI Path 替换成 Debug 模式的 '/debug'
//Server URI Path 替换成 Debug 模式的 '/debug'
NSURL *url = [[[NSURL URLWithString:serverURL] URLByDeletingLastPathComponent] URLByAppendingPathComponent:@"/debug"];
serverURL = [url absoluteString];
}

// 将 Configure URI Path 末尾补齐 iOS.conf
NSURL *url = [NSURL URLWithString:configureURL];
if ([[url lastPathComponent] isEqualToString:@"config"]) {
url = [url URLByAppendingPathComponent:@"iOS.conf"];
}
configureURL = [url absoluteString];

SALog(@"%@ Initializing the instance of Sensors Analytics SDK with server url '%@', configure url '%@', vtrack server url '%@'",
self, serverURL, configureURL, vtrackServerURL);

if (self = [self init]) {
self.people = [[SensorsAnalyticsPeople alloc] initWithSDK:self];

Expand All @@ -168,10 +176,12 @@ - (instancetype)initWithServerURL:(NSString *)serverURL
_debugMode = debugMode;

if (debugMode != SensorsAnalyticsDebugOff) {
// Debug 模式下 Flush Interval 默认为1秒
_flushInterval = 1 * 1000;
} else {
_flushInterval = 60 * 100;
}

self.checkForEventBindingsOnActive = YES;
self.flushBeforeEnterBackground = NO;

Expand Down Expand Up @@ -1101,11 +1111,11 @@ - (void)setOnce:(NSDictionary *)profileDict {
[_sdk track:nil withProperties:profileDict withType:@"profile_set_once"];
}

- (void)set:(NSString *) profile withValue:(id)content {
- (void)set:(NSString *) profile to:(id)content {
[_sdk track:nil withProperties:@{profile: content} withType:@"profile_set"];
}

- (void)setOnce:(NSString *) profile withValue:(id)content {
- (void)setOnce:(NSString *) profile to:(id)content {
[_sdk track:nil withProperties:@{profile: content} withType:@"profile_set_once"];
}

Expand Down

0 comments on commit cf2fab8

Please sign in to comment.