StatisticalManager
public class StatisticalManager : NSObject, @unchecked Sendable
事件统计管理器
视图从不可见变为可见时曝光开始,触发曝光开始事件(triggerDuration为0); 视图从可见到不可见时曝光结束,视为一次曝光,触发曝光结束事件(triggerDuration大于0)并统计曝光时长。 默认未开启曝光时长统计,仅触发开始事件用于统计次数;开启曝光时长统计后会触发结束事件并统计时长,应用退后台时不计曝光时间。 默认运行模式时,视图快速滚动不计算曝光,可配置runLoopMode快速滚动时也计算曝光
-
单例模式
Declaration
Swift
public static let shared: StatisticalManager
-
是否启用通知,默认false
Declaration
Swift
public var notificationEnabled: Bool
-
是否启用分析上报,默认false
Declaration
Swift
public var reportEnabled: Bool
-
设置全局事件过滤器
Declaration
Swift
public var eventFilter: (@MainActor @Sendable (StatisticalEvent) -> Bool)?
-
设置全局事件处理器
Declaration
Swift
public var eventHandler: (@MainActor @Sendable (StatisticalEvent) -> Void)?
-
是否相同点击只触发一次,默认false,视图自定义后覆盖默认
Declaration
Swift
public var clickOnce: Bool
-
是否相同曝光只触发一次,默认false,视图自定义后覆盖默认
Declaration
Swift
public var exposureOnce: Bool
-
设置运行模式,默认default快速滚动时不计算曝光
Declaration
Swift
public var runLoopMode: RunLoop.Mode
-
是否统计曝光时长,开启后会触发曝光结束事件并计算时长,默认false
Declaration
Swift
public var exposureTime: Bool
-
设置部分可见时触发曝光的比率,范围0-1,默认>=0.95会触发曝光(因为frame有小数,忽略计算误差)
Declaration
Swift
public var exposureThresholds: CGFloat
-
计算曝光时是否自动屏蔽控制器的顶部栏和底部栏,默认true
Declaration
Swift
public var exposureIgnoredBars: Bool
-
应用回到前台时是否重新计算曝光,默认true
Declaration
Swift
public var exposureBecomeActive: Bool
-
注册单个事件处理器
Declaration
Swift
public func registerEvent(_ name: String, handler: @escaping @MainActor @Sendable (StatisticalEvent) -> Void)
-
手工触发点击统计,如果为cell需指定indexPath,点击触发时调用
Declaration
Swift
@MainActor public func trackClick(_ view: UIView?, indexPath: IndexPath? = nil, event: StatisticalEvent)
-
手工触发视图曝光并统计次数,如果为cell需指定indexPath,isFinished为曝光结束,可重复触发
Declaration
Swift
@MainActor public func trackExposure(_ view: UIView?, indexPath: IndexPath? = nil, isFinished: Bool = false, event: StatisticalEvent)
-
手工触发控制器曝光并统计次数,isFinished为曝光结束,可重复触发
Declaration
Swift
@MainActor public func trackExposure(_ viewController: UIViewController?, isFinished: Bool = false, event: StatisticalEvent)