VIAnalyticsKit 是一个开源软件框架,使用户在应用程序中的交互更容易被捕捉。无论按钮的 target-action、UIAlertController 的选择项、UITableView/UICollectionView 的 didSelectRowAtIndexPath
或 UIGestureRecognizer 的手势,此框架都可以捕获这些事件。
VIAnalyticsKit 以 AOP 形式进行埋点,中文文章中有解释说明。
可用于数据收集和分析。
VIAnalyticsKit
将根据用户在视图控制器中的交互位置以及 SEL 名称生成一个 identifier string
。在 AppDelegate.m
中导入 "VIAnalyticsAOP.h"
,然后在 didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[VIAnalyticsAOP sharedInstance].analyticsIdentifierBlock = ^(NSString *identifier) {
NSLog(@"aop:::%@", identifier);
// Post identifier to your server
};
return YES;
}
identifier
将包含操作的信息。您可以将这些标识符收集起来并发送到您的服务器,这将帮助您公司分析用户行为。
传统的分析方法是类似于中国 UMeng 的在项目中的任何地方添加统计代码。这真的是一个不好的主意,浪费了时间。VIAnalyticsKit
可以通过使用类似于 Java 中的 AOP 的 objc/runtime
有助于解决这个问题。如下 identifier
2016-08-26 15:19:37.518 VIAnalyticsKit[6322:1628618] aop:::UIInputWindowController#viewWillAppear:
2016-08-26 15:19:37.554 VIAnalyticsKit[6322:1628618] aop:::UINavigationController#viewDidAppear:
2016-08-26 15:19:37.554 VIAnalyticsKit[6322:1628618] aop:::ViewController#viewDidAppear:
2016-08-26 15:19:37.555 VIAnalyticsKit[6322:1628618] aop:::UIInputWindowController#viewDidAppear:
2016-08-26 15:19:50.609 VIAnalyticsKit[6322:1628618] aop:::ViewController#UITapGestureRecognizer#liveshre_QQ#imageViewPan#ViewController
2016-08-26 15:19:50.652 VIAnalyticsKit[6322:1628618] aop:::View2Controller#viewDidLoad
2016-08-26 15:19:50.653 VIAnalyticsKit[6322:1628618] aop:::View2Controller#viewWillAppear:
2016-08-26 15:19:51.277 VIAnalyticsKit[6322:1628618] aop:::View2Controller#viewDidAppear:
2016-08-26 15:19:56.278 VIAnalyticsKit[6322:1628618] aop:::View2Controller#UITableView#0-0#View2Controller
此 identifier
包含 ViewController、方法名称、图片名称等
。
使用 Cocoapods
pod 'VIAnalyticsKit'
MIT License
Copyright (c) 2016 Vienta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.