//
//  DYOpenSDKTrackerManager.h
//  AWEAnywhereArena
//
//  Created by ByteDance on 2025/2/18.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

#define DYOPEN_TRACK_COMMON_PARAMS [DYOpenSDKTrackerManager dyopenCommonTrackParams]

#define DYOPEN_TRACK_EVENT(__EVENT_STRING__, __PARAMS_DICT__) \
[DYOpenSDKTrackerManager delegateEvent:__EVENT_STRING__ params:__PARAMS_DICT__];

#define DYOPEN_TRACK_API_EVENT(__IS_SUPPORT_BOOL__) \
DYOPEN_TRACK_EVENT(@"dysdk_api_invoke", (@{\
    @"api_name": [NSString stringWithFormat:@"%s", __FUNCTION__] ?: @"",\
    @"is_support": @(__IS_SUPPORT_BOOL__).stringValue,\
}));

@protocol DYOpenSDKTrackerManagerDelegate <NSObject>

- (void)dyTrackerManagerEvent:(NSString * _Nonnull)event params:(NSDictionary * _Nonnull)params;

@end

@interface DYOpenSDKTrackerManager : NSObject

@property (nullable, nonatomic, strong) id<DYOpenSDKTrackerManagerDelegate> delegate;

+ (instancetype)shareManager;

+ (NSDictionary *)dyopenCommonTrackParams;

// 通过 DouyinOpenSDKApplicationDelegate 发埋点，会根据内外部来决定发送方式
+ (void)delegateEvent:(NSString  * _Nonnull)event params:(NSDictionary  * _Nonnull)params;

/// 发送埋点（外部版本用这个能力）
/// - Parameters:
///   - event: 埋点名称（非空）
///   - params: 埋点参数（非空）
- (void)event:(NSString * _Nonnull)event params:(NSDictionary * _Nonnull)params;

- (void)getCurrentAllTrackerCountWithCompletion:(void(^)(NSInteger count))completion;

+ (NSMutableDictionary *)getNetworkTrackerCommonParams:(NSHTTPURLResponse *)httpResponse
                                                method:(NSString *)method
                                      requestStartTime:(NSDate *)requestStartTime
                                                   url:(NSURL *)url
                                             isSuccess:(BOOL)isSuccess;

@end

NS_ASSUME_NONNULL_END
