Commit bb5212dac429e8979b3ae10d8d5dbbb71e0a6f5f

Authored by 张旭
1 parent 3e497392

添加统计SDK

LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -234,6 +234,7 @@
234 234 D25BF8A31E80C4FC007FB138 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8A21E80C4FC007FB138 /* Accelerate.framework */; };
235 235 D25BF8A51E80EC76007FB138 /* 头像.jpg in Resources */ = {isa = PBXBuildFile; fileRef = D25BF8A41E80EC76007FB138 /* 头像.jpg */; };
236 236 D260E6101F0CE8690095E49D /* praiseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D260E60F1F0CE8690095E49D /* praiseModel.m */; };
  237 + D263AFC21F13300600A963A6 /* CNLiveStat.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D263AFC11F13300600A963A6 /* CNLiveStat.framework */; };
237 238 D2888D941E6EB8B4003A77C8 /* LVCTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */; };
238 239 D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D9B1E6EBF1B003A77C8 /* LVCLiveViewController.m */; };
239 240 D29D88481E88C53300543A03 /* LVCUGCLivePrepareView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */; };
... ... @@ -774,6 +775,7 @@
774 775 D25BF8A41E80EC76007FB138 /* 头像.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "头像.jpg"; sourceTree = "<group>"; };
775 776 D260E60E1F0CE8690095E49D /* praiseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = praiseModel.h; sourceTree = "<group>"; };
776 777 D260E60F1F0CE8690095E49D /* praiseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = praiseModel.m; sourceTree = "<group>"; };
  778 + D263AFC11F13300600A963A6 /* CNLiveStat.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveStat.framework; sourceTree = "<group>"; };
777 779 D2888D921E6EB8B4003A77C8 /* LVCTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCTabBar.h; sourceTree = "<group>"; };
778 780 D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCTabBar.m; sourceTree = "<group>"; };
779 781 D2888D9A1E6EBF1B003A77C8 /* LVCLiveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCLiveViewController.h; sourceTree = "<group>"; };
... ... @@ -854,6 +856,7 @@
854 856 D2393D0E1F0250A100D3EE17 /* libWeChatSDK.a in Frameworks */,
855 857 D2393D1D1F0250A700D3EE17 /* libWeiboSDK.a in Frameworks */,
856 858 D2575C7D1E76A4F300E3A8FC /* NHGiftAnimtionSDK.a in Frameworks */,
  859 + D263AFC21F13300600A963A6 /* CNLiveStat.framework in Frameworks */,
