in Sources/XCMetricsClient/Mobius/Effect Handlers/DumpParser/JSONMetricsParserFactory.swift [54:100]
func buildBuildStepParser(with type: BuildStepType) -> (Data) throws -> BuildInfo {
return { data in
let representation = try JSONMetricsParserFactory.parseJSON(data)
guard representation["identifier"] != nil else {
throw MetricsParserError.missingKey("identifier")
}
let startTimestamp: Double = representation.fetch("startTimestampMicroseconds")
let endTimestamp: Double = representation.fetch("endTimestampMicroseconds")
let detailType = DetailStepType.init(rawValue: representation.fetch("type")) ?? .other
// TODO: Parse FunctionTimes as well
let step = BuildStep(type: type,
machineName: representation.fetch("machineName") ,
buildIdentifier: representation.fetch("buildIdentifier") ,
identifier: representation.fetch("identifier") ,
parentIdentifier: representation.fetch("parentIdentifier", "targetIdentifier") ,
domain: representation.fetch("domain") ,
title: representation.fetch("title", "name") ,
signature: representation.fetch("signature") ,
startDate: representation.fetch("startDate") ,
endDate: representation.fetch("endDate") ,
startTimestamp: startTimestamp,
endTimestamp: endTimestamp,
duration: endTimestamp - startTimestamp,
detailStepType: detailType,
buildStatus: representation.fetch("buildStatus"),
schema: representation.fetch("schema"),
subSteps: [],
warningCount: representation.fetch("warningCount"),
errorCount: representation.fetch("errorCount"),
architecture: representation.fetch("architecture"),
documentURL: representation.fetch("documentURL"),
warnings: [],
errors: [],
notes: [],
swiftFunctionTimes: nil,
fetchedFromCache: representation.fetch("fetchedFromCache"),
compilationEndTimestamp: representation.fetch("compilationEndTimestamp"),
compilationDuration: representation.fetch("compilationDuration"),
clangTimeTraceFile: nil,
linkerStatistics: nil,
swiftTypeCheckTimes: nil)
return BuildInfo(step: step,
projectName: representation.fetch("projectName"),
userID: representation.fetch("userID"))
}
}