Files
peko-ios/YuMi/Tools/Event/XPEventHandle.m
2024-04-11 15:47:44 +08:00

162 lines
8.1 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// XPEventHandle.m
// xplan-ios
//
// Created by duoban on 2022/12/5.
//
#import "XPEventHandle.h"
#import "XPFirebbaseEvent.h"
#import "XPEventHead.h"
static NSString *const isHaveWindow = @"0";
@implementation XPEventHandle
///埋点时必传参数
+(NSMutableDictionary *)getCommonAttributes{
NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970] * 1000];
return [NSMutableDictionary dictionaryWithDictionary:@{
@"when":timeSp,
@"uid":[AccountInfoStorage instance].getUid ?: @"",
@"channel":[YYUtility appName],
@"appv":[YYUtility appVersion]
}];
}
#pragma mark - 埋点
///首页板块点击,1=搜索2=创建房间3=排行榜,4=分类导航5=热门房间6=banner轮播7=扩列聊天-用户房间8=扩列聊天-创建普通房9=扩列聊天-创建游戏房10=房间派对11=菜单栏-首页12=菜单栏-论坛13=菜单栏-消息14=菜单栏-我的
+(void)homeClickEventWithType:(NSString *)type{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarHomepage forKey:kModule];
[attributes setValue:type forKey:kHomepageType];
[XPFirebbaseEvent event:kModuleHomepageClick attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kModuleHomepageClick,[attributes mj_JSONString]]];
}
///导航栏tab板块点击,1=推荐2=女神3=男神,4=点唱5=娱乐6=开黑7=交友8=小游戏;
+(void)homeTabClickEventWithType:(NSString *)type{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarHomepage forKey:kModule];
[attributes setValue:type forKey:kHomepageTab];
[XPFirebbaseEvent event:kTabHomepageClick attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kTabHomepageClick,[attributes mj_JSONString]]];
}
///登录协议弹框展示
+(void)loginAgreementShowEvent{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarLogin forKey:kModule];
[XPFirebbaseEvent event:kAgreementShow attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kAgreementShow,[attributes mj_JSONString]]];
}
///登录协议点击type,1=用户协议2=隐私协议3=同意, page,1=隐私协议与用户协议弹框2=账号注册
+(void)loginAgreementClickEventWithWindowType:(NSString *)type{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarLogin forKey:kModule];
[attributes setValue:type forKey:kClickType];
[attributes setValue:@"1" forKey:kPage];
[XPFirebbaseEvent event:KAgreementClick attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",KAgreementClick,[attributes mj_JSONString]]];
}
///登录协议点击type,1=用户协议2=隐私协议3=同意, page,1=隐私协议与用户协议弹框2=账号注册
+(void)loginAgreementClickEventWithType:(NSString *)type{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarLogin forKey:kModule];
[attributes setValue:type forKey:kClickType];
[attributes setValue:@"2" forKey:kPage];
[XPFirebbaseEvent event:KAgreementClick attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",KAgreementClick,[attributes mj_JSONString]]];
}
///发起登录,1=Facebook登录2=LINE登录3=Google登录,4=手机号登录5=ID登录其他方式
+(void)loginRequestEventWithType:(NSString *)type{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarLogin forKey:kModule];
[attributes setValue:type forKey:kLoginType];
[XPFirebbaseEvent event:kLoginRequest attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kLoginRequest,[attributes mj_JSONString]]];
}
///登录结果,type,1=Facebook登录2=LINE登录3=Google登录,4=手机号登录5=ID登录其他方式result,0=失败1=成功, failDetail,将具体失败原因上报
+(void)loginResultEventWithType:(NSString *)type result:(NSString *)result failDetail:(NSString * _Nullable)failDetail{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarLogin forKey:kModule];
[attributes setValue:type forKey:kLoginType];
[attributes setValue:result forKey:kResult];
if(failDetail != nil){
[attributes setValue:failDetail forKey:kFailDetail];
}
[XPFirebbaseEvent event:kLoginResult attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kLoginResult,[attributes mj_JSONString]]];
}
///首次启动
+(void)activateFirstEvent{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarActivate forKey:kModule];
[XPFirebbaseEvent event:kFirstActivate attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kFirstActivate,[attributes mj_JSONString]]];
}
///登录点击,1=Facebook登录2=LINE登录3=Google登录,4=手机号登录5=ID登录其他方式
+(void)loginClickEventWithType:(NSString *)type{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarLogin forKey:kModule];
[attributes setValue:type forKey:kClickType];
[XPFirebbaseEvent event:kLoginClick attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kLoginClick,[attributes mj_JSONString]]];
}
///登录页面展示
+(void)loginShowEvent{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarLogin forKey:kModule];
[XPFirebbaseEvent event:kLoginShow attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kLoginShow,[attributes mj_JSONString]]];
}
///根据点击充值的入口上报,type,=房间内背包的充值入口2=房间内赠送礼物时余额不足的充值入口3=房间内VIPicon的充值入口个人中心的充值入口4=VIP中心的充值入口5=星级厨房的充值入口6=寻找小精灵的充值入口7=寻爱之旅的充值入口8=私聊送礼的充值入口,balance,返回用户具体余额
+(void)payPageShowEventWithType:(NSString *)type balance:(NSString *)balance{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarPay forKey:kModule];
[attributes setValue:type forKey:kPaypageType];
[attributes setValue:balance forKey:kAccountBalance];
[XPFirebbaseEvent event:kPaypageShow attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kPaypageShow,[attributes mj_JSONString]]];
}
///点击确认支付按钮,money,金额
+(void)payClickEventWithMoney:(NSString *)money{
NSMutableDictionary *attributes = [XPEventHandle getCommonAttributes];
[attributes setValue:kMoliStarPay forKey:kModule];
[attributes setValue:money forKey:kMoney];
[XPFirebbaseEvent event:kPayClick attributes:attributes];
[XPEventHandle showWindowWtihText:[NSString stringWithFormat:@"埋点事件\n%@\n埋点参数\n%@",kPayClick,[attributes mj_JSONString]]];
}
+(void)showWindowWtihText:(NSString *)text{
if([isHaveWindow isEqualToString:@"1"]){
TTAlertConfig *config = [[TTAlertConfig alloc]init];
config.message = text;
config.actionStyle = TTAlertActionConfirmStyle;
[TTPopup alertWithConfig:config showBorder:NO confirmHandler:^{
} cancelHandler:^{
}];
}
}
@end