123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- //
- // UMengRecordTool.h
- // MSYOUPAI
- //
- // Created by xiaohaoran on 2022/4/12.
- // Copyright © 2022 MS. All rights reserved.
- //
- #import "UMengRecordTool.h"
- @implementation UMengRecordTool
- /**
- @ 页面统计 - 进入
-
- */
- + (void)umengEnterViewWithName:(NSString *)name
- {
- [MobClick beginLogPageView:name];
- }
- /**
- @ 页面统计 - 退出
-
- */
- + (void)umengOutViewWithName:(NSString *)name
- {
- [MobClick endLogPageView:name];
- }
- /**
- @ 计数事件统计
-
- */
- + (void)umengEventCountWithId:(NSString *)eventId
- {
- [MobClick event:eventId];
- }
- /**
- @ 计算事件统计
-
- */
- + (void)umengEventCalculatWithId:(NSString *)eventId attributes:(NSDictionary *)attributes number:(nullable id)number
- {
- NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:attributes];
- if (number) {
- NSString *numberKey = @"__ct__";
- [mutableDictionary setObject:[number stringValue] forKey:numberKey];
- }
-
- [MobClick event:eventId attributes:mutableDictionary];
- }
- /**
- @ ScrollView 已滚动/浏览的百分比
-
- */
- + (void)umengEventScrollViewWithId:(NSString *)eventId attributes:(NSDictionary *)attributes scrollview:(UIScrollView *)scrollview isVertical:(BOOL)isVertical
- {
-
- NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:attributes];
-
- CGFloat x = scrollview.contentOffset.x;
- CGFloat y = scrollview.contentOffset.y;
-
- CGFloat width = scrollview.contentSize.width;
- CGFloat height = scrollview.contentSize.height;
-
- CGFloat superVWidth = scrollview.superview.frame.size.width;
- CGFloat superVHeight = scrollview.superview.frame.size.height;
-
- if (isVertical) { //竖直
-
- int yInt;
- if (height <= superVHeight)
- {
- yInt = 100;
-
- }else
- {
- yInt = ((y+superVHeight)/height) *100;
- }
- NSString *numberKey = @"__ct__";
- [mutableDictionary setObject:[NSString stringWithFormat:@"%d",yInt] forKey:numberKey];
-
- }else{
-
- int xInt;
- if (width <= superVWidth)
- {
- xInt = 100;
-
- }else{
- xInt = ((x+superVWidth)/width) *100;
- }
- NSString *numberKey = @"__ct__";
- [mutableDictionary setObject:[NSString stringWithFormat:@"%d",xInt] forKey:numberKey];
- }
-
- [MobClick event:eventId attributes:mutableDictionary];
-
-
- }
- @end
|