Commit 7788a94e authored by 翟国钧's avatar 翟国钧

升级Phobos,fix referer为空的bug

parent 385f7561
......@@ -357,7 +357,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
AD2DAA4386519D3497CC28DC /* [CP] Copy Pods Resources */ = {
......@@ -402,7 +402,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
......
......@@ -10,6 +10,9 @@
@interface Phobos : NSObject
@property (strong, nonatomic) UINavigationController *selectedNavigationController;
/**
* @brief 开启Phobos统计,默认以BATCH方式发送log.
*
......@@ -88,14 +91,14 @@
*
* @since 0.0.8
*/
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName;
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time;
/**
* @brief 当页面结束时的PV处理,在此方法中记录当前页面的停留时间和记录本次埋点事件
*
* @since 0.0.8
*/
- (void)onPageEnd;
- (void)onPageEnd:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time;
/**
* @author 翟国钧, 16-03-08 11:03:45
......
......@@ -11,7 +11,7 @@
#import <AdSupport/AdSupport.h>
#import "PhobosUtil.h"
#import "PhobosConfig.h"
#import "UIViewController+Phobos.h"
static Phobos *sharedClient = nil;
static NSString *sdkVersion = @"110";
......@@ -27,9 +27,6 @@ static NSString *sdkVersion = @"110";
@property (assign, nonatomic) BOOL logEnabled;
@property (strong, nonatomic) NSString *sessionId;
@property (strong, nonatomic) NSMutableDictionary *pageEnterParam;
@end
@implementation Phobos
......@@ -90,6 +87,17 @@ static NSString *sdkVersion = @"110";
}
}
- (UINavigationController *)selectedNavigationController{
if ([[UIApplication sharedApplication].keyWindow.rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabbar = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
UINavigationController *navigationController = (UINavigationController *)tabbar.selectedViewController;
return navigationController;
}else{
NSAssert(0, @"获取不到 selectedNavigationController %@", NSStringFromClass([UIApplication sharedApplication].keyWindow.rootViewController.class));
return nil;
}
}
#pragma mark - notification handler
/**
......@@ -138,6 +146,7 @@ static NSString *sdkVersion = @"110";
phobosLog(@"handleAppInForeground");
[self handleSessionStart];
[self fetchDataAndSend];
[self handlePVEventAppInForeground];
}
/**
......@@ -151,6 +160,7 @@ static NSString *sdkVersion = @"110";
phobosLog(@"handleAppInBackgound");
[self handleSessionOver];
[self fetchDataAndSend];
[self handlePVEventAppInBackgound];
}
/**
......@@ -173,6 +183,30 @@ static NSString *sdkVersion = @"110";
[cache removeObjectAtDiskWithkey:PhobosBeginTime];
}
/**
APP从后台到前台的时候,重新初始化pagename等信息
@author zhaiguojun 16-10-11 in (null)
*/
- (void)handlePVEventAppInForeground {
NSString *pageName = self.selectedNavigationController.visibleViewController.pageName;
NSString *businessId = self.selectedNavigationController.visibleViewController.businessId;
NSString *regerer = self.selectedNavigationController.visibleViewController.referer;
self.selectedNavigationController.visibleViewController.inTime = [self currentTime];
[self onPageStart:pageName businessId:businessId referer:regerer inTime:[self currentTime]];
}
/**
APP进到后台的时候,把当前pageview时间结束
@author zhaiguojun 16-10-11 in (null)
*/
- (void)handlePVEventAppInBackgound {
NSString *pageName = self.selectedNavigationController.visibleViewController.pageName;
NSString *businessId = self.selectedNavigationController.visibleViewController.businessId;
NSString *referer = self.selectedNavigationController.visibleViewController.referer;
NSString *inTime = self.selectedNavigationController.visibleViewController.inTime;
[self onPageEnd:pageName businessId:businessId referer:referer inTime:inTime];
}
#pragma mark - track event handler
+ (void)track:(NSString *)eventId{
......@@ -222,26 +256,25 @@ static NSString *sdkVersion = @"110";
}
#pragma mark - pv
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName{
_pageEnterParam = [NSMutableDictionary dictionaryWithObjectsAndKeys:
pageName?:@"",@"page_name",
businessId?:@"",@"business_id",
refererPageName?:@"",@"referer",
[self currentTime],@"in",nil];
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time{
//目前来说,变成了空方法,其主要功能是给当前VC的属性赋值,下个版本优化,挪到UIViewController+Phobos里去
}
- (void)onPageEnd{
- (void)onPageEnd:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time{
if (![self isNonEmpty:pageName]) {
return;
}
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
@try {
[dict setObject:[self currentTime] forKey:@"out"];
[dict setObject:@([_pageEnterParam[@"in"] doubleValue])?:@"" forKey:@"in"];
[dict setObject:_pageEnterParam[@"page_name"]?:@"" forKey:@"page_name"];
[dict setObject:_pageEnterParam[@"business_id"]?:@"" forKey:@"business_id"];
[dict setObject:_pageEnterParam[@"referer"]?:@"" forKey:@"referer"];
[dict setObject:time?:@"" forKey:@"in"];
[dict setObject:pageName forKey:@"page_name"];
[dict setObject:businessId?:@"" forKey:@"business_id"];
[dict setObject:refererPageName?:@"" forKey:@"referer"];
[dict setObject:@(0) forKey:@"fake"];
[Phobos track:@"page_view" attributes:dict];
[_pageEnterParam removeAllObjects];
}
@catch (NSException *exception) {
phobosLog(exception);
......@@ -259,7 +292,6 @@ static NSString *sdkVersion = @"110";
[dict setObject:@(1) forKey:@"fake"];
[Phobos track:@"page_view" attributes:dict];
[_pageEnterParam removeAllObjects];
}
@catch (NSException *exception) {
phobosLog(exception);
......
......@@ -25,7 +25,7 @@
*
* @since 5.9.1
*/
@property (nonatomic, strong, readonly, nonnull) NSString *referer;
@property (nonatomic, copy, nonnull) NSString *referer;
/**
* @author 翟国钧 in 16-02-25 19:02:32
......@@ -34,4 +34,11 @@
* @since 5.9.1
*/
@property (nonatomic, copy, nonnull) NSString *pageName;
/**
当前VC.view 显示的时候的时间戳
@author zhaiguojun 16-10-12 in (null)
*/
@property (nonatomic, copy, nonnull) NSString *inTime;
@end
......@@ -19,16 +19,21 @@
*
* @since 5.9.1
*/
- (NSString *)referer
{
- (void)setReferer:(NSString *)referer {
NSArray *navigationPool = self.navigationController.viewControllers;
NSInteger refererIndex = navigationPool.count - 2;
if (refererIndex < 0 ) {
return @"";
return ;
}
UIViewController *controller = navigationPool[refererIndex];
return controller.pageName == nil ? @"" : controller.pageName;
objc_setAssociatedObject(self, @selector(referer), controller.pageName, OBJC_ASSOCIATION_COPY);
}
- (NSString *)referer
{
NSString *referer = objc_getAssociatedObject(self, @selector(referer));
return referer == nil ? @"" : referer;
}
- (NSString *)pageName {
......@@ -48,4 +53,14 @@
- (void)setBusinessId:(NSString *)businessId {
objc_setAssociatedObject(self, @selector(businessId), businessId, OBJC_ASSOCIATION_COPY);
}
- (void)setInTime:(NSString *)inTime {
objc_setAssociatedObject(self, @selector(inTime), inTime, OBJC_ASSOCIATION_COPY);
}
- (NSString *)inTime {
NSString *inTime = objc_getAssociatedObject(self, @selector(inTime));
return inTime;
}
@end
{
"name": "GMBase",
"version": "0.0.10",
"version": "0.0.11",
"summary": "更美iOS APP 的 Objective-C 基础Pod库",
"homepage": "http://git.gengmei.cc/gengmeiios/GMBase",
"license": "仅限北京更美互动信息科技有限公司内部使用",
......@@ -9,7 +9,7 @@
},
"source": {
"git": "http://git.gengmei.cc/gengmeiios/GMBase.git",
"tag": "0.0.10"
"tag": "0.0.11"
},
"platforms": {
"ios": "8.0"
......
......@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession
- GMBase (0.0.10):
- GMBase (0.0.11):
- GMNetService
- GMPhobos
- GMRefresh
......@@ -26,7 +26,7 @@ PODS:
- TMCache (~> 2.1.0)
- GMNetService (0.1.3):
- AFNetworking (= 3.1.0)
- GMPhobos (0.2.11):
- GMPhobos (0.2.13):
- GMCache (~> 0.1.0)
- GMRefresh (0.1.4):
- MJRefresh (~> 3.1.0)
......@@ -46,10 +46,10 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
GMBase: 0c1f235a6cbbbdfce4f2cf37888daa225ed417c8
GMBase: 6cea1da64d6e0971f08852e4f4eefa2ae3a8c097
GMCache: a7b06a2d8a5a1c7cf023055c631ba9a0cd7c39fc
GMNetService: 2eb74ed62512078e9f00bc7006227a93c2acdf32
GMPhobos: cd634b80564edb29f0dda9f3e62cf4a83de717b1
GMPhobos: 2f91b2b86285be7ae1e88c21628ccd7486a2afd8
GMRefresh: 8d6ef25dbd38c2687fee713cc520012d47c7261e
JSONModel: 12523685c4b623553ccf844bbbf7007624317b2c
Masonry: a1a931a0d08870ed8ae415a2ea5ea68ebcac77df
......@@ -60,4 +60,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 9ce9038dd459ce1a2403f8111c792b3549ce8741
COCOAPODS: 1.1.0.rc.2
COCOAPODS: 1.0.1
This diff is collapsed.
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.10</string>
<string>0.0.11</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.2.11</string>
<string>0.2.13</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -34,8 +34,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>AFNetworking</string>
<key>Type</key>
......@@ -63,8 +61,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>&#20165;&#38480;&#21271;&#20140;&#26356;&#32654;&#20114;&#21160;&#20449;&#24687;&#31185;&#25216;&#26377;&#38480;&#20844;&#21496;&#20869;&#37096;&#20351;&#29992;</string>
<key>Title</key>
<string>GMBase</string>
<key>Type</key>
......@@ -92,8 +88,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMCache</string>
<key>Type</key>
......@@ -121,8 +115,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMNetService</string>
<key>Type</key>
......@@ -150,8 +142,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMPhobos</string>
<key>Type</key>
......@@ -179,8 +169,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMRefresh</string>
<key>Type</key>
......@@ -212,8 +200,6 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License in plain English: http://www.touch-code-magazine.com/JSONModel/MITLicense
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>JSONModel</string>
<key>Type</key>
......@@ -240,8 +226,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>MBProgressHUD</string>
<key>Type</key>
......@@ -269,8 +253,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>MJRefresh</string>
<key>Type</key>
......@@ -297,8 +279,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>Masonry</string>
<key>Type</key>
......@@ -508,8 +488,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</string>
<key>License</key>
<string>Apache 2.0</string>
<key>Title</key>
<string>TMCache</string>
<key>Type</key>
......@@ -540,8 +518,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>UITableView+FDTemplateLayoutCell</string>
<key>Type</key>
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
......@@ -93,6 +93,7 @@
// 导航栏隐藏在 viewWillAppear 里控制的原因是在viewDidLoad时,有可能 navigationController 与 self 并没有关系
self.navigationController.navigationBarHidden = YES;
[self setUpInTime];
[self setReferer:nil];
[[Phobos sharedClient] onPageStart:self.pageName businessId:self.businessId referer:[self referer] inTime:self.inTime];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment