//
//  Phobos.h
//  GengmeiDoctor
//  Data Statistic Client For Mars
//  Created by Thierry on 16/1/26.
//  Copyright © 2016年 wanmeizhensuo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "PhobosPVProtocol.h"
#import <CoreLocation/CLLocation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM (NSInteger, PhobosSigningType) {
    PhobosSigningTypeUndefined = 0,
    PhobosSigningTypeAppStore,
    PhobosSigningTypeRelease,
    PhobosSigningTypeDebug
};

@interface Phobos : NSObject

/**
 *  @brief 开启Phobos统计,默认以BATCH方式发送log.
 *
 *  @param appName  通常由数据端与客户端一起确认的区分不同app的名字
 *  @param channelId 发布渠道
 *
 *  @return Phobos实例
 *
 *  @since 0.0.1
 */
+ (Phobos *)clientWithAppName:(NSString *)appName channelId:(NSString *)channelId;

+ (instancetype)sharedClient;

+ (void)setSharedClient:(Phobos *)client;


#pragma mark - SDK配置

// Phobos在处理业务端传递来的参数时会检查是否某个value为空，如果为空会调用这个block以通知业务层，业务层可以上报这个异常，以助解决问题
@property(nonatomic, copy) void (^captureNullExpection) (NSString *eventId, NSDictionary *info);

/**
 网络状态 wifi=1, mobile=0, 不连通=-1
 */
@property (nonatomic, copy) NSString *netStatus;
/**
 //没有网络连接
 public static final String NETWORN_NONE = "none";
 //wifi连接
 public static final String NETWORN_WIFI = "wifi";
 //手机网络数据连接类型
 public static final String NETWORN_2G = "2G";
 public static final String NETWORN_3G = "3G";
 public static final String NETWORN_4G = "4G";
 public static final String NETWORN_MOBILE = "other";
 */
@property (nonatomic, copy) NSString *networkStatus;

/**
 *  @brief 设置是否打印sdk的log信息,默认不开启
 *
 *  @since 0.0.1
 */
@property (assign, nonatomic) BOOL logEnabled;

/**
 *  @brief 设置当前登录用户的ID，如果没有默认为@""
 *
 *
 *  @since 0.0.2
 */
@property (strong, nonatomic) NSString *userId;

/*!
 *  @author zhaiguojun, 16-05-31
 *
 *  @brief 用户当前的城市id
 *
 *
 *  @since 0.2.7
 */
@property (strong, nonatomic) NSString *currentCityId;

@property (strong, nonatomic) CLLocation *gps;

/**
 * 记录用户类型
 */
@property (strong, nonatomic) NSMutableDictionary *userType;

/**
 数据接收的服务器API
 */
@property (copy, nonatomic) NSString *serverAPI;

/**
 当前APP请求接口的 APIHOST（GMServerDomains.apiHost 主要用于flutter AppDelegate 中初始化需要传值
 */
@property (nonatomic, copy) NSString *apiHost;

/**
 当前APP请求接口的 cookie(主要用于flutter) 获取到cookie 的时候穿过来 或者cookie 有变化的时候传过来
 */
@property (nonatomic, copy) NSString *cookie;

/**
 灰度组, since 7.7.65
 */
@property (nonatomic, copy) NSString *greyType;

/**
 包的类型：APPSTORE、RELEASE、DEBUG
 */
@property (nonatomic, assign) PhobosSigningType signingType;

/**
 从主项目获取当前显示的controller
 */
@property (nonatomic, copy) UIViewController * (^getTopController) (void);

#pragma mark - 事件采集

/**
 *  @brief 自定义事件,数量统计.
 *
 *  @param eventId 事件Id
 *  @attributes 参数
 *  @sendNow 是否实时发送，默认为NO
 *
 *  @since 0.0.1
 */
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow;
+ (void)track:(NSString *)eventId;

/**
 *  @brief 自定义事件,数量统计  7730 精准曝光.
 *
 *  @param eventId 事件Id
 *  @attributes 参数
 *  @sendNow 是否实时发送，默认为NO
 *  @currentAPI 当前传过来的API
 *  @
 */
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow currentAPI:(NSString *)currentAPI;
+ (void)track:(NSString *)eventId currentAPI:(NSString *)currentAPI;

/**
 *  @author 翟国钧, 16-02-03 16:02:30
 *
 *  @brief H5调用的埋点方法
 *
 *  @param jsonString h5传过来的参数
 *
 *  @since 0.0.1
 */
+ (void)trackJsEvent:(NSString *)jsonString;

/**
 *  @brief PV事件开始。当controller viewWillAppear时调用
 */
- (void)onPVStart:(UIResponder<PhobosPVProtocol> *)page;
/**
 *  @brief PV事件结束。当controller viewWillDisAppear时调用
 */
- (void)onPVEnd:(UIResponder<PhobosPVProtocol> *)page;

/**
 *  @author 翟国钧, 16-03-08 11:03:45
 *
 *  @brief 有些事件需要模拟pv事件，统一用该方法处理，in out 时间相同.点击一次即触发
 *
 *  @param pageName 控件所在VC的pageName
 *  @param bid      业务id
 *  @param referer  上个月面的pagename
 *
 *  @since 5.9.1
 */
- (void)simulativePV:(NSString *)pageName businessId:(NSString *)bid referer:(NSString *)referer;

@end
NS_ASSUME_NONNULL_END
