添加部分通用上报

修改bug 未登录在键盘点击充值要先去跳转登录
This commit is contained in:
2025-12-30 15:27:35 +08:00
parent 34089ddeea
commit 4e2d7d2908
5 changed files with 84 additions and 8 deletions

View File

@@ -481,6 +481,13 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
} }
} }
- (void)functionView:(KBFunctionView *_Nullable)functionView didRightTapToolActionAtIndex:(NSInteger)index{ - (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]; NSString *schemeStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME];
NSURL *scheme = [NSURL URLWithString:schemeStr]; NSURL *scheme = [NSURL URLWithString:schemeStr];
// //

View File

@@ -13,12 +13,27 @@
#define KB_MAI_POINT_PATH_NEW_ACCOUNT @"/newAccount" #define KB_MAI_POINT_PATH_NEW_ACCOUNT @"/newAccount"
#endif #endif
#ifndef KB_MAI_POINT_PATH_GENERIC_DATA
#define KB_MAI_POINT_PATH_GENERIC_DATA @"/genericData"
#endif
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
extern NSString * const KBMaiPointErrorDomain; extern NSString * const KBMaiPointErrorDomain;
typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable error); 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. /// Lightweight reporter for Mai point tracking. Safe for app + extension.
@interface KBMaiPointReporter : NSObject @interface KBMaiPointReporter : NSObject
@@ -26,9 +41,18 @@ typedef void (^KBMaiPointReportCompletion)(BOOL success, NSError * _Nullable err
/// POST /newAccount with type + account. /// POST /newAccount with type + account.
- (void)reportNewAccountWithType:(NSString *)type - (void)reportNewAccountWithType:(NSString *)type
account:(NSString *)account account:(nullable NSString *)account
completion:(KBMaiPointReportCompletion _Nullable)completion; 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. /// Generic POST for future endpoints.
- (void)postPath:(NSString *)path - (void)postPath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters

View File

@@ -42,11 +42,16 @@ static void KBMaiPoint_DebugLogError(NSURLResponse *response, NSError *error) {
return reporter; return reporter;
} }
- (NSString *)kb_trimmedStringOrEmpty:(NSString * _Nullable)string {
NSString *value = [string isKindOfClass:[NSString class]] ? string : @"";
return [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] ?: @"";
}
- (void)reportNewAccountWithType:(NSString *)type - (void)reportNewAccountWithType:(NSString *)type
account:(NSString *)account account:(NSString * _Nullable)account
completion:(KBMaiPointReportCompletion)completion { completion:(KBMaiPointReportCompletion _Nullable)completion {
NSString *trimmedType = [type stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *trimmedType = [self kb_trimmedStringOrEmpty:type];
NSString *trimmedAccount = [account stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *trimmedAccount = [self kb_trimmedStringOrEmpty:account];
if (trimmedType.length == 0 || trimmedAccount.length == 0) { if (trimmedType.length == 0 || trimmedAccount.length == 0) {
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
code:-1 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]; [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 - (void)postPath:(NSString *)path
parameters:(NSDictionary *)parameters parameters:(NSDictionary *)parameters
completion:(KBMaiPointReportCompletion)completion { completion:(KBMaiPointReportCompletion _Nullable)completion {
if (path.length == 0 || ![parameters isKindOfClass:[NSDictionary class]]) { if (path.length == 0 || ![parameters isKindOfClass:[NSDictionary class]]) {
NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain NSError *error = [NSError errorWithDomain:KBMaiPointErrorDomain
code:-1 code:-1

View File

@@ -52,6 +52,11 @@
[weakSelf.navigationController pushViewController:vc animated:true]; [weakSelf.navigationController pushViewController:vc animated:true];
}; };
[[KBMaiPointReporter sharedReporter] reportGenericDataWithEventType:KBMaiPointGenericReportTypePage account:@"123" completion:^(BOOL success, NSError * _Nullable error) {
NSLog(@"===");
}];
// groups // groups
// NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup]; // NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
// // // //

View File

@@ -7,7 +7,7 @@
#import "KBForgetPwdNewPwdVC.h" #import "KBForgetPwdNewPwdVC.h"
#import "KBLoginVM.h" #import "KBLoginVM.h"
#import "KBEmailRegistVC.h" #import "KBLoginVC.h"
@interface KBForgetPwdNewPwdVC () <UITextFieldDelegate> @interface KBForgetPwdNewPwdVC () <UITextFieldDelegate>
@property (nonatomic, strong) UILabel *titleLabel; // Reset Password @property (nonatomic, strong) UILabel *titleLabel; // Reset Password
@@ -131,7 +131,7 @@
if (success) { if (success) {
UIViewController *targetVC = nil; UIViewController *targetVC = nil;
for (UIViewController *vc in KB_CURRENT_NAV.viewControllers) { for (UIViewController *vc in KB_CURRENT_NAV.viewControllers) {
if ([vc isKindOfClass:[KBEmailRegistVC class]]) { if ([vc isKindOfClass:[KBLoginVC class]]) {
targetVC = vc; targetVC = vc;
break; break;
} }