添加部分通用上报
修改bug 未登录在键盘点击充值要先去跳转登录
This commit is contained in:
@@ -481,6 +481,13 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
||||
}
|
||||
}
|
||||
- (void)functionView:(KBFunctionView *_Nullable)functionView didRightTapToolActionAtIndex:(NSInteger)index{
|
||||
if (!KBAuthManager.shared.isLoggedIn) {
|
||||
NSString *schemeStr = [NSString stringWithFormat:@"%@://login?src=keyboard", KB_APP_SCHEME];
|
||||
NSURL *scheme = [NSURL URLWithString:schemeStr];
|
||||
// 从当前视图作为起点,通过响应链找到 UIApplication 再调起主 App
|
||||
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:self.view];
|
||||
return;
|
||||
}
|
||||
NSString *schemeStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME];
|
||||
NSURL *scheme = [NSURL URLWithString:schemeStr];
|
||||
//
|
||||
|
||||
@@ -13,12 +13,27 @@
|
||||
#define KB_MAI_POINT_PATH_NEW_ACCOUNT @"/newAccount"
|
||||
#endif
|
||||
|
||||
#ifndef KB_MAI_POINT_PATH_GENERIC_DATA
|
||||
#define KB_MAI_POINT_PATH_GENERIC_DATA @"/genericData"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString * const KBMaiPointErrorDomain;
|
||||
|
||||
typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable error);
|
||||
|
||||
typedef NS_ENUM(NSInteger, KBMaiPointGenericReportType) {
|
||||
/// 未知/默认类型(按需扩展,具体含义以服务端约定为准)
|
||||
KBMaiPointGenericReportTypeUnknown = 0,
|
||||
/// 点击
|
||||
KBMaiPointGenericReportTypeClick = 1,
|
||||
/// 曝光
|
||||
KBMaiPointGenericReportTypeExposure = 2,
|
||||
/// 页面/进入
|
||||
KBMaiPointGenericReportTypePage = 3,
|
||||
};
|
||||
|
||||
/// Lightweight reporter for Mai point tracking. Safe for app + extension.
|
||||
@interface KBMaiPointReporter : NSObject
|
||||
|
||||
@@ -26,9 +41,18 @@ typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable err
|
||||
|
||||
/// POST /newAccount with type + account.
|
||||
- (void)reportNewAccountWithType:(NSString *)type
|
||||
account:(NSString *)account
|
||||
account:(nullable NSString *)account
|
||||
completion:(KBMaiPointReportCompletion _Nullable)completion;
|
||||
|
||||
//- (void)reportGenericDataWithEvent:(NSString *)event
|
||||
// account:(nullable NSString *)account
|
||||
// completion:(KBMaiPointReportCompletion _Nullable)completion;
|
||||
|
||||
/// POST /genericData with type + event + account.
|
||||
- (void)reportGenericDataWithEventType:(KBMaiPointGenericReportType)type
|
||||
account:(nullable NSString *)account
|
||||
completion:(KBMaiPointReportCompletion _Nullable)completion;
|
||||
|
||||
/// Generic POST for future endpoints.
|
||||
- (void)postPath:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
|
||||
@@ -42,11 +42,16 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
|
||||
return reporter;
|
||||
}
|
||||
|
||||
- (NSString *)kb_trimmedStringOrEmpty:(NSString * _Nullable)string {
|
||||
NSString *value = [string isKindOfClass:[NSString class]] ? string : @"";
|
||||
return [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] ?: @"";
|
||||
}
|
||||
|
||||
- (void)reportNewAccountWithType:(NSString *)type
|
||||
account:(NSString *)account
|
||||
completion:(KBMaiPointReportCompletion)completion {
|
||||
NSString *trimmedType = [type stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
NSString *trimmedAccount = [account stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
account:(NSString * _Nullable)account
|
||||
completion:(KBMaiPointReportCompletion _Nullable)completion {
|
||||
NSString *trimmedType = [self kb_trimmedStringOrEmpty:type];
|
||||
NSString *trimmedAccount = [self kb_trimmedStringOrEmpty:account];
|
||||
if (trimmedType.length == 0 || trimmedAccount.length == 0) {
|
||||
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
|
||||
code:-1
|
||||
@@ -66,9 +71,44 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
|
||||
[self postPath:KB_MAI_POINT_PATH_NEW_ACCOUNT parameters:params completion:completion];
|
||||
}
|
||||
|
||||
//- (void)reportGenericDataWithEvent:(NSString *)event
|
||||
// account:(NSString * _Nullable)account
|
||||
// completion:(KBMaiPointReportCompletion _Nullable)completion {
|
||||
// [self reportGenericDataWithType:KBMaiPointGenericReportTypeUnknown
|
||||
// event:event
|
||||
// account:account
|
||||
// completion:completion];
|
||||
//}
|
||||
|
||||
- (void)reportGenericDataWithEventType:(KBMaiPointGenericReportType)eventType
|
||||
account:(nullable NSString *)account
|
||||
completion:(KBMaiPointReportCompletion _Nullable)completion{
|
||||
// if ([KBUserSessionManager shared].isLoggedIn == false) {
|
||||
// return;
|
||||
// }
|
||||
NSString *trimmedAccount = [self kb_trimmedStringOrEmpty:account];
|
||||
if (trimmedAccount.length == 0) {
|
||||
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
|
||||
code:-1
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"Invalid parameter"}];
|
||||
if (completion) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completion(NO, error);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary *params = @{
|
||||
@"eventId": @"123",
|
||||
@"account": account
|
||||
};
|
||||
[self postPath:KB_MAI_POINT_PATH_GENERIC_DATA parameters:params completion:completion];
|
||||
}
|
||||
|
||||
- (void)postPath:(NSString *)path
|
||||
parameters:(NSDictionary *)parameters
|
||||
completion:(KBMaiPointReportCompletion)completion {
|
||||
completion:(KBMaiPointReportCompletion _Nullable)completion {
|
||||
if (path.length == 0 || ![parameters isKindOfClass:[NSDictionary class]]) {
|
||||
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
|
||||
code:-1
|
||||
|
||||
@@ -52,6 +52,11 @@
|
||||
[weakSelf.navigationController pushViewController:vc animated:true];
|
||||
};
|
||||
|
||||
|
||||
[[KBMaiPointReporter sharedReporter] reportGenericDataWithEventType:KBMaiPointGenericReportTypePage account:@"123" completion:^(BOOL success, NSError * _Nullable error) {
|
||||
NSLog(@"===");
|
||||
}];
|
||||
|
||||
// 测试groups
|
||||
// NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
|
||||
// // 写入一个简单字符串
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#import "KBForgetPwdNewPwdVC.h"
|
||||
#import "KBLoginVM.h"
|
||||
#import "KBEmailRegistVC.h"
|
||||
#import "KBLoginVC.h"
|
||||
@interface KBForgetPwdNewPwdVC () <UITextFieldDelegate>
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password
|
||||
@@ -131,7 +131,7 @@
|
||||
if (success) {
|
||||
UIViewController *targetVC = nil;
|
||||
for (UIViewController *vc in KB_CURRENT_NAV.viewControllers) {
|
||||
if ([vc isKindOfClass:[KBEmailRegistVC class]]) {
|
||||
if ([vc isKindOfClass:[KBLoginVC class]]) {
|
||||
targetVC = vc;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user