857 860 D2393D071F02505400D3EE17 /* TencentOpenAPI.framework in Frameworks */,
858 861 D2EBC8A21F034F3C00F198FB /* CNLivePlayerSDK.framework in Frameworks */,
859 862 );
... ... @@ -1129,6 +1132,7 @@
1129 1132 812E504E1E7699B9004F5FCD /* CNLiveSDK */ = {
1130 1133 isa = PBXGroup;
1131 1134 children = (
  1135 + D263AFC11F13300600A963A6 /* CNLiveStat.framework */,
1132 1136 D2EBC8A51F03926E00F198FB /* CNLiveChatManager.framework */,
1133 1137 D2EBC8A11F034F3C00F198FB /* CNLivePlayerSDK.framework */,
1134 1138 D2EBC88F1F0241AD00F198FB /* CNLiveMsgTools.framework */,
... ...
LiveVideoCloud/AppDelegate/AppDelegate.m
... ... @@ -22,7 +22,7 @@
22 22 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
23 23 self.window.rootViewController = [[ZXTabBarController alloc] init];
24 24  
25   - //测试环境开关,只在初始化时有效
  25 + //测试环境开关,只在初始化时设置有效
26 26 self.isTestEnvironment = YES;
27 27  
28 28 //APP 启动是初始化直播SDK
... ... @@ -37,19 +37,11 @@
37 37 //初始化聊天SDK并连接服务器
38 38 [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:UserAppKey appId:UserAppId isTestEnvironment:self.isTestEnvironment];
39 39  
40   - /*
41   - [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
42   - NSLog(@"连接服务器-----success");
43   - } error:^(CNLiveChatConnectErrorCode errors) {
44   - NSLog(@"连接服务器失败-----%ld", errors);
45   - }];
46   - */
  40 + //初始化统计SDK
  41 + [CNLiveStat registerApp:UserAppId appKey:UserAppKey isTestEnvironment:self.isTestEnvironment];
47 42  
48   - /*
49   - CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170311" name:@"zzllzzzll" portrait:@"https://y3.cnliveimg.com/mobile/images/mobilehead/2017/03/30/1490844962259_small.jpg"];
50   - */
51   -
52   - // 20170327 20170328
  43 + //启动事件数量统计
  44 + [CNLiveStat event:@"iOS AppStartTest"];
53 45  
54 46 if ([UserTools isLogin]) {
55 47  
... ...
LiveVideoCloud/Classes/CNLiveSDK/CNLiveStat.framework/CNLiveStat 0 → 100644
No preview for this file type
LiveVideoCloud/Classes/CNLiveSDK/CNLiveStat.framework/Headers/CNLiveStat.h 0 → 100644
  1 +//
  2 +// CNLiveStat.h
  3 +// CNLiveStat
  4 +//
  5 +// Created by 雷浩杰 on 2016/11/10.
  6 +// Copyright © 2016年 雷浩杰. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface CNLiveStat : NSObject
  12 +
  13 +/*
  14 + * 获取SDK版本号
  15 + */
  16 ++ (NSString *)getVersion;
  17 +
  18 +/*
  19 + * 注册APP 注册成功或失败信息以log形式输出(CNLiveStatManager registerApp Success 或者 CNLiveStatManager registerApp Error :)
  20 +
  21 + @param appId AppId
  22 + @param appKey AppKey
  23 +
  24 + 此方法默认将统计数据上传到正式环境,如果需要测试SDK,强烈建议用
  25 + + (void)registerApp:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment 方法初始化SDK
  26 + */
  27 ++ (void)registerApp:(NSString *)appId appKey:(NSString *)appKey;
  28 +
  29 +/**
  30 + 注册APP 注册成功或失败信息以log形式输出(CNLiveStatManager registerApp Success 或者 CNLiveStatManager registerApp Error :)
  31 +
  32 + @param appId AppId
  33 + @param appKey AppKey
  34 + @param isTestEnvironment 测试环境开关,YES为测试环境,NO为正式环境
  35 +
  36 + */
  37 ++ (void)registerApp:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment;
  38 +
  39 +/* 数量统计
  40 + *
  41 + * eventID 事件ID
  42 + *
  43 + */
  44 ++ (void)event:(NSString *)eventID;
  45 +
  46 +/* 时长统计 在调用endEvent:方法前,多次使用同一个eventID调用此方法,只会将第一次视为有效调用
  47 + *
  48 + * eventID 事件ID
  49 + *
  50 + */
  51 ++ (void)beginEvent:(NSString *)eventID;
  52 +
  53 +/* 时长统计 多次使用同一个eventID调用此方法,只会将第一次视为有效调用
  54 + *
  55 + * eventID 事件ID
  56 + *
  57 + */
  58 ++ (void)endEvent:(NSString *)eventID;
  59 +
  60 +/* 直播播放统计
  61 + *
  62 + * channelId 直播channelId
  63 + *
  64 + */
  65 ++ (void)statLivePlayerWithChannelId:(NSString *)channelId;
  66 +
  67 +/* 点播播放统计
  68 + *
  69 + * vId 点播vId
  70 + *
  71 + */
  72 ++ (void)statVodPlayerWithVId:(NSString *)vId;
  73 +
  74 +@end
... ...
LiveVideoCloud/Classes/CNLiveSDK/CNLiveStat.framework/Info.plist 0 → 100644
No preview for this file type
LiveVideoCloud/Classes/CNLiveSDK/CNLiveStat.framework/Modules/module.modulemap 0 → 100644
  1 +framework module CNLiveStat {
  2 + umbrella header "CNLiveStat.h"
  3 +
  4 + export *
  5 + module * { export * }
  6 +}
... ...
LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.m
... ... @@ -154,6 +154,15 @@
154 154 return giftView;
155 155 }
156 156  
  157 +- (void)giftViewAddBgView:(UIView *)giftView
  158 +{
  159 + UIImageView *bgView = [[UIImageView alloc] initWithFrame:giftView.bounds];
  160 + bgView.backgroundColor = [UIColor blackColor];
  161 + bgView.tag = giftView.tag + 100;
  162 + bgView.alpha = 0.2;
  163 + [giftView addSubview:bgView];
  164 +}
  165 +
157 166 #pragma mark - 选择礼物点击
158 167 - (void)gestureClick:(UITapGestureRecognizer *)gesture
159 168 {
... ... @@ -161,35 +170,44 @@
161 170 NSLog(@"%zd",tag);
162 171  
163 172 if (_curruntSelectIdx == 0 && _isSelectedGift == NO) {//没选过
164   - UIView *giftView = gesture.view;
165   -
166   - UIImageView *bgView = [[UIImageView alloc] initWithFrame:giftView.bounds];
167   - bgView.backgroundColor = [UIColor blackColor];
168   - bgView.tag = giftView.tag + 100;
169   - bgView.alpha = 0.2;
170   - [giftView addSubview:bgView];
  173 + [self giftViewAddBgView:gesture.view];
  174 + _isSelectedGift = YES;
171 175 }
172 176  
173 177 if (_curruntSelectIdx != 0 && _isSelectedGift == YES) {//选过
174   - UIView *gView = gesture.view;
175   - for (UIView *view in self.scrollView.subviews) {//移除上一个bgView
176   - if (view.tag == _curruntSelectIdx) {
177   - for (UIView *bg in view.subviews) {
178   - if (bg.tag == view.tag + 100) {
179   - [bg removeFromSuperview];
180   - break;
  178 +// for (UIView *view in self.scrollView.subviews) {//移除上一个bgView
  179 +// if (view.tag == _curruntSelectIdx) {
  180 +// for (UIView *bg in view.subviews) {
  181 +// if (bg.tag == view.tag + 100) {
  182 +// [bg removeFromSuperview];
  183 +// break;
  184 +// }
  185 +// }
  186 +// }
  187 +// }
  188 + if (gesture.view.tag != _curruntSelectIdx) {//选的其他礼物
  189 + //增加当前bgView
  190 + [self giftViewAddBgView:gesture.view];
  191 + _isSelectedGift = YES;
  192 + }else{//选的当前礼物 ,根据是否选中做变化
  193 + if (_isSelectedGift == YES) {
  194 + _isSelectedGift = NO;
  195 + for (UIView *view in self.scrollView.subviews) {//移除上一个bgView
  196 + if (view.tag == _curruntSelectIdx) {
  197 + for (UIView *bg in view.subviews) {
  198 + if (bg.tag == view.tag + 100) {
  199 + [bg removeFromSuperview];
  200 + break;
  201 + }
  202 + }
181 203 }
182 204 }
  205 + }else{
  206 + _isSelectedGift = YES;
  207 + [self giftViewAddBgView:gesture.view];
183 208 }
184 209 }
185   - //增加当前bgView
186   - UIImageView *bgView = [[UIImageView alloc] initWithFrame:gView.bounds];
187   - bgView.backgroundColor = [UIColor blackColor];
188   - bgView.tag = gView.tag + 100;
189   - bgView.alpha = 0.2;
190   - [gView addSubview:bgView];
191 210 }
192   - _isSelectedGift = YES;
193 211 _curruntSelectIdx = gesture.view.tag;
194 212  
195 213 GiftModel *model = self.giftArray[tag];
... ...
LiveVideoCloud/Classes/Sections/PGCSections/Controller/LVCLivePlayerController.m
... ... @@ -44,13 +44,18 @@
44 44 self.navigationController.navigationBar.hidden = YES;
45 45 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
46 46 [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
47   -
  47 +
  48 + //直播时长统计开始
  49 + [CNLiveStat beginEvent:@"PGCLiveEvent"];
48 50 }
49 51  
50 52 - (void)viewDidDisappear:(BOOL)animated
51 53 {
52 54 [super viewDidDisappear:animated];
53 55 self.navigationController.navigationBar.hidden = NO;
  56 +
  57 + //直播时长统计结束
  58 + [CNLiveStat endEvent:@"PGCLiveEvent"];
54 59 }
55 60  
56 61 - (void)viewWillDisappear:(BOOL)animated
... ... @@ -64,6 +69,9 @@
64 69 [super viewDidLoad];
65 70 self.view.backgroundColor = [UIColor blackColor];
66 71  
  72 + //直播播放数量统计
  73 + [CNLiveStat statLivePlayerWithChannelId:@"iosLivePlayStatTest"];
  74 +
67 75 _roomId = [NSString stringWithFormat:@"syn%@",self.model.mediaId];
68 76 playerFrame = CGRectMake(0, 20, SCREEN_WIDTH, SCREEN_WIDTH*9/16);
69 77 _originalDirection = 0;
... ...
LiveVideoCloud/Classes/Sections/PGCSections/Controller/LVCTelevisioController.m
... ... @@ -37,7 +37,6 @@
37 37  
38 38 [self.view addSubview:self.tableView];
39 39 [self loadData];
40   -
41 40 }
42 41  
43 42 - (void)loadData {
... ...
LiveVideoCloud/Classes/Sections/UGCSections/Controller/LVCUGCLivePlayerController.m
... ... @@ -55,15 +55,21 @@
55 55 - (void)viewWillAppear:(BOOL)animated {
56 56  
57 57 [super viewWillAppear:animated];
58   -
59 58 self.navigationController.navigationBar.hidden = YES;
60 59 }
61 60  
62 61 - (void)viewWillDisappear:(BOOL)animated {
63 62  
64 63 [super viewWillDisappear:animated];
65   -
66 64 self.navigationController.navigationBar.hidden = NO;
  65 + //UGC直播时长统计结束
  66 + if ([_model.activityStatus isEqualToString:@"1"]) {
  67 + [CNLiveStat endEvent:@"UGCLive"];
  68 + }
  69 + //UGC回放时长统计结束
  70 + if ([_model.activityStatus isEqualToString:@"4"]) {
  71 + [CNLiveStat endEvent:@"UGCPlayback"];
  72 + }
67 73 }
68 74  
69 75 - (void)viewDidLoad {
... ... @@ -79,6 +85,7 @@
79 85 [self.view addSubview:self.viewThird];
80 86  
81 87 if ([_model.activityStatus isEqualToString:@"1"]) {
  88 +
82 89 [self addLiveBaseViewWithChannelId:_model.channelId];
83 90 }
84 91 _bgModel = _model;
... ... @@ -156,6 +163,7 @@
156 163 if ([model.activityStatus isEqualToString:@"1"]) {
157 164  
158 165 _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:model.channelId anchorStatus:YES authSuccess:^{
  166 +
159 167  
160 168 _player.videoDecoderMode = CNLiveMovieVideoDecoderMode_AUTO;
161 169 _player.view.frame = self.view.bounds;
... ... @@ -163,7 +171,9 @@
163 171 [_player prepareToPlay];
164 172 [self.viewSecond addSubview:_player.view];
165 173 [self.viewSecond sendSubviewToBack:_player.view];
166   -
  174 +
  175 + //UGC直播时长统计开始
  176 + [CNLiveStat beginEvent:@"UGCLive"];
167 177 } authFailed:^(NSDictionary *errorInfo) {
168 178 NSLog(@"初始化直播播放器失败:%@", errorInfo);
169 179  
... ... @@ -193,7 +203,9 @@
193 203 [self.viewSecond sendSubviewToBack:_player.view];
194 204 [_player.view addGestureRecognizer:_pan];
195 205 [_player.view addSubview:self.bottomView];
196   -
  206 +
  207 + //UGC回放时长统计开始
  208 + [CNLiveStat beginEvent:@"UGCPlayback"];
197 209 } authFailed:^(NSDictionary *errorInfo) {
198 210 NSLog(@"初始化点播播放器失败%@", errorInfo);
199 211 }];
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.m
... ... @@ -88,6 +88,9 @@ typedef enum {
88 88 self.view.backgroundColor = [UIColor whiteColor];
89 89 [self.view addSubview:self.playerSuperView];
90 90 [self.view addSubview:self.commentView];
  91 +
  92 + //点播播放数量统计
  93 + [CNLiveStat statVodPlayerWithVId:@"iosVodPlayStatTest"];
91 94 }
92 95  
93 96 - (void)setModel:(LVCVodListModel *)model {
... ...
LiveVideoCloud/PrefixHeader.pch
... ... @@ -55,6 +55,7 @@
55 55 #import "WeiboSDK.h"
56 56 #import "AppDelegate.h"
57 57 #import <CNLiveChatManager/CNLiveCommentManager.h>
  58 + #import <CNLiveStat/CNLiveStat.h>
58 59  
59 60  
60 61 #if TARGET_OS_IPHONE
... ...