Hello all,
I wanted to get MXMetricPayload to analyse some App metrics. And for some reason the method func didReceive(_ payloads: [MXMetricPayload]) from mxMetricManager is not being executed.
For this I created a Class:
import MetricKit
public final class MetricKitManagerImpl: NSObject, MetricKitManager {
public static let shared: MetricKitManager = MetricKitManagerImpl(mxMetricManager: MXMetricManager.shared)
private let mxMetricManager: MXMetricManager
private init(
mxMetricManager: MXMetricManager
) {
self.mxMetricManager = mxMetricManager
super.init()
mxMetricManager.add(self)
}
deinit {
mxMetricManager.remove(self)
}
public func didReceive(_ payloads: [MXMetricPayload]) {
payloads.forEach {
if let scrollHitchTimeRatio = $0.animationMetrics?.scrollHitchTimeRatio.value {
sendToSomeWhere(scrollHitchTimeRatio)
}
}
}
}
Then on the AppDelegate on didFinishLaunchingWithOptions I do:
private(set) var metricsManager: MetricKitManager!
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
self.metricsManager = MetricKitManagerImpl.shared
...
}
With this setUp I am able to receive the debug playload (triggered from Xcode Menu. Debug -> Simulate Metrik Kit Payload). However, after using the app for some days, I did not receive any real payload.
Did anyone experience this? What am I doing wrong?
Thanks a lot in advance! Miguel Franco