Skip to content

Commit

Permalink
Release 1.4.4
Browse files Browse the repository at this point in the history
1. 为 可视化埋点 增加配置参数,可选 UIWindow 对象在 UIApplication
windows 对象中的序号
  • Loading branch information
Yuhan ZOU committed May 9, 2016
1 parent ab772ed commit 5cbbe53
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
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.4.3"
s.version = "1.4.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 @@ -16,6 +16,7 @@
#import "SAObjectIdentityProvider.h"
#import "SAObjectSerializerConfig.h"
#import "SADesignerConnection.h"
#import "SensorsAnalyticsSDK.h"

#pragma mark -- Snapshot Request

Expand Down Expand Up @@ -66,7 +67,8 @@ - (NSOperation *)responseCommandWithConnection:(SADesignerConnection *)connectio
__block NSDictionary *serializedObjects = nil;

dispatch_sync(dispatch_get_main_queue(), ^{
screenshot = [serializer screenshotImageForWindowAtIndex:0];
UInt32 vtrackWindowIndex = [[SensorsAnalyticsSDK sharedInstance] vtrackWindowIndex];
screenshot = [serializer screenshotImageForWindowAtIndex:vtrackWindowIndex];
});
snapshotMessage.screenshot = screenshot;

Expand All @@ -76,7 +78,8 @@ - (NSOperation *)responseCommandWithConnection:(SADesignerConnection *)connectio
}

dispatch_sync(dispatch_get_main_queue(), ^{
serializedObjects = [serializer objectHierarchyForWindowAtIndex:0];
UInt32 vtrackWindowIndex = [[SensorsAnalyticsSDK sharedInstance] vtrackWindowIndex];
serializedObjects = [serializer objectHierarchyForWindowAtIndex:vtrackWindowIndex];
});
[connection setSessionObject:serializedObjects forKey:@"snapshot_hierarchy"];
snapshotMessage.serializedObjects = serializedObjects;
Expand Down
13 changes: 13 additions & 0 deletions SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsDebugMode) {
*/
@property (atomic) UInt64 flushBulkSize;

/**
* @property
*
* @abstract
* 可视化埋点中,UIWindow 对象的序号
*
* @discussion
* 默认值为 0。一般情况下,App 的 UIWindow 对象是 UIApplication 的 windows 列表中的 firstObject,若用户调用 UIWindow 的 makeKeyAndVisible 等方法,
* 改变了 windows 列表中各个对象的 windowLevel,会导致可视化埋点无法正常获取需要埋点的 UIWindow 对象。用户调用该借口,设置 UIWindow 对象在
* windows 列表中的 index。
*/
@property (atomic) UInt32 vtrackWindowIndex;

/**
* @abstract
* 根据传入的配置,初始化并返回一个<code>SensorsAnalyticsSDK</code>的单例
Expand Down
16 changes: 15 additions & 1 deletion 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.4.2"
#define VERSION @"1.4.4"

#define PROPERTY_LENGTH_LIMITATION 255

Expand Down Expand Up @@ -74,6 +74,7 @@ @implementation SensorsAnalyticsSDK {
UInt64 _flushBulkSize;
UInt64 _flushInterval;
UInt64 _lastFlushTime;
UInt32 _vtrackWindowIndex;
NSDateFormatter *_dateFormatter;
}

Expand Down Expand Up @@ -201,6 +202,7 @@ - (instancetype)initWithServerURL:(NSString *)serverURL

_flushInterval = 60 * 1000;
_flushBulkSize = 100;
_vtrackWindowIndex = 0;

_dateFormatter = [[NSDateFormatter alloc] init];
[_dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss.SSS"];
Expand Down Expand Up @@ -1030,6 +1032,18 @@ - (void)setFlushBulkSize:(UInt64)bulkSize {
}
}

- (UInt32)vtrackWindowIndex {
@synchronized(self) {
return _vtrackWindowIndex;
}
}

- (void)setVtrackWindowIndex:(UInt32)vtrackWindowIndex {
@synchronized(self) {
_vtrackWindowIndex = vtrackWindowIndex;
}
}

/**
* @abstract
* 内部触发的flush,需要根据上次发送时间和网络情况来判断是否发送
Expand Down

0 comments on commit 5cbbe53

Please sign in to comment